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

###############################################################################
#
# FLINT Sage install script
#
###############################################################################

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

if [ "$SAGE64" = "yes" ]; then
    echo "Building a 64-bit version of FLINT."
    ABI="64"; export ABI
fi

if [ "$SAGE_DEBUG" = "yes" ]; then
    echo "Building a debug version of FLINT."
    CFLAGS="-O0 -g $CFLAGS"; export CFLAGS
    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
fi

if [ "$UNAME" = "CYGWIN" ]; then
    echo "Only building a shared version of FLINT on Cygwin."
    FLINT_CONFIGURE="--disable-static $FLINT_CONFIGURE"
fi

cd src

echo "Patching FLINT."
for patch in ../patches/*.patch; do
    [ -f "$patch" ] || continue
    patch -p1 <"$patch"
    if [ $? -ne 0 ]; then
        echo >&2 "Error applying '$patch'"
        exit 1
    fi
done

echo "Configuring FLINT."
./configure --prefix="$SAGE_LOCAL" --with-mpir="$SAGE_LOCAL" \
    --with-mpfr="$SAGE_LOCAL" --with-ntl="$SAGE_LOCAL" $FLINT_CONFIGURE
if [ $? -ne 0 ]; then
    echo >&2 "Error: Failed to configure FLINT."
    exit 1
fi

echo "Building FLINT shared library."
$MAKE
if [ $? -ne 0 ]; then
    echo >&2 "Error: Failed to build FLINT shared library."
    exit 1
fi

echo "Deleting old FLINT files."
rm -f $SAGE_LOCAL/lib/libflint*
rm -rf $SAGE_LOCAL/include/flint

echo "Installing new FLINT files."
$MAKE install
if [ $? -ne 0 ]; then
    echo >&2 "Error: Failed to install FLINT."
    exit 1
fi