#! /bin/sh # $Id: tpc-version.in 5550 2009-02-19 18:14:43Z cher $ # Copyright (c) 2008 Alexander Chernov libexecdir="/opt/ejudge/libexec" contests_home_dir="/home/judges" local_dir="/var/lib/ejudge" LANG_CONFIG_DIR="/home/judges/compile/conf/lang.d" common_config() { echo 'long_name="Borland Pascal"' echo 'src_sfx=".pas"' echo 'exe_sfx=".exe"' echo 'arch="dos"' } failure() { rm -f conftest* echo 'version=' echo 'arg="'"${arg}"'"' common_config echo 'TPCRUN=false' [ "${verbose}" = 1 ] && echo "no" >&2 exit 1 } if [ x"$1" = x-v ] then verbose=1 shift fi # recheck the language if [ x"$1" = x-r ] then arg="$2" [ x"$2" != x ] && TPCRUN="$2" [ "${TPCRUN}" = "" ] && TPCRUN="${libexecdir}/ejudge/lang/bpcemu2" [ "${verbose}" = 1 ] && echo -n "checking whether Borland Pascal 7.0 is available..." >&2 [ -x "${TPCRUN}" ] || failure dosdir="${local_dir}" [ "${dosdir}" != "" ] || dosdir="${contests_home_dir}" [ -d "${dosdir}" ] || failure dosdir="${dosdir}/dosemu" [ -d "${dosdir}" ] || failure [ -x "${dosdir}/bin/dos" ] || failure [ -f "${dosdir}/boot/BP7/BIN/BPC.EXE" ] || failure version="7.0" rm -f ./conftest* echo 'version="'"${version}"'"' echo 'arg="'"${arg}"'"' common_config echo 'TPCRUN="'"${TPCRUN}"'"' [ "${verbose}" = 1 ] && echo "yes, ${TPCRUN}, ${version}" >&2 exit 0 fi if [ x"$1" = x-l ] then echo "Borland Pascal 7.0 (DOS mode)" exit 0 fi [ "${EJUDGE_LANG_CONFIG}" = "" ] && EJUDGE_LANG_CONFIG="${LANG_CONFIG_DIR}/tpc.cfg" if [ -f "${EJUDGE_LANG_CONFIG}" ] then . "${EJUDGE_LANG_CONFIG}" fi if [ x"${TPCRUN}" = x -o x"${TPCRUN}" = xfalse ] then echo "This language is not supported." >&2 exit 1 fi if [ x"$1" = x-p ] then echo "${TPCRUN}" exit 0 fi [ x"$1" = x-f ] && echo -n "Borland Pascal " echo "7.0"