help () { cat < options for Refal compiler -C options for C++ compiler -o place the output into EOF } execho () { echo " + $1" eval "$1" status=$? if [ $status != 0 ]; then echo "Command exited with status $status. Aborting..." exit fi } while [ -n "$1" ]; do case $1 in -R) shift if [ -z "$1" ]; then echo "-R should be followed by rfpc option." exit 1 fi rflags="$rflags $1" ;; -C) shift if [ -z "$1" ]; then echo "-C should be followed by C++ compiler option." exit 1 fi cflags="$cflags $1" ;; -o) shift if [ -z "$1" ]; then echo "-o should be followed by the name for resulting file." exit 1 else res_name=" $1" fi ;; -h|-help) help exit 0 ;; *.rf|*.asr|*.ast|*.asi) execho "$rfpc $rflags $1" files="$files ${1%.*}.cc" ;; *.rfi) # update read time of corresponding .cc file [ -r ${1%.rfi}.cc ] && head -1 ${1%.rfi}.cc > /dev/null execho "$rfpc $rflags $1" # if .cc file was modified since last read then # we probably should compile it [ -N ${1%.rfi}.cc ] && files="$files ${1%.rfi}.cc" ;; *) files="$files $1" ;; esac shift done for f in `echo $files`; do case $f in *.cc) execho "$cxx -o ${f%.cc}.o $cflags $f" obj_files="$obj_files ${f%.cc}.o" ;; *) obj_files="$obj_files $f" ;; esac done for f in `echo $obj_files`; do if !(expr " $res_files " : ".* $f .*" > /dev/null); then res_files="$res_files $f" fi done if [ -z "$res_files" ]; then echo "No files to link." exit fi execho "$cxx -o${res_name:-${res_files%%.o*}} $ldflags $res_files $ldlibs" echo "No errors."