]> mj.ucw.cz Git - eval.git/blob - mop/public/compile.sh
c467dca0f058e8a416095b583c324ed23601fcfc
[eval.git] / mop / public / compile.sh
1 # The Evaluator -- Public Compilation Script
2 # (c) 2001 Martin Mares <mj@ucw.cz>
3
4 set -e
5 [ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
6 pushd $MO_ROOT >/dev/null
7 . lib/libeval.sh
8 . cf/mop
9 popd >/dev/null
10
11 [ -n "$1" ] || die "Usage: compile (<problem> | <file> [<options>])"
12 if [ "${1%%.*}" == "$1" ] ; then
13         # Compiling problem
14         PROBLEM=$1
15         public-setup
16         . $PDIR/config
17         locate-source
18         if compile ; then
19                 mv $TDIR/$PROBLEM .
20         else
21                 echo >&2
22                 sed <check-log >&2 '1,/^Compiler output:/d;/^Compiler output files:/,$d;/^Exited /d'
23         fi
24 else
25         SRC=$1
26         [ -f $SRC ] || die "$SRC doesn't exist"
27         EXE=${1%%.*}
28         SRCEXT=${1/*./}
29         shift
30         EXTRA_CFLAGS="$@"
31         CCMD=COMP_$SRCEXT
32         [ -n "${!CCMD}" ] || die "Don't know how to compile $SRC"
33         CCMD="`eval echo ${!CCMD}`"
34         echo "$CCMD"
35         $CCMD
36 fi