#!/bin/sh # $Id: g++-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 C++"' echo 'src_sfx=".cpp"' } failure() { rm -f conftest* echo 'version=' echo 'arg="'"${arg}"'"' common_config echo 'GPPRUN=false' echo 'GPPDIR=' [ "${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 ] && GPPRUN="$2" [ "${GPPRUN}" = "" ] && GPPRUN="g++" [ "${verbose}" = 1 ] && echo -n "checking whether GNU C++ is available..." >&2 "${GPPRUN}" -v >/dev/null 2>/dev/null || failure version=`"${GPPRUN}" -v 2>&1 | grep "gcc version" | gawk '{ print $3; }'` || failure [ "${version}" != "" ] || failure cat > conftest.cpp < using namespace std; int main() { cout << "ok" << endl; return 0; } EOF "${GPPRUN}" -static conftest.cpp -o conftest 2>/dev/null >/dev/null || failure [ -x conftest ] || failure ./conftest 2>/dev/null >/dev/null || failure rm -f ./conftest* GPPDIR=`dirname "${GPPRUN}"` [ "${GPPDIR}" = . ] && GPPDIR="" echo 'version="'"${version}"'"' echo 'arg="'"${arg}"'"' common_config echo 'GPPRUN="'"${GPPRUN}"'"' echo 'GPPDIR="'"${GPPDIR}"'"' [ "${verbose}" = 1 ] && echo "yes, ${GPPRUN}, ${version}" >&2 exit 0 fi if [ x"$1" = x-l ] then echo "GNU C++ compiler [http://gcc.gnu.org]" exit 0 fi [ "${EJUDGE_LANG_CONFIG}" = "" ] && EJUDGE_LANG_CONFIG="${LANG_CONFIG_DIR}/g++.cfg" if [ -f "${EJUDGE_LANG_CONFIG}" ] then . "${EJUDGE_LANG_CONFIG}" else GPPRUN="g++" GPPDIR= fi if [ x"${GPPRUN}" = x -o x"${GPPRUN}" = xfalse ] then echo "This language is not supported." >&2 exit 1 fi if [ x"${GPPDIR}" != x ] then PATH="${GPPDIR}:${PATH}" fi if [ x"$1" = x-p ] then echo "${GPPRUN}" exit 0 fi "${GPPRUN}" -v 2>/dev/null >/dev/null || exit 1 [ x"$1" = x-f ] && echo -n "GNU C++ " "${GPPRUN}" -v 2>&1 | grep "gcc version" | gawk '{ print $3; }'