#!/bin/sh # $Id: gpc-version.in 5550 2009-02-19 18:14:43Z cher $ # Copyright (c) 2005-2008 Alexander Chernov LANG_CONFIG_DIR="/home/judges/compile/conf/lang.d" common_config() { echo 'long_name="GNU Pascal"' echo 'src_sfx=".pas"' } failure() { rm -f conftest* echo 'version=' echo 'arg="'"${arg}"'"' common_config echo 'GPCRUN=false' echo 'GPCDIR=' [ "${verbose}" = 1 ] && echo "no" >&2 exit 1 } unset LANG unset LC_ALL unset LC_MESSAGES unset LANGUAGE if [ x"$1" = x-v ] then verbose=1 shift fi # recheck the language if [ x"$1" = x-r ] then arg="$2" [ x"$2" != x ] && GPCRUN="$2" [ "${GPCRUN}" = "" ] && GPCRUN="gpc" [ "${verbose}" = 1 ] && echo -n "checking whether GNU Pascal is available..." >&2 "${GPCRUN}" -v >/dev/null 2>/dev/null || failure version=`"${GPCRUN}" --version | gawk '{ print $1; exit 0; }'` || failure [ "${version}" != "" ] || failure cat > conftest.pas </dev/null >/dev/null || failure [ -x conftest ] || failure ./conftest 2>/dev/null >/dev/null || failure rm -f ./conftest* GPCDIR=`dirname "${GPCRUN}"` [ "${GPCDIR}" = . ] && GPCDIR="" echo 'version="'"${version}"'"' echo 'arg="'"${arg}"'"' common_config echo 'GPCRUN="'"${GPCRUN}"'"' echo 'GPCDIR="'"${GPCDIR}"'"' [ "${verbose}" = 1 ] && echo "yes, ${GPCRUN}, ${version}" >&2 exit 0 fi if [ x"$1" = x-l ] then echo "GNU Pascal compiler (obsolete)" exit 0 fi [ "${EJUDGE_LANG_CONFIG}" = "" ] && EJUDGE_LANG_CONFIG="${LANG_CONFIG_DIR}/gpc.cfg" if [ -f "${EJUDGE_LANG_CONFIG}" ] then . "${EJUDGE_LANG_CONFIG}" else GPCRUN="gpc" GPCDIR= fi if [ x"${GPCRUN}" = x -o x"${GPCRUN}" = xfalse ] then echo "This language is not supported." >&2 exit 1 fi if [ x"${GPCDIR}" != x ] then PATH="${GPCDIR}:${PATH}" fi if [ x"$1" = x-p ] then echo "${GPCRUN}" exit 0 fi "${GPCRUN}" --version 2>/dev/null >/dev/null || exit 1 [ x"$1" = x-f ] && echo -n "GNU Pascal " "${GPCRUN}" --version | gawk '{ print $1; }' [ $? != 0 -a $? != 1 ] && exit 1 exit 0