Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/build/pkgs/glpk/spkg-install
8815 views
#!/usr/bin/env bash

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

# glpk's build system uses the output of grep
unset GREP_OPTIONS

# The version of libtool in this glpk package requires that
# RM/MV/CP if they are set include the -f option
# See for example the discussion at:
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=523750

# It was agreed some time back to remove these environment variables.
# nobody in their right mind will want to set them.

unset MV && export MV
unset RM && export RM
unset CP && export CP

# Let the user set an environment variable CFLAG64 to indicate the flag
# for the C compiler to build 64-bit code. If not set, asssume it is -m64
# as that is what is used by both GCC and SunStudio, but -m64 is not used
# by IBM's compiler on AIX or HP's compiier on HP-UX

if [ -z $CFLAG64 ] ; then
  CFLAG64=-m64 # -m64 is used by gcc and SunStudio.
fi

CPPFLAGS="-I $SAGE_LOCAL/include" && export CPPFLAGS
LDFLAGS="-L$SAGE_LOCAL/lib" &&  export LDFLAGS

if [ "x$SAGE64" = xyes ] ; then
   echo "Building a 64-bit version of GLPK"
   CFLAGS="$CFLAGS $CFLAG64" && export CFLAGS
   LDFLAGS="$LDFLAGS $CFLAG64" && export LDFLAGS
   CPPFLAGS="$CPPFLAGS $CFLAG64" && export CPPFLAGS
   # Very rarly is it needed to add '-m64' to CPPFLAGS,
   # but potentially it can be.
fi

cd src

./configure --prefix=$SAGE_LOCAL --libdir="$SAGE_LOCAL/lib" --with-gmp --with-zlib --disable-static

if [ $? -ne 0 ]; then
    echo "An error occurred whilst configuring GLPK"
    exit 1
fi

$MAKE
if [ $? -ne 0 ]; then
    echo "An error occurred whilst building GLPK"
    exit 1
fi

# There are two cases where this can fail to install - at the point of
# installing the C source code and at the point of using Python.

$MAKE install
if [ $? -ne 0 ]; then
    echo "An error occurred whilst installing GLPK (during the \"make install\" process)"
    exit 1
fi