# Critical to get rid of old versions, since they will break the install, since
# at some point one of the libraries accidently links against what's in SAGE_LOCAL,
# instead of what is in the build directory!
rm "$SAGE_LOCAL"/lib/libgd.*

cd src

if [ "$SAGE64" = "yes" ]; then
   CFLAGS=" -m64 -g $CFLAGS"
   LDFLAGS="-m64 $LDFLAGS"
else
   CFLAGS="-g $CFLAGS"
fi

export CFLAGS LDFLAGS

# We explicitly disable X and fontconfig support, since (1) X is not a SAGE dependency,
# and (2) the gd build fails on a lot of OS X PPC machines when X is enabled.
sdh_configure --without-jpeg --without-xpm --without-x --without-fontconfig \
              --with-zlib="$SAGE_LOCAL" --with-freetype="$SAGE_LOCAL" \
              $LIBGD_CONFIGURE
sdh_make
sdh_make_install
