rm -f "$SAGE_LOCAL/bin/sqlite3"

cd src

# Use newer version of config.guess and config.sub (see Trac #19711)
cp "$SAGE_ROOT"/config/config.* .


# Build with -O0 if debugging requested
if [ "$SAGE_DEBUG" = "yes" ]; then
    CFLAGS="-g -O0 $CFLAGS"
else
    CFLAGS="-g -O2 $CFLAGS"
fi

export CPPFLAGS="$CPPFLAGS -I$SAGE_LOCAL/include"
export CFLAGS

# Old OS X systems need -DSQLITE_WITHOUT_ZONEMALLOC
if uname -sr |grep 'Darwin [0-8][.]' >/dev/null; then
    export CPPFLAGS="$CPPFLAGS -DSQLITE_WITHOUT_ZONEMALLOC"
fi


sdh_configure
sdh_make
sdh_make_install
