###########################################
## PARI
###########################################

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

if [ "x$SAGE_DEBUG" = xyes ] ; then
    CFLAGS="$CFLAGS -O0 -g" # Disable optimisation, add debug symbols. Good
                            # for debugging or working around compiler bugs.
else
    CFLAGS="-O3 -g $CFLAGS" # Default optimisation, with debug symbols.
                            # Prepend to not override user's setting.
fi

export CFLAGS

cd src

$MAKE test-all

if [ $? -ne 0 ]; then
    echo "Error: PARI failed the self-tests when running '$MAKE test-all'"
    exit 1
fi

if [ -d ../parigit ]; then
    echo "WARNING: You should delete the parigit directory before submitting this spkg."
fi

echo "The PARI self-tests all passed"
