#!/bin/sh # $Id: perl-version.in 6118 2011-03-18 06:23:23Z cher $ # Copyright (c) 2005-2011 Alexander Chernov LANG_CONFIG_DIR="/home/judges/compile/conf/lang.d" common_config() { echo 'long_name="Perl"' echo 'src_sfx=".pl"' echo 'arch="linux-shared"' } failure() { rm -f conftest* echo 'version=' echo 'arg="'"${arg}"'"' common_config echo 'PERLPATH=/bin/false' [ "${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 ] && perl="$2" [ "${perl}" = "" ] && perl="perl" [ "${verbose}" = 1 ] && echo -n "checking whether Perl is available..." >&2 "${perl}" --version >/dev/null 2>&1 || failure version=`"${perl}" -e '$z=int($]*1000000); $v1 = int($z / 1000000); $z = int($z % 1000000);$v2 = int($z / 1000);$v3 = int($z % 1000);print $v1 . "." . $v2 . "." . $v3 . "\n";'` || failure [ "${version}" != "" ] || failure PERLPATH=`which "${perl}"` || failure [ "${PERLPATH}" != "" ] || failure echo "#! ${PERLPATH} -W" > conftest.pl echo 'print "OK"' >> conftest.pl chmod +x ./conftest.pl || failure ./conftest.pl >/dev/null 2>&1 || failure rm -f ./conftest* echo 'version="'"${version}"'"' echo 'arg="'"${arg}"'"' common_config echo 'PERLPATH="'"${PERLPATH}"'"' [ "${verbose}" = 1 ] && echo "yes, ${PERLPATH}, ${version}" >&2 exit 0 fi if [ x"$1" = x-l ] then echo "Perl interpreter [http://www.perl.org]" exit 0 fi [ "${EJUDGE_LANG_CONFIG}" = "" ] && EJUDGE_LANG_CONFIG="${LANG_CONFIG_DIR}/perl.cfg" if [ -f "${EJUDGE_LANG_CONFIG}" ] then . "${EJUDGE_LANG_CONFIG}" else PERLPATH="/usr/bin/perl" fi if [ x"${PERLPATH}" = x -o x"${PERLPATH}" = x/bin/false ] then echo "This language is not supported." >&2 exit 1 fi if [ x"$1" = x-p ] then echo "${PERLPATH}" exit 0 fi "${PERLPATH}" --version 2>/dev/null >/dev/null || exit 1 [ x"$1" = x-f ] && echo -n "Perl " "${PERLPATH}" -e '$z=int($]*1000000); $v1 = int($z / 1000000); $z = int($z % 1000000);$v2 = int($z / 1000);$v3 = int($z % 1000);print $v1 . "." . $v2 . "." . $v3 . "\n";'