# -*- shell-script -*-
###########################################################################
#
# Set environment variables for building and/or running Sage.
#
# NOTES:
# - You must *source* this script instead of executing.
# - Use "return" instead of "exit" to signal a failure. Since this
# file is sourced, an "exit" here will actually exit src/bin/sage,
# which is probably not intended.
# - All environment variables set here should be *exported*, otherwise
# they won't be available in child programs.
# - This script has a version number such that a newer version of
# sage-env can be sourced when upgrading. See below.
#
# If you want to set all environment variables for your shell like
# they are during the build of Sage packages, type
#
# . src/bin/sage-env
#
# from the SAGE_ROOT directory.
#
# AUTHORS: William Stein, David Kirkby, Jeroen Demeyer,
# J. H. Palmieri, Leif Leonhardy and others.
#
##########################################################################
# Resolve all symbolic links in a filename. This more or less behaves
# like "readlink -f" except that it does not convert the filename to an
# absolute path (a relative path remains relative), nor does it treat
# "." or ".." specially.
#
# AUTHOR: Jeroen Demeyer (2011-08-23): Trac tickets #5852 and #11704
#
resolvelinks() {
# $in is what still needs to be converted (normally has no starting slash)
in="$1"
# $out is the part which is converted (normally ends with trailing slash)
out="./"
# Move stuff from $in to $out
while [ -n "$in" ]; do
# Normalize $in by replacing consecutive slashes by one slash
while { in_single_slash=${in//\/\//\/}; [ "$in" != "$in_single_slash" ]; }; do
in=$in_single_slash
done
# If $in starts with a slash, remove it and set $out to the root
in_without_slash=${in/#\//}
if [ "$in" != "$in_without_slash" ]; then
in=$in_without_slash
out="/"
continue
fi
# Check that the directory $out exists by trying to cd to it.
# If this fails, then cd will show an error message (unlike
# test -d "$out"), so no need to be more verbose.
( cd "$out" ) || return $?
# Get the first component of $in
f=${in%%/*}
# If it is not a symbolic link, simply move it to $out
if [ ! -L "$out$f" ]; then
in=${in#"$f"}
out="$out$f"
# If the new $in starts with a slash, move it to $out
in_without_slash=${in/#\//}
if [ "$in" != "$in_without_slash" ]; then
in=$in_without_slash
out="$out/"
fi
continue
fi
# Now resolve the symbolic link "$f"
f_resolved=`readlink -n "$out$f" 2>/dev/null`
status=$?
# status 127 means readlink could not be found.
if [ $status -eq 127 ]; then
# We don't have "readlink", try a stupid "ls" hack instead.
# This will fail if we have filenames like "a -> b".
fls=`ls -l "$out$f" 2>/dev/null`
status=$?
f_resolved=${fls##*-> }
# If $fls equals $f_resolved, then certainly
# something is wrong
if [ $status -eq 0 -a "$fls" = "$f_resolved" ]; then
echo >&2 "Cannot parse output from ls -l '$out$f'"
return 1
fi
fi
if [ $status -ne 0 ]; then
echo >&2 "Cannot read symbolic link '$out$f'"
return $status
fi
# In $in, replace $f by $f_resolved (leave $out alone)
in=${in/#"$f"/"$f_resolved"}
done
# Return $out
echo "$out"
}
# New value for SAGE_ROOT: either SAGE_ROOT (if given)
# or a guessed value based on pwd.
if [ -n "$SAGE_ROOT" ]; then
NEW_SAGE_ROOT="$SAGE_ROOT"
elif [ -f sage -a -d build ]; then
NEW_SAGE_ROOT="."
elif [ -f ../../sage -a -d ../../build ]; then
NEW_SAGE_ROOT="../.."
else
# No idea what SAGE_ROOT should be...
echo >&2 "Error: You must set the SAGE_ROOT environment variable or run this"
echo >&2 "script from the SAGE_ROOT or SAGE_ROOT/local/bin/ directory."
return 1
fi
# Make NEW_SAGE_ROOT absolute
NEW_SAGE_ROOT=`cd "$NEW_SAGE_ROOT" && pwd -P`
# Sanity check NEW_SAGE_ROOT
if [ -f "$NEW_SAGE_ROOT/sage" -a -d "$NEW_SAGE_ROOT/build" ]; then
:
else
echo >&2 "Error: SAGE_ROOT is set to a bad value:"
echo >&2 "SAGE_ROOT=$SAGE_ROOT"
echo >&2 "You must correct it or erase it and run this script from the SAGE_ROOT"
echo >&2 "or SAGE_ROOT/local/bin/ directory."
return 1
fi
# Warn if NEW_SAGE_ROOT does not equal the old SAGE_ROOT
if [ "$SAGE_ROOT" != "$NEW_SAGE_ROOT" -a -n "$SAGE_ROOT" ]; then
echo >&2 "Warning: overwriting SAGE_ROOT environment variable:"
echo >&2 "Old SAGE_ROOT=$SAGE_ROOT"
echo >&2 "New SAGE_ROOT=$NEW_SAGE_ROOT"
fi
# Don't execute the commands more than once for the same version of
# sage-env. Check this after checking the validity of SAGE_ROOT, but
# before modifying its value.
#
# The idea of versioning is that SAGE_ENV_SOURCED will be set to a
# "version number" of sage-env. If a different version of sage-env was
# sourced earlier (when upgrading), we still source the new version.
# The sage-env version should be increased whenever a newer sage-env is
# required for upgrading. Note that build/deps might also need
# to be changed: the packages which need the new sage-env must depend on
# SAGE_ROOT_REPO (the root repo contains sage-env).
#
# sage-env version history:
# - sage-4.7.1: version 1 (#10469)
# - sage-5.4: version 2 (#13395)
# - sage-5.10: version 3 (#14699)
# - sage-6.0: version 4 (#14715)
#
SAGE_ENV_VERSION=4
if [ "$SAGE_ENV_SOURCED" = "$SAGE_ENV_VERSION" ]; then
# Already sourced, nothing to do.
return 0
fi
export SAGE_ENV_SOURCED=$SAGE_ENV_VERSION
export SAGE_ROOT="$NEW_SAGE_ROOT"
# sage-env must know where the Sage's script files are
if [ -z "$SAGE_SCRIPTS_DIR" ]; then
if [ -f "`dirname $0`/sage-env" ]; then
SAGE_SCRIPTS_DIR=`dirname $0`
elif [ -f "$SAGE_ROOT/local/bin/sage-env" ]; then
SAGE_SCRIPTS_DIR="$SAGE_ROOT/local/bin"
elif [ -f "$SAGE_ROOT/src/bin/sage-env" ]; then
SAGE_SCRIPTS_DIR="$SAGE_ROOT/src/bin"
else
echo >&2 "Error: You must set the SAGE_SCRIPTS_DIR environment variable to run this"
return 1
fi
elif [ ! -f "$SAGE_SCRIPTS_DIR/sage-env" ]; then
echo >&2 "Error: SAGE_SCRIPTS_DIR is set to a bad value:"
echo >&2 "SAGE_SCRIPTS_DIR=$SAGE_SCRIPTS_DIR"
echo >&2 "You must correct it or erase it and rerun this script"
return 1
fi
# Make SAGE_SCRIPTS_DIR absolute
export SAGE_SCRIPTS_DIR="`cd "$SAGE_SCRIPTS_DIR" && pwd -P`"
# Call with: contains_spaces X${VAR}X
# i.e., WITHOUT quotes but some character(s) around the environment variable to test.
# (This function does return false for empty/unset variables.)
contains_spaces()
{
if [ $# -ne 1 ]; then
return 0 # true
else
return 1 # false
fi
}
if contains_spaces X${SAGE_ROOT}X ; then
echo "Error: The path to the Sage directory (\$SAGE_ROOT) MUST NOT contain spaces."
echo "It is currently \"$SAGE_ROOT\"."
echo "Please correct this by moving Sage (or renaming one or more directories) first."
echo "Exiting now..."
return 1
fi
if [ 1 = 2 ]; then
echo "The following enviroment variables can be set by the user"
echo "AR The archiver (e.g. ar, /usr/ccs/bin/ar or /usr/bin/ar)"
echo "AS The assembler (e.g. as, /usr/ccs/bin/as or /usr/bin/as)"
echo "CC The C compiler (e.g cc, /opt/SUNWspro/bin/cc or /usr/bin/gcc)"
echo "CFLAGS Flag(s) for the C compiler (e.g. -g -Wall -O2)"
echo " (You are advised to a some optimisation flag(s), such as -O2 or -xO2 to CFLAGS)"
echo "CXX The C++ compiler (e.g g++, /opt/SUNWspro/bin/CC or /usr/local/bin/g++)"
echo "CXXFLAGS Flag(s) for the C++ compiler (e.g. -fast -fsimple=1 -x04)"
echo "LD The linker (e.g. ld, /usr/ccs/bin/ld or /usr/bin/ld)"
echo "LDFLAGS Linker flag(s) (e.g. -D token)"
echo "LN Used to make links (e.g. ln, /usr/xpg4/bin/ln or /usr/bin/ln)"
echo "MAKE The make program (e.g. make, /usr/bin/make or /usr/local/bin/gmake)"
echo "MAKEFLAGS Flag(s) to make (e.g. -j4)."
echo "RANLIB Archiver ranlib (e.g. ranlib, /usr/ccs/bin/ranlib etc)"
echo "SAGE64 Set to \"yes\" to build a 64-bit binary (Solaris SPARC or Solaris x86 only)"
echo "SHAREDFLAGS Flag(s) necessary for building a shared library (e.g. -fPIC or -xcode=pic32)"
echo "We attempt to set this to sensible values, but check below to"
echo "ensure they are OK. If you wish to override any then please use:"
echo "setenv NAME_OF_ENVIROMENT_VARIABLE value_of_enviroment_variable"
echo "(if you use tcsh, csh or a similar shell) or"
echo "NAME_OF_ENVIROMENT_VARIABLE value_of_enviroment_variable"
echo "export NAME_OF_ENVIROMENT_VARIABLE"
echo "if you use sh, bash or a similar shell"
fi
# Setting Sage-related location environment variables.
export SAGE_LOCAL="$SAGE_ROOT/local"
export SAGE_ETC="$SAGE_LOCAL/etc"
export SAGE_SHARE="$SAGE_LOCAL/share"
export SAGE_EXTCODE="$SAGE_SHARE/sage/ext"
export SAGE_SPKG_INST="$SAGE_LOCAL/var/lib/sage/installed"
export SAGE_LOGS="$SAGE_ROOT/logs/pkgs"
export SAGE_SRC="$SAGE_ROOT/src"
export SAGE_DOC="$SAGE_SRC/doc"
export PATH="$SAGE_SRC/bin:$SAGE_LOCAL/bin:$PATH"
# We offer a toolchain option, so if $SAGE_LOCAL/toolchain/toolchain-env exists source it.
# Since the user might do something crazy we do not do any checks, but hope for the best.
if [ -f $SAGE_LOCAL/toolchain/toolchain-env ]; then
source $SAGE_LOCAL/toolchain/toolchain-env
fi
# Mac OS X-specific setup
if [ `uname` = "Darwin" ]; then
# set MACOSX_DEPLOYMENT_TARGET -- if set incorrectly, this can
# cause lots of random "Abort trap" issues on OSX. see trac
# #7095 for an example.
MACOSX_VERSION=`uname -r | awk -F. '{print $1}'`
MACOSX_DEPLOYMENT_TARGET=10.$[$MACOSX_VERSION-4]
export MACOSX_DEPLOYMENT_TARGET
fi
# Compile-time path for libraries. This is the equivalent of
# adding the gcc option -L $SAGE_LOCAL/lib.
[ -z "$LIBRARY_PATH" ] || LIBRARY_PATH="${LIBRARY_PATH}:"
export LIBRARY_PATH="${LIBRARY_PATH}$SAGE_LOCAL/lib"
# Compile-time path for include files. This is the equivalent of
# adding the gcc option -I $SAGE_LOCAL/include.
[ -z "$CPATH" ] || CPATH="${CPATH}:"
export CPATH="${CPATH}$SAGE_LOCAL/include"
# Add Debian multi-arch directories if applicable.
# See http://wiki.debian.org/Multiarch
MULTI_ARCH=`dpkg-architecture -qDEB_BUILD_MULTIARCH 2>/dev/null`
if [ -n "$MULTI_ARCH" ]; then
LIBRARY_PATH="${LIBRARY_PATH}:/usr/lib/$MULTI_ARCH"
CPATH="${CPATH}:/usr/include/$MULTI_ARCH"
fi
# For PARI/GP
GP_DATA_DIR="$SAGE_LOCAL/share/pari" && export GP_DATA_DIR
GPHELP="$SAGE_LOCAL/bin/gphelp" && export GPHELP
GPDOCDIR="$SAGE_LOCAL/share/pari/doc" && export GPDOCDIR
# Make Mercurial always use utf-8 for usernames,...
# See Trac Ticket #11830
HGENCODING="utf8" && export HGENCODING
# Make Mercurial not use any user defaults (like enabling the pager extension)
# This is needed in order to use mercurial in scripts. When running hg
# directly through "sage -hg", we will disable HGPLAIN in src/bin/sage.
# See Trac Ticket #12058
HGPLAIN="yes" && export HGPLAIN
SINGULARPATH="$SAGE_LOCAL/share/singular" && export SINGULARPATH
SINGULAR_EXECUTABLE="$SAGE_LOCAL/bin/Singular" && export SINGULAR_EXECUTABLE
if [ "$SAGE_SERVER" = "" ]; then
SAGE_SERVER="http://www.sagemath.org/"
export SAGE_SERVER
fi
if [ "$SAGE_UPSTREAM" = "" ]; then
SAGE_UPSTREAM="${SAGE_SERVER}packages/upstream"
export SAGE_UPSTREAM
fi
if [ -z "$SAGE_REPO_ANONYMOUS" ]; then
SAGE_REPO_ANONYMOUS="git://trac.sagemath.org/sage.git"
export SAGE_REPO_ANONYMOUS
fi
if [ -z "$SAGE_REPO_AUTHENTICATED" ]; then
SAGE_REPO_AUTHENTICATED="ssh://[email protected]:2222/sage.git"
export SAGE_REPO_AUTHENTICATED
fi
if [ -z "$SAGE_DISTFILES" ]; then
SAGE_DISTFILES="$SAGE_ROOT/upstream"
export SAGE_DISTFILES
fi
# Check that $HOME exists
if [ "$HOME" = "" ]; then
echo >&2 'Error: environment variable $HOME is not set.'
return 1
fi
if ! [ -d "$HOME" ]; then
echo >&2 "Error: HOME directory '$HOME' does not exist."
return 1
fi
if [ "$DOT_SAGE" = "" ]; then
# It is *not* an error if this directory does not exist, it will
# be created in src/bin/sage or src/sage/misc/misc.py.
# This also works if $HOME/.sage is a symbolic link to a
# non-existing directory.
DOT_SAGE=`resolvelinks "$HOME/.sage"`
# In theory, DOT_SAGE is not required to have a trailing slash.
# But since there are some issues (#11924, maybe #12221),
# we add a slash for safety.
DOT_SAGE="${DOT_SAGE}/"
export DOT_SAGE
fi
if [ "$SAGE_STARTUP_FILE" = "" ]; then
SAGE_STARTUP_FILE="$DOT_SAGE/init.sage"
export SAGE_STARTUP_FILE
fi
if [ -d "$SAGE_ROOT/local/lib/python" ]; then
PYTHONPATH="$SAGE_ROOT/local/lib/python"
if [ -n "$SAGE_PATH" ]; then
PYTHONPATH="$SAGE_PATH:$PYTHONPATH"
fi
PYTHONHOME="$SAGE_ROOT/local"
export PYTHONPATH
export PYTHONHOME
fi
if [ -z "${SAGE_ORIG_LD_LIBRARY_PATH_SET}" ]; then
SAGE_ORIG_LD_LIBRARY_PATH=$LD_LIBRARY_PATH && export SAGE_ORIG_LD_LIBRARY_PATH
SAGE_ORIG_LD_LIBRARY_PATH_SET=True && export SAGE_ORIG_LD_LIBRARY_PATH_SET
fi
# Use a matplotlib config directory specific to Sage and specific to
# the version number of matplotlib, by setting the environment
# variable MPLCONFIGDIR. See
# http://trac.sagemath.org/sage_trac/ticket/6235 and
# http://trac.sagemath.org/sage_trac/ticket/9221. Find the version
# number for matplotlib by reading the file
# SAGE_LOCAL/lib/python/site-packages/matplotlib/__init__.py, and use
# the version number in the name of the directory. If that file
# doesn't exist, matplotlib hasn't been installed yet, so don't set
# MPLCONFIGDIR.
MPLINITFILE="$SAGE_LOCAL/lib/python/site-packages/matplotlib/__init__.py"
if [ -f "$MPLINITFILE" ]; then
MPLVERSION=`sed -n "/^__version__[ ]*=/s/[^']*'\([^']*\)'.*$/\1/p" "$MPLINITFILE"`
if [ "$MPLVERSION" != "" ]; then
MPLCONFIGDIR="$DOT_SAGE/matplotlib-$MPLVERSION"
else
# MPLVERSION is empty, so no version found.
MPLCONFIGDIR="$DOT_SAGE/matplotlib"
fi
export MPLCONFIGDIR
# The directory is created when Sage starts (see sage.misc.misc).
fi
# Add some directories to $LD_LIBRARY_PATH:
# * lib/openmpi is needed for openmpi.
# * lib/R/lib is needed for R in case the Sage install is moved.
# * lib32 and lib64 are needed for GCC, see #12405.
for d in lib/openmpi lib/R/lib lib32 lib64 lib; do
libdir="$SAGE_LOCAL/$d"
# Add only existing directories
if [ -d "$libdir" ]; then
[ -z "$LD_LIBRARY_PATH" ] || LD_LIBRARY_PATH=":${LD_LIBRARY_PATH}"
LD_LIBRARY_PATH="${libdir}$LD_LIBRARY_PATH"
fi
done
export LD_LIBRARY_PATH
# The following is needed for OS X (especially for the
# Singular install).
if [ `uname` = "Darwin" ]; then
if [ -z "${SAGE_ORIG_DYLD_LIBRARY_PATH_SET}" ]; then
SAGE_ORIG_DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH && export SAGE_ORIG_DYLD_LIBRARY_PATH
SAGE_ORIG_DYLD_LIBRARY_PATH_SET=True && export SAGE_ORIG_DYLD_LIBRARY_PATH_SET
fi
DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH:$SAGE_LOCAL/lib/R/lib" && export DYLD_LIBRARY_PATH
fi
# Unset these variables which interfere with R
unset R_HOME
unset R_PROFILE
MAXIMA_PREFIX="$SAGE_ROOT/local" && export MAXIMA_PREFIX
# PKG_CONFIG_PATH is used by 'pkg-config' on Solaris and Linux,
# but at least some versions of OS X do not have the pkg-config
# command, so relying on this is not wise on OS X.
if [ -z "$PKG_CONFIG_PATH" ]; then
PKG_CONFIG_PATH="$SAGE_LOCAL/lib/pkgconfig"
else
PKG_CONFIG_PATH="$SAGE_LOCAL/lib/pkgconfig:$PKG_CONFIG_PATH"
fi
export PKG_CONFIG_PATH
############ architecture flags
# Support flags to change the build architecture. Currently, this is
# only SAGE64.
# Whenever a flag like SAGE64 has been set once, it needs to be
# restored in every run of sage, as mixing 64-bit and 32-bit code is
# bad idea at best. This script takes care of that.
. "$SAGE_SCRIPTS_DIR/sage-arch-env"
############ compilation flags
# On Cygwin the result of `uname` depends on the version of Windows
# it is running on, e.g. CYGWIN_NT-5.1 on 32 bits Windows XP or
# CYGWIN_NT-6.1-WOW64 on 64 bits Windows 7.
# Currently, this information is of no use to us so we discard it.
export UNAME=`uname | sed 's/CYGWIN.*/CYGWIN/' `
# Setting Sage-related compilation flags.
# This could be used in code to make special changes only when
# code is being built as part of Sage.
export __sage__=""
# Set the C and C++ compilers
if [ -z "$CC" ]; then
# On OS X 10.7 (Lion) or later when building GCC, use clang as
# default C compiler as some older versions of XCode 4 ship broken
# versions of GCC which fail to bootstrap GCC-4.6.3.
# See http://trac.sagemath.org/sage_trac/ticket/12820
if [ "$SAGE_BUILD_TOOLCHAIN" = yes ] && [ "$UNAME" = Darwin ] && [ `uname -r | cut -d. -f1` -ge 11 ]; then
CC=`which clang 2>/dev/null`
fi
fi
if [ -z "$CC" ]; then
CC=gcc
fi
if [ -z "$CXX" ]; then
CXX=g++
fi
if [ -z "$FC" ]; then
if [ -n "$SAGE_FORTRAN" ]; then
# Deprecated, see #13349.
FC="$SAGE_FORTRAN"
elif command -v gfortran >/dev/null 2>/dev/null; then
FC=gfortran
elif command -v g95 >/dev/null 2>/dev/null; then
FC=g95
elif command -v g77 >/dev/null 2>/dev/null; then
FC=g77
fi
fi
# An Objective-C compiler is needed for R on Darwin.
# On Darwin, /usr/bin/cc supports Objective-C. The gcc shipped with
# Sage doesn't.
if [ "$UNAME" = "Darwin" ]; then
if [ -z "$OBJC" -a -x "/usr/bin/cc" ]; then
export OBJC=/usr/bin/cc
fi
if [ -z "$OBJCXX" -a -x "/usr/bin/c++" ]; then
export OBJCXX=/usr/bin/c++
fi
fi
# Override CC, CPP, CXX, FC if the GCC spkg was installed.
if [ -x "$SAGE_LOCAL/bin/gcc" ]; then
CC=gcc
fi
if [ -x "$SAGE_LOCAL/bin/cpp" ]; then
CPP=cpp
fi
if [ -x "$SAGE_LOCAL/bin/g++" ]; then
CXX=g++
fi
if [ -x "$SAGE_LOCAL/bin/gfortran" ]; then
FC=gfortran
fi
export CC CPP CXX FC
# Set other Fortran-related compiler variables
export F77="$FC"
export F90="$FC" # Needed for SciPy
export F95="$FC"
# Setup env varariables if ccache is installed
if [ -d "$SAGE_LOCAL/libexec/ccache" ]; then
PATH="$SAGE_LOCAL/libexec/ccache:$PATH"
fi
if [ -z "$CCACHE_BASEDIR" ]; then
export CCACHE_BASEDIR="$SAGE_ROOT"
fi
# Set AS to assembler used by $CC ("as" by default)
if [ "$AS" = "" ]; then
CC_as=`$CC -print-file-name=as 2>/dev/null`
if command -v $CC_as >/dev/null 2>/dev/null; then
AS="$CC_as"
fi
if [ "$AS" = "" ]; then
AS=as
fi
fi
export AS
# Set LD to linker used by $CC ("ld" by default)
if [ "$LD" = "" ]; then
CC_ld=`$CC -print-file-name=ld 2>/dev/null`
if command -v $CC_ld >/dev/null 2>/dev/null; then
LD="$CC_ld"
fi
if [ "$LD" = "" ]; then
LD=ld
fi
fi
export LD
if [ "$AR" = "" ]; then
AR="ar" && export AR
fi
if [ "$LDFLAGS" = "" ]; then
LDFLAGS="" && export LDFLAGS
fi
if [ "$CXXFLAGS" = "" ]; then
export CXXFLAGS="$CFLAGS"
fi
if [ "$CP" = "" ]; then
CP="cp" && export CP
fi
if [ "$MV" = "" ]; then
MV="mv" && export MV
fi
if [ "$RANLIB" = "" ]; then
RANLIB="ranlib" && export RANLIB
fi
if [ "$LN" = "" ]; then
LN="ln" && export LN
fi
if [ "$MKDIR" = "" ]; then
MKDIR="mkdir" && export MKDIR
fi
if [ "$CHMOD" = "" ]; then
CHMOD="chmod" && export CHMOD
fi
if [ "$TOUCH" = "" ]; then
TOUCH="touch" && export TOUCH
fi
if [ "$UNAME" = "CYGWIN" ]; then
# Cygwin needs pathnames in PATH to resolve runtime dependencies
PATH="$SAGE_LOCAL/lib/R/lib:$SAGE_LOCAL/lib:$PATH" && export PATH
# And "dlopen" needs them in LD_LIBRARY_PATH, just as on Linuces,
# except that on Cygwin shared libraries are usually stored in "bin"
# and not in "lib"
LD_LIBRARY_PATH="$SAGE_LOCAL/bin:$LD_LIBRARY_PATH" && export LD_LIBRARY_PATH
fi
# See trac 7186 -- this is needed if ecl is moved
ECLDIR="$SAGE_LOCAL/lib/ecl/" && export ECLDIR
# Handle parallel building/testing/...
# See Trac Ticket #12016
# First, figure out the right values for SAGE_NUM_THREADS (default
# number of threads) and SAGE_NUM_THREADS_PARALLEL (default number of
# threads when parallel execution is asked explicitly).
sage_num_threads_array=(`sage-num-threads.py 2>/dev/null || echo 1 2 1`)
SAGE_NUM_THREADS=${sage_num_threads_array[0]}
SAGE_NUM_THREADS_PARALLEL=${sage_num_threads_array[1]}
export SAGE_NUM_THREADS
export SAGE_NUM_THREADS_PARALLEL
if [ "$MAKE" = "" ]; then
MAKE="make"
fi
# If MAKEFLAGS exists, assume it got set by make.
# Therefore, remove all flags from $MAKE
if [ "${MAKEFLAGS-__unset__}" != "__unset__" ]; then
MAKE=`echo "$MAKE" | sed 's/ .*//'`
fi
export MAKE
# When building documentation, use MathJax by default. To turn it off,
# set SAGE_DOC_MATHJAX to be "no" or "False".
if [ -z "$SAGE_DOC_MATHJAX" ]; then
# For backwards compatibility, we use the value of SAGE_DOC_JSMATH
# if it is set.
if [ -n "$SAGE_DOC_JSMATH" ]; then
SAGE_DOC_MATHJAX="$SAGE_DOC_JSMATH"
else
SAGE_DOC_MATHJAX="True"
fi
export SAGE_DOC_MATHJAX
fi
# You can set environment variables in $SAGE_RC_FILE
# (by default, this is the file $DOT_SAGE/sagerc). For example,
# setting PS1 there will set your prompt when you run "sage --sh".
if [ -z "$SAGE_RC_FILE" ]; then
SAGE_RC_FILE="$DOT_SAGE/sagerc"
fi
if [ -r "$SAGE_RC_FILE" ]; then
source "$SAGE_RC_FILE"
if [ $? -ne 0 ]; then
echo >&2 "Error sourcing $SAGE_RC_FILE"
exit 1
fi
fi
# If we move the Sage tree then ncurses cannot find terminfo, hence, we
# tell it where to find it. See Trac Ticket #15091
export TERMINFO="$SAGE_LOCAL/share/terminfo"
if [ -x "$SAGE_LOCAL/bin/ipython" ]; then
export IPYTHONDIR="$DOT_SAGE/ipython-"`ipython --version`
else
# IPython is not yet installed
export IPYTHONDIR="$DOT_SAGE/ipython-"`sed 's+\.p[0-9]*$++' "$SAGE_ROOT"/build/pkgs/ipython/package-version.txt`
fi
# this is to be compatible with optional packages that haven't
# been updated to not use SAGE_DATA
export SAGE_DATA="$SAGE_SHARE"