#!/usr/bin/env bash # Test for SAGE_LOCAL in the best possible way. if [ "x$SAGE_LOCAL" = "x" ]; then echo "SAGE_LOCAL undefined ... exiting"; echo "Maybe run 'sage -sh'?" exit 1 fi # Force an exit on all errors. However, not it will be desirable to unset this # sometimes, as you might want to test for a particular error and exit with # a message. You can't do that with 'set -e'. So use 'set +e' to unset it set -e # Compile for 64-bit if SAGE64 is set to 'yes'. This is documented, so only 'yes' will do. if [ "x$SAGE64" = "xyes" ]; then CFLAGS="$CFLAGS -m64 " fi # If SAGE_DEBUG is set either unset (the default), set to '1', 'yes', or 'TRUE' # then build with debugging information. Otherwise, don't add debugging information. # Since both the Sun and GNU compilers accept -g to give debugging information # there is no need to do anything specific to one compiler or the other. if [ "x$SAGE_DEBUG" = "x" -o "x$SAGE_DEBUG" = "x1" ] ; then echo "Code will be built with debugging information present. Set 'SAGE_DEBUG' to '0' if you don't want that." CFLAGS="$CFLAGS -g " CXXFLAGS="$CXXFLAGS -g " elif [ "x$SAGE_DEBUG" = "xyes" -o "x$SAGE_DEBUG" = "xTRUE" ] ; then echo "Code will be built with debugging information present. Set 'SAGE_DEBUG' to '0' if you don't want that." CFLAGS="$CFLAGS -g " CXXFLAGS="$CXXFLAGS -g " fi # Display all warnings from the compilers. Do so in a way that works for # both The GNU Compiler Collection (gcc, g++, gfortran), as well as for # Sun's compilers. Since the compilers use different methods, the compiler # must be tested. # gcc/g++/gfortran uses -Wall to show this. # The best flags for the Sun compilers are not known, but my best guess # is below. if "$CC" -flags 2>&1 | grep -i sun ; then CFLAGS="$CFLAGS -xtransition -erroff=none " SUN_COMPILER=1 elif "$CC" --version | grep 'GCC' ; then CFLAGS="$CFLAGS -Wall " GNU_COMPILER=1 else echo "The spkg-install file can't work out what C compiler you are using" echo "No flags will be added to show extra warnings while compiling C" fi # Determine if the C++ compiler is the Sun or GNU compiler # Add appropiate flag(s) to show all warnings. if "$CXX" -flags 2>&1 | grep -i sun ; then CXXFLAGS="$CXXFLAGS -xtransition -erroff=none " SUN_COMPILER=1 elif "$CXX" --version | grep 'GCC' ; then CXXFLAGS="$CXXFLAGS -Wall " GNU_COMPILER=1 else echo "The spkg-install file can't work out what C++ compiler you are using" echo "No flags will be added to show extra warnings while compiling C++" fi # Determine if the Fortran compiler is the Sun or GNU compiler # Add appropiate flag(s) to show all warnings. # Until I know exactly how a user is supposed to specify that, I'll leave that. # In any case, fortran is not used in lcalc. # Checks that the user is not mixing the Sun and GNU compilers. This problem # has been seen on code built with the aid of SCons, but in general could # happen with any code if the user has specified a C compiler but not a C++ one. if [ "x$SUN_COMPILER" = "x1" -a "x$GNU_COMPILER" = "x1" ] ; then echo "You are mixing the Sun and GNU C/C++ compilers" echo "Such a combination will lead to problems. Check CC and CXX carefully." echo "Exiting ..." exit 1 fi cd src if [ `uname` = "SunOS" ]; then LCALC_LIBS="-lpari -lmpfr -lgmpxx -lgmp -liberty" else LCALC_LIBS="-lpari -lmpfr -lgmpxx -lgmp" fi export CC CXX CFLAGS CXXFLAGS LCALC_LIBS echo "Building Rubinstein's lcalc program using CC=$CC" echo " CCX=$CXX" echo " CFLAGS=$CFLAGS" echo " CXXFLAGS=$CXXFLAGS" echo " LCALC_LIBS=$LCALC_LIBS" # disable Cygwin build for now if [ `uname` = "CYGWIN" ]; then echo "Sorry, the lcalc build is currently broken" echo 1 fi cd src set +e success() { if [ $? -ne 0 ]; then echo "Error building lcalc '$1'" exit 1 fi } set -e export DEFINES="" cp ../../patches/Makefile.sage Makefile make lcalc success 'plain' echo "Now copying over the lcalc binary" cp lcalc "$SAGE_LOCAL/bin" success 'install'