CFLAGS="$CFLAGS -I$SAGE_LOCAL/include -g"

COMPILER=`testcc.sh $CC`

if [ "$COMPILER"  = "GCC" ] ; then
   CFLAGS="$CFLAGS -fPIC -Wall -pedantic"
elif [ "$COMPILER" = "Sun_Studio" ] ; then
   CFLAGS="$CFLAGS -Kpic"
elif [ "$COMPILER" = "HP_on_HP-UX" ] ; then
   CFLAGS="$CFLAGS + z"
fi

if [ "x$SAGE_DEBUG" = "xyes" ]; then
   CFLAGS="$CFLAGS -O0"
   ENABLE_DEBUG="--enable-debug"
else
   CFLAGS="$CFLAGS -O2"
   ENABLE_DEBUG=""
fi

export CFLAGS

if [ "x$SAGE_FAT_BINARY" = "xyes" ]; then
    DISABLE_SSE2="--disable-sse2"
else
    DISABLE_SSE2=""
fi

# otherwise we might run into problems with old headers
rm -rf "$SAGE_LOCAL/include/m4ri"

cd src

# Configure and build M4RI
sdh_configure --enable-shared --disable-static $ENABLE_DEBUG $DISABLE_SSE2
sdh_make
sdh_make_install
