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

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

cd src

# Apply patches.
for patch in ../patches/*.patch; do
    [ -r "$patch" ] || continue  # Skip non-existing or non-readable patches
    patch -p1 <"$patch"
    if [ $? -ne 0 ]; then
        echo >&2 "Error applying '$patch'"
        exit 1
    fi
done


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

if [ "$SAGE64" = "yes" ]; then
    echo "Building a 64-bit version of IML."
    CFLAGS="-m64 $CFLAGS"
fi

if [ -d "$SAGE_LOCAL/include/atlas" ]; then
    # We actually installed ATLAS
    echo "Using ATLAS headers installed by Sage"
    ./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" \
        --enable-shared --with-default="$SAGE_LOCAL"
else
    # We symlinked from a system-wide installation, so let's use GSL's header
    # Note that setting --with-atlas-lib to /usr/lib does not really make sense
    echo "Using system-wide ATLAS, using headers copied from GSL"
    ./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" \
        --enable-shared --with-default="$SAGE_LOCAL" \
        --with-atlas-include="`pwd`" --with-atlas-lib=/usr/lib
fi

if [ $? -ne 0 ]; then
    echo >&2 "Error configuring IML."
    exit 1
fi

$MAKE
if [ $? -ne 0 ]; then
    echo >&2 "Error building IML."
    exit 1
fi

$MAKE install
if [ $? -ne 0 ]; then
    echo >&2 "Error installing IML."
    exit 1
fi