set -xe
src=*.c

getopt() {
  perl -ne "print \$1 if (m,/\* $1: (.*?) \*/, or m,// $1: (.*?)\n,)" $2
}

std=
echo "$1" | grep -q '.cpp$' && std="-std=c++14"

opts=$(eval echo $(getopt VERIFY_OPTS $src))
args=$(eval echo $(getopt PROGRAM_OPTS $src))
ccopt=$(eval echo $(getopt CC_OPTS $src))

echo "building..."
/var/obj/xrockai-divine-next/release/tools/divine cc -o main.bc $std $ccopt $src $gtest
echo "build done"
rm -f $src

# vim: syntax=sh
