if [ "$SAGE_LOCAL" = "" ]; then
    echo "SAGE_LOCAL undefined ... exiting";
    echo "Maybe run 'sage -sh'?"
    exit 1
fi

cd src

# Ensure FreeBSD build finds new, local math.h and complex.h
if [ "$UNAME" = FreeBSD ]; then
    export CPPFLAGS="$CPPFLAGS -I$SAGE_LOCAL/include"
fi

sdh_pip_install .

if [ $? -ne 0 ]; then
    echo "Error building/installing cvxopt"
    exit 1
fi

if [ "x$SAGE_SPKG_INSTALL_DOCS" = xyes ] ; then
   cd doc
# This part would be used to build the documentation with sphinx.
# cvxopt would then have to depend on sphinx.
# in 1.1.5 the documentation is shipped already built and up to date.
#   ${MAKE} -B html
#   if [ $? -ne 0 ]; then
#      echo "Error building the documentation"
#      exit 1
#   fi
# checking to see if there is previously installed documentation.
   if [ -d $SAGE_LOCAL/share/doc/cvxopt/html ] ; then
      rm -rf $SAGE_LOCAL/share/doc/cvxopt/html
   fi
   mkdir -p $SAGE_LOCAL/share/doc/cvxopt/html
   cp -r html/* $SAGE_LOCAL/share/doc/cvxopt/html/
fi

