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

#################################
# Set up environment variables: #
#################################

# It shouldn't be necessary to add Sage's include directory here,
# since we configure with '--with-gmp=...'.
# Also, '-I...' should normally be added to (just) CPPFLAGS.
CFLAGS="$CFLAGS -fPIC -I\"$SAGE_LOCAL/include\""
CXXFLAGS="$CXXFLAGS -fPIC -I\"$SAGE_LOCAL/include\""

export CFLAGS CPPFLAGS CXXFLAGS LDFLAGS


cd src/

echo "Building and running Givaro's test suite..."
$MAKE check
if [[ $? -ne 0 ]]; then
    echo >&2 "Error while building or running Givaro's test suite."
    exit 1
fi
echo "Givaro's test suite passed."
