2 # Compile script for MO-P
3 # 2015 - Jan Hadrava <had@kam.mff.cuni.cz>
10 [ -n "$1" ] || die "Usage: compile <source-file> [<options>]"
12 if [ "${1%.*}" == "$1" ]; then
13 die "Source file must have suffix. Can not compile."
16 [ -f "$src" ] || die "File \"$src\" doesn't exist"
26 comm="gcc -static -DEVAL -O2 -std=gnu11 $cflags $src -o ${bin} -lm" ;;
28 comm="g++ -static -DEVAL -O2 -std=gnu++11 $cflags $src -o ${bin}" ;;
30 comm="fpc $cflags -XS -dEVAL -O2 -o${bin} $src";;
32 die "Unknown suffix \"$ext\"."
35 echo -e '\e[0;32m'"Compiling..."'\e[0m' >&2
36 echo -e '\e[0;33m'"$comm"'\e[0m' >&2
37 $comm && echo -e '\e[0;32m'"Done."'\e[0m' >&2 || die -e '\e[0;31m'"Compilation failed!"'\e[0m'