if [ -z "$SAGE_LOCAL" ] ; then
    echo >&2 "SAGE_LOCAL undefined ... exiting"
    echo >&2 "Maybe run 'sage -sh'?"
    exit 1
fi

CUR=`pwd`

if [ "x$SAGE_DEBUG" = xyes ] ; then
    CFLAGS="$CFLAGS -g -O0" # No optimisation, aids debugging.
else
    CFLAGS="$CFLAGS -g -O2" # Normal optimisation.
fi

export CFLAGS

dirsr="$CUR"/src
echo "Testing in $dirsr"
cd "$dirsr"
$MAKE check
if [ $? -ne 0 ]; then
     echo >&2 "Error: tests failed"
     exit 1
fi
