#!/bin/sh
# autopkgtest check: Build and run a program with the help of musl-gcc
# (C) 2013 Thomas Moulard
# (C) 2014 Anton Gladky
# Author: Thomas Moulard <thomas.moulard@gmail.com>
#         Anton Gladky <gladk@debian.org>

set -e

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF > hello.c
#include <stdio.h>
int main(int argc, char **argv)
{ 
  printf("hello %d\n", argc); 
  return 0;
}
EOF

musl-gcc -static -Os -o hello hello.c
echo "build: OK"
[ -x hello ]
./hello
echo "run: OK"
