diff --git a/build/envsetup.sh b/build/envsetup.sh index 5e6a761b92b3c01ccfbb264650058df9a77ec740..2556441de8e6895fec76f9c6d0d8ec963fb16894 100644 --- a/build/envsetup.sh +++ b/build/envsetup.sh @@ -20,12 +20,39 @@ function print_usage { echo " " } +function gettop { + local TOPFILE=build/core/maple_variables.mk + if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then + # The following circumlocution ensures we remove symlinks from TOP. + (cd $TOP; PWD= /bin/pwd) + else + if [ -f $TOPFILE ] ; then + # The following circumlocution (repeated below as well) ensures + # that we record the true directory name and not one that is + # faked up with symlink names. + #PWD= /bin/pwd + /bin/pwd -L + else + local HERE=$PWD + local T= + while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do + \cd .. + T=`PWD= /bin/pwd -P` + done + \cd $HERE + if [ -f "$T/$TOPFILE" ]; then + echo $T + fi + fi + fi +} + if [ "$#" -lt 2 ]; then print_usage # return fi -curdir=$(pwd) +curdir=$(gettop) export MAPLE_ROOT=${curdir} export CASE_ROOT=${curdir}/testsuite export OUT_ROOT=${curdir}/output