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

# If SAGE_DEBUG is set to 'yes', add debugging information.  Since both
# the Sun and GNU compilers accept -g to give debugging information,
# there is no need to do anything specific to one compiler or the other.
if [ "x$SAGE_DEBUG" = xyes ]; then
    echo "Code will be built with debugging information present. Unset 'SAGE_DEBUG'"
    echo "or set it to 'no' if you don't want that."

    CFLAGS="$CFLAGS -O0 -g"
    CXXFLAGS="$CXXFLAGS -O0 -g"
else
    echo "No debugging information will be used during the build of this package."
    echo "Set 'SAGE_DEBUG' to 'yes' if you want debugging information present (-g added)."
fi

# Export everything. Probably not necessary in most cases.
export CFLAGS
export CXXFLAGS="$CXXFLAGS -std=c++11"

export DEFINES=""

cd src/src   # Now we are in src/src.

# Build everything:
echo "Now building lcalc, example programs and the shared library..."
sdh_make
