cd src

set -e

cp -p ../patches/GC.c src
cp -p ../patches/sysdep.h include

saclib=$(pwd -P)
export saclib
bin/sconf && bin/mkproto && bin/mkmake

(cd lib/objd && ${MAKE:-make} CC="$CC" SACFLAG="-std=gnu17 -g -DNO_SACLIB_MACROS" EXTENSION=d)

(cd lib/objo && ${MAKE:-make} CC="$CC" SACFLAG="-std=gnu17" EXTENSION=o)

# install saclib to the Sage tree
cd ..
mv src $SAGE_DESTDIR_LOCAL/lib/saclib
