#!/bin/bash # Copyright (c) 2022 John Abbott, Anna M. Bigatti (really needed?) # Configure script for CoCoALib # It accepts a small number of options: run "configure --help" for details. # Here is what this script does. # It establishes the location of the GMP library (and the gmp.h file). # It establishes which C++ compiler to use and the compilation flags; # both compiler and flags can be user specified (via env vars CXX & CXXFLAGS). # After some basic checks, all details are written into a configuration file # (currently called configuration/autoconf.mk) which is read by make. # The chosen configuration parameters will be placed in the file CONFIG_FILE: # we save any previous CONFIG_FILE by appending suffix ".old", # the new file is built up in CONFIG_TMP then renamed to CONFIG_FILE at the end. CONFIG_DIR=configuration CONFIG_FILE="$CONFIG_DIR/autoconf.mk" CONFIG_TMP="$CONFIG_FILE.part" CPPDEFNS_H=include/CoCoA/PREPROCESSOR_DEFNS.H ERR_MESGS=ERR_MESGS # file to contain error mesgs from aux scripts (preserves newlines) trap "/bin/rm -f \"$ERR_MESGS\"" EXIT # Auxiliary shell scripts are in this directory; load some useful shell fns. SCRIPT_DIR=configuration source "$SCRIPT_DIR/shell-fns.sh" EXTLIB_DIR=configuration/ExternalLibs # Full path needed by some configuration scripts [is this a bug?] EXTLIB_DIR_FULL=`pwd`/$EXTLIB_DIR export EXTLIB_DIR_FULL EXTLIB_5_DIR=configuration/ExternalLibs-CoCoA5 # Full path needed by some configuration scripts [is this a bug?] EXTLIB_5_DIR_FULL=`pwd`/$EXTLIB_5_DIR export EXTLIB_5_DIR_FULL # If no installation directories specified, set the deafults. COCOALIB_INSTALL_DIR="${COCOALIB_INSTALL_DIR:-/usr/local}" COCOA5_INSTALL_DIR="${COCOA5_INSTALL_DIR:-/usr/local/bin}" # Try to determine which command to for installing: if [[ "$OSTYPE" != "linux-gnu" ]]; then INSTALL_FLAG="-S" fi INSTALL_CMD="install $INSTALL_FLAG" # install -S is better on BSD (or MacOSX) but not portable command -v install > /dev/null 2>&1 if [ $? -ne 0 ] then INSTALL_CMD="/bin/cp -f" # should this be "/bin/cp -pf" ??? fi ################################################################## # Special handling for the arg "--again" (recalls args from previous invocation) # This section puts the script args into ARGS. if [ $# = 1 -a "XXX$1" = "XXX-again" ] then echo "$0: ERROR: Did you mean ./configure --again" > /dev/stderr exit 1 fi if [ $# = 1 -a "XXX$1" = "XXX--again" ] then if [ \! -f "$CONFIG_FILE" ] then echo "$0: ERROR: no previous configuration file found" > /dev/stderr if [ -f configuration/last-config-cmd ] then echo "$0: >>HINT<< Try looking in the file configuration/last-config-cmd" > /dev/stderr fi exit 1 fi ARGS=`head -5 "$CONFIG_FILE" | tail -1 | cut -c 3- | cut -f 2- -d " " ` echo echo "Recalling previous configure command:" echo "$0 $ARGS" echo sleep 4 eval "$0 $ARGS" exit $? fi ################################################################## # Process command line args. ORIG_CMD="$0" # Put all args inside double quotes: ORIG_ARGS= for arg in "$@" do ORIG_ARGS="$ORIG_ARGS \"$arg\"" done # First 3 are "english booleans" (value is "yes" or "no") COCOA_DEBUG="no" BUILD_QT_GUI="yes" ONLY_COCOALIB="no" BOOST_INC_DIR= # set by --with-boost-hdr-dir option # Below, is there a neater way to do tilde expansion for paths to libraries??? for option in "$@" do case $option in ( --again ) echo "$0: ERROR: option '--again' must be used alone" > /dev/stderr exit 1 ;; ( --recall ) if [ \! -f "$CONFIG_FILE" ] then echo "$0: ERROR: no previous configuration file found" > /dev/stderr echo "$0: ERROR: Try looking in the file configuration/last-config-cmd" > /dev/stderr exit 1 fi head -5 "$CONFIG_FILE" | tail -1 | cut -c 3- exit 0 ;; ( --recall-from=* ) head -5 "`echo "$option" | cut -f 2- -d=`" | tail -1 | cut -c 3- exit 0 ;; ( --with-libgmp=~* ) GMP_LIB="$HOME`echo "$option" | cut -f 2- -d~`" ;; ( --with-libgmp=* ) GMP_LIB=`echo "$option" | cut -f 2- -d=` ;; ( --no-qt-gui ) BUILD_QT_GUI=no NO_GUI_REASON="(configure option: --no-qt-gui)" ;; (--only-cocoalib ) ONLY_COCOALIB=yes BUILD_QT_GUI=no NO_GUI_REASON="(configure option: --only-cocoalib)" # will not actually be used AVOID_READLINE=yes ;; ( --with-boost-hdr-dir=~* ) BOOST_INC_DIR="$HOME`echo "$option" | cut -f 2- -d~`" ;; ( --with-boost-hdr-dir=* ) BOOST_INC_DIR=`echo "$option" | cut -f 2- -d=` ;; ( --with-boost=~* ) echo echo "=====================================================================" echo "WARNING: option --with-boost is OBSOLESCENT: use --with-boost-hdr-dir" echo "=====================================================================" echo ""; sleep 3; BOOST_INC_DIR="$HOME`echo "$option" | cut -f 2- -d~`" ;; ( --with-boost=* ) echo echo "=====================================================================" echo "WARNING: option --with-boost is OBSOLESCENT: use --with-boost-hdr-dir" echo "=====================================================================" echo ""; sleep 3; BOOST_INC_DIR=`echo "$option" | cut -f 2- -d=` ;; (--no-readline ) AVOID_READLINE=yes ;; ( --with-libreadline=~* ) READLINE_LIB="$HOME`echo "$option" | cut -f 2- -d~`" ;; ( --with-libreadline=* ) READLINE_LIB=`echo "$option" | cut -f 2- -d=` ;; ( --with-libcddgmp=system ) # Not sure this works (JAA, 2022-04-10) CDD_LIB=`$SCRIPT_DIR/find-lib-in-std-dirs.sh libcddgmp 2> "$ERR_MESGS"` if [ $? -ne 0 ] then echo "$0: ERROR: Could not find libcddgmp" > /dev/stderr /bin/cat "$ERR_MESGS" > /dev/stderr exit 1 fi # echo "calling $SCRIPT_DIR/find-hdr-from-lib.sh cdd/cdd.h $CDD_LIB" # Script prints error on /dev/stderr if there is a problem CDD_HDR_DIR=`$SCRIPT_DIR/find-hdr-from-lib.sh cddlib/cdd.h "$CDD_LIB" 2> "$ERR_MESGS"` if [ $? -ne 0 ] then echo "$0: ERROR: could not find header file for CDD" > /dev/stderr /bin/cat "$ERR_MESGS" > /dev/stderr exit 1 fi CDD_SYSTEM=yes ;; ( --with-libcddgmp=~* ) CDD_LIB="$HOME`echo "$option" | cut -f 2- -d~`" ;; ( --with-libcddgmp=* ) CDD_LIB=`echo "$option" | cut -f 2- -d=` ;; ( --with-libfrobby=~* ) FROBBY_LIB="$HOME`echo "$option" | cut -f 2- -d~`" ;; ( --with-libfrobby=* ) FROBBY_LIB=`echo "$option" | cut -f 2- -d=` ;; ( --with-libntl ) NTL_LIB="/usr/local/lib/libntl.a" ;; #BUG: HARDWIRED! ( --with-libgsl=~* ) GSL_LIB="$HOME`echo "$option" | cut -f 2- -d~`" ;; ( --with-libgsl=* ) GSL_LIB=`echo "$option" | cut -f 2- -d=` ;; ( --with-libgfan=~* ) GFAN_LIB="$HOME`echo "$option" | cut -f 2- -d~`" ;; ( --with-libgfan=* ) GFAN_LIB=`echo "$option" | cut -f 2- -d=` ;; ( --with-libmathsat=~* ) MATHSAT_LIB="$HOME`echo "$option" | cut -f 2- -d~`" ;; ( --with-libmathsat* ) MATHSAT_LIB=`echo "$option" | cut -f 2- -d=` ;; ( --with-libnormaliz=~* ) NORMALIZ_LIB="$HOME`echo "$option" | cut -f 2- -d~`" ;; ( --with-libnormaliz=* ) NORMALIZ_LIB=`echo "$option" | cut -f 2- -d=` ;; ( --with-cxx=* ) CXX=`echo "$option" | cut -f 2- -d=` ;; ( --with-cxxflags=* ) CXXFLAGS=`echo "$option" | cut -f 2- -d=` ;; ( --debug ) COCOA_DEBUG="yes" ;; ( --disable-mempool ) DISABLE_MEMPOOL=yes ;; ( --threadsafe-hack ) DISABLE_MEMPOOL=yes THREADSAFE_HACK=yes ;; ( --prefix=* ) COCOALIB_INSTALL_DIR=`echo "$option" | cut -f 2- -d=` if [ \! -d "$COCOALIB_INSTALL_DIR" ] then echo "$0: ERROR: specified installation directory does not exist: \`$COCOALIB_INSTALL_DIR\'" > /dev/stderr exit 1 fi ;; ( --help* ) echo -e "\nThis script configures CoCoALib. For details please consult the" echo -e "files INSTALL and README located in the same directory as this script." echo -e "\nUsage: ./configure [OPTIONS]" echo -e "\nConfiguration:" echo -e " --help\t\tdisplay this help and exit" echo -e " --again\t\tre-run configure with the same options as last time" echo -e " --recall\t\tprint out the configure command given last time" echo -e " --only-cocoalib\tcompile only CoCoALib (and not CoCoA-5 as well)" echo -e " --with-cxx=ARG\tspecify name of compiler [default: g++]" echo -e "\t\t\t(or specify via environment variable CXX)" echo -e " --with-cxxflags=ARG\tspecify some compilation flags (more flags will be appended by \"configure\")" echo -e "\t\t\t(or specify them via environment variable CXXFLAGS)" echo -e " --with-libgmp=ARG\tspecify location of the file libgmp.a (or libgmp.so)" echo -e "\t\t\t[default assumes a standard system installation]" echo -e " --disable-mempool\tuse system allocator instead of CoCoA MemPools" echo -e " --threadsafe-hack\tcompile using a hack for threadsafety" echo -e " --debug\t\tcompile with debugging checks" echo -e "\nInstallation:" echo -e " --prefix=PREFIX\tset install location to PREFIX/include & PREFIX/lib" echo -e "\t\t\t[default: /usr/local]" echo -e "\nOptional_libraries:" echo -e " --with-libcddgmp=ARG\tspecify location of the file libcddgmp.a" echo -e "\t\t\t[default is no libcddgmp.a]" echo -e " --with-libfrobby=ARG\tspecify location of the file libfrobby.a" echo -e "\t\t\t[default is no libfrobby]" echo -e " --with-libgfan=ARG\tspecify location of the file libgfan.a" echo -e "\t\t\t[default is no libgfan]" echo -e " --with-libgsl=ARG\tspecify location of the file libgsl.a" echo -e "\t\t\t[default is no libgsl]" echo -e " --with-libmathsat=ARG\tspecify location of the file libmathsat.a" echo -e "\t\t\t[default is no libmathsat]" echo -e " --with-libnormaliz=ARG\tspecify location of the file libnormaliz.a" echo -e "\t\t\t[default is no libnormaliz]" echo -e "\nCoCoA-5: (options relevant only when compiling CoCoA-5)" echo -e " --with-boost-hdr-dir=ARG\tspecify location of the BOOST header files (without the trailing /boost)" echo -e "\t\t\t[default assumes a standard system installation]" echo -e " --no-readline\t\tdo not look for libreadline.a" echo -e " --with-libreadline=ARG\tspecify location of the file libreadline.a" echo -e "\t\t\t[default assumes a standard system installation]" echo -e " --no-qt-gui\t\tdisable building the Qt GUI for CoCoA-5 (saves some compilation time)" echo -e "\t\t\t[default is to determine automatically]" exit ;; ( * ) echobox "$0: ERROR: unrecognized option/parameter \"$option\"" > /dev/stderr echo > /dev/stderr echo "$0: HINT: try \"$0 --help\" for guidance" > /dev/stderr exit 1 ;; esac done if [ "$AVOID_READLINE" = "yes" -a -n "$READLINE_LIB" ] then echo "$0: ERROR: incompatible inputs for readline" > /dev/stderr exit 1 fi if [ "$ONLY_COCOALIB" = "yes" -a -n "$BOOST_INC_DIR" ] then echo "$0: ERROR: cannot specify BOOST when compiling only CoCoALib" > /dev/stderr exit 1 fi if [ "$ONLY_COCOALIB" = "yes" -a -n "$READLINE_LIB" ] then echo "$0: ERROR: cannot specify readline when compiling only CoCoALib" > /dev/stderr exit 1 fi if [ -n "$BOOST_INC_DIR" ] then # Check if BOOST path is vaguely sane [ -d "$BOOST_INC_DIR" ] && [ -r "$BOOST_INC_DIR" ] && [ -x "$BOOST_INC_DIR" ] if [ $? -ne 0 ] then echo "$0: specified BOOST path is not an accessible directory" > /dev/stderr exit 1 fi [ -d "$BOOST_INC_DIR/boost" ] && [ -r "$BOOST_INC_DIR/boost" ] && [ -x "$BOOST_INC_DIR/boost" ] if [ $? -ne 0 ] then echo "$0: specified BOOST path does not have accessible subdir \"boost\":" > /dev/stderr echo "$0: specified path: $BOOST_INC_DIR" > /dev/stderr exit 1 fi fi ############################################################################# # Set env variable PKGCONF: pkgconf (NEW) or pkg-config (OLD) # Used by scripts in directory configuration/ to find installed libraries. export PKGCONF="pkg-config" if command -v pkgconf >/dev/null 2>&1 then PKGCONF="pkgconf" fi ############################################################################# # Find directory of this script (taken from link below) # http://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself pushd . > /dev/null SCRIPT_PATH="${BASH_SOURCE[0]}" while [ -L "$SCRIPT_PATH" ] do cd "`dirname "$SCRIPT_PATH"`" SCRIPT_PATH="$(readlink "`basename "$SCRIPT_PATH"`")" done cd "`dirname "$SCRIPT_PATH"`" > /dev/null CONFIG_SCRIPT_DIR="`pwd`" popd > /dev/null ################################################################## # Check whether the source tree contains GUI code: if [ "$BUILD_QT_GUI" = "yes" ] && [ \! -d "src/CoCoA-5/QCodeEdit" ] then BUILD_QT_GUI="no" NO_GUI_REASON="source tree without Qt-gui code" fi if [ "$BUILD_QT_GUI" = "yes" ] then echo "---------------------------------------------------------------" echo "Starting configuration process for CoCoALib, CoCoA-5 and Qt-GUI" echo "---------------------------------------------------------------" elif [ "$ONLY_COCOALIB" = "no" ] then echo "---------------------------------------------------------------------" echo "Starting configuration process for CoCoALib, CoCoA-5 (without Qt-GUI)" echo "---------------------------------------------------------------------" else echo "------------------------------------------------------------------------" echo "Starting configuration process for CoCoALib only; no CoCoA-5 (or Qt-GUI)" echo "------------------------------------------------------------------------" fi echo ################################################################## # Rename the old configuration file (if it exists). # Do this early so that after a failed configure it is not # not possible to compile if [ -f "$CONFIG_FILE" ] then /bin/rm -rf "$CONFIG_FILE.old" /bin/mv "$CONFIG_FILE" "$CONFIG_FILE.old" echo echo "**NOTE** moved previous config file into $CONFIG_FILE.old" echo echo fi if [ -f "$CPPDEFNS_H" -a -s "$CPPDEFNS_H" ] then /bin/mv "$CPPDEFNS_H" "$CPPDEFNS_H-old" fi touch "$CPPDEFNS_H" # needed by cpp-flags-ulong2long.sh ################################################################## # Check the compiler. # If user didn't specify a compiler, we assume g++. if [ -z "$CXX" ] then CXX=g++ fi # Next two lines required by the scripts which check GMP (see below). export CXX export CXXFLAGS # Check compiler and flags are sane. # If all is well, result is either "gnu" or "not gnu" & return code is 0. # If there's a problem, script prints error message on /dev/stderr & return code is non-zero. CXX_TYPE=`$SCRIPT_DIR/verify-compiler.sh 2> "$ERR_MESGS"` if [ $? -ne 0 ] then /bin/cat "$ERR_MESGS" > /dev/stderr echo "$0: ERROR: Check the options --with-cxx=... and --with-cxxflags=..." > /dev/stderr echo "$0: ERROR: (or the environment variables CXX and CXXFLAGS)." > /dev/stderr exit 1 fi #------------------------------------------------------- # Decide which flags to use for C++14 standard... CXX14_FLAG=`$SCRIPT_DIR/cxx14.sh 2>&1` if [ $? -ne 0 ] then echo "ERROR: unable to find flag for C++14 compilation" > /dev/stderr echo "$CXX14_FLAG" > /dev/stderr exit 1 fi if [ "$CXX_TYPE" != "other" -a -z "$CXXFLAGS" ] then FPIC=`$SCRIPT_DIR/fpic-flag.sh` LDFPIC=`$SCRIPT_DIR/fpic-ldflag.sh` fi CXXFLAGS="$CXXFLAGS $CXX14_FLAG -Wall -pedantic $FPIC" #----------------------------------------------------------------- # Decide which "optimization" flags to use: # if the compiler is type "gnu" or "clang" then we use -O2 # otherwise we just use -O CXXFLAGS_OPT="-O" if [ "$CXX_TYPE" \!= "other" ] # clang or gnu then CXXFLAGS_OPT=-O2 fi if [ "$COCOA_DEBUG" = "yes" ] then CXXFLAGS_OPT="-g" if [ "$CXX_TYPE" = "gnu" ] then # I did try with -Og flag, but using gdb was then too "weird" CXXFLAGS_OPT="-g -Wextra" fi if [ "$CXX_TYPE" = "clang" ] then CXXFLAGS_OPT="-g -Wextra" fi fi CXXFLAGS="$CXXFLAGS $CXXFLAGS_OPT" #-------------------------------------------- # 2025-05-23 (g++) disable -Wdangling-reference because it reports too many false positives if [ "$CXX_TYPE" = "gnu" ] then CXXFLAGS="$CXXFLAGS -Wno-dangling-reference" fi #-------------------------------------------- # Workaround "bug" in clang on MacOS ("Darwin") ISYSTEM=isystem if [ `uname -s` = "Darwin" ] then ISYSTEM=I fi ################################################################## # -- EXTERNAL LIBRARIES -- ############################ ################################################################## # Prepare subtree for symlinks to external libs # Recall: $EXTLIB_DIR is relative path /bin/rm -rf "$EXTLIB_DIR" mkdir "$EXTLIB_DIR" mkdir "$EXTLIB_DIR/lib" mkdir "$EXTLIB_DIR/include" # Prepare subtree for symlinks to external libs for CoCoA-5 only ###EXTLIB_DIR_COCOA5=configuration/ExternalLibs-CoCoA5 /bin/rm -rf "$EXTLIB_5_DIR" mkdir "$EXTLIB_5_DIR" mkdir "$EXTLIB_5_DIR/lib" mkdir "$EXTLIB_5_DIR/include" ################################################################## # Required external library: GMP ################################################################## # Now obtain and check the GMP installation. # Establish the location of the GMP library. # Check whether user supplied the location of the GMP library; if not, we search for it. if [ -n "$GMP_LIB" ] then # User supplied a path to the GMP library. # Check it is at least a readable file. # Convert the file name into an absolute path (in case it was not). if [ \! -f "$GMP_LIB" -o \! -r "$GMP_LIB" ] then echo "$0: ERROR: Specified GMP library is not a readable file \"$GMP_LIB\"" > /dev/stderr case $(basename "$GMP_LIB") in libgmp.*) echo "$0: ERROR: Check the --with-libgmp option" > /dev/stderr ;; *) echo "$0: ERROR: Usually the GMP path ends with .../libgmp.a or .../libgmp.so" > /dev/stderr ;; esac echo > /dev/stderr exit 1 fi # These two lines should make sure GMP_LIB is an absolute path. GMP_DIR=$(dirname "$GMP_LIB") GMP_LIB=$(cd "$GMP_DIR"; pwd)/$(basename "$GMP_LIB") GMP_LIB_EXTN=$($SCRIPT_DIR/extn.sh "$GMP_LIB") /bin/ln -s "$GMP_LIB" "$EXTLIB_DIR/lib/libgmp-symlink.$GMP_LIB_EXTN" else # User did not supply path to GMP library, so we look for a system installation GMP_LIB=$($SCRIPT_DIR/gmp-find-lib.sh 2> "$ERR_MESGS") GMP_FIND_EXIT_CODE=$? if [ $GMP_FIND_EXIT_CODE = 2 ] then # Something went wrong; so GMP_MESG contains an error message. echo > /dev/stderr echo "$0: ERROR: Problem with GMP -- abandoning configuration of CoCoALib." > /dev/stderr echo "$0: ERROR: You can provide the path to libgmp.a (or libgmp.so) using" > /dev/stderr echo "$0: ERROR: the \"--with-libgmp=\" command line option to $0." > /dev/stderr /bin/cat "$ERR_MESGS" > /dev/stderr exit 1 fi if [ $GMP_FIND_EXIT_CODE = 1 ] then echo "INFO: More than one GMP installation found:" /bin/cat "$ERR_MESGS" echo "INFO:" echo "INFO: Proceeding with choice: $GMP_LIB" echo sleep 3 fi # gmp-find-lib.sh script worked, so message is full path of GMP library GMP_LIB_SUFFIX="SUFFIX_NOT_RECOGNISED" case "$GMP_LIB" in ( *.dll.a ) GMP_LIB_SUFFIX=dll.a ;; ( *.a ) GMP_LIB_SUFFIX=a ;; ( *.so ) GMP_LIB_SUFFIX=so ;; ( *.dylib ) GMP_LIB_SUFFIX=dylib ;; esac # GMP_LIB_SUFFIX should never be empty /bin/ln -s "$GMP_LIB" "$EXTLIB_DIR/lib/libgmp-symlink.$GMP_LIB_SUFFIX" fi GMP_INC_DIR=$($SCRIPT_DIR/gmp-find-hdr.sh "$GMP_LIB" 2> "$ERR_MESGS") if [ $? -ne 0 ] then # Something went wrong; details are in GMP_INC_DIR echo "$0: ERROR: Unable to locate header for GMP library $GMP_LIB" > /dev/stderr /bin/cat "$ERR_MESGS" > /dev/stderr exit 1 fi GMP_H="$GMP_INC_DIR/gmp.h" /bin/ln -s "$GMP_H" "$EXTLIB_DIR/include/gmp.h" # Now check that GMP is new enough GMP_VERSION=$($SCRIPT_DIR/gmp-version.sh 2> "$ERR_MESGS") if [ $? -ne 0 ] then /bin/cat "$ERR_MESGS" > /dev/stderr exit 1 fi if [ "$GMP_VERSION" \< "5.1.0" ] then echo "$0: ERROR: Your GMP installation is too old -- must be at least 5.1.0!" > /dev/stderr echo "$0: ERROR: Please update to a newer version, then reconfigure CoCoALib." > /dev/stderr exit 1 fi # Tell user which version of GMP we are using. echo "Using GMP version $GMP_VERSION:" echo " header is $GMP_H" echo " library is $GMP_LIB" echo # If user supplied CXXFLAGS, check they are compatible with GMP if [ -n "$CXXFLAGS" ] then $SCRIPT_DIR/gmp-check-cxxflags.sh 2> "$ERR_MESGS" if [ $? -ne 0 ] then echo "$0: ERROR: Supplied value of CXXFLAGS, namely \"$CXXFLAGS\"" > /dev/stderr echo "$0: ERROR: is not compatible with GMP library" > /dev/stderr /bin/cat "$ERR_MESGS" > /dev/stderr exit 1 fi fi # --------------------------------- # Look for GMPXX -- needed by Frobby, but not by CoCoALib, so # not an error if we do not find GMPXX # Make "intelligent guess" for the full path of libgmpxx. # For the moment we do NOT CHECK if our guess was good # (we will check later if we are using Frobby). case "$GMP_LIB" in *.dll.a) GMP_LIB_EXTN=dll.a ;; *.a) GMP_LIB_EXTN=a ;; *.so) GMP_LIB_EXTN=so ;; *.dylib) GMP_LIB_EXTN=dylib ;; *) echo "$0: ERROR: unexpected extn in $GMP_LIB" > /dev/stderr; exit 2 ;; esac GMPXX_LIB=$(dirname "$GMP_LIB")/libgmpxx.$GMP_LIB_EXTN GMPXX_H="$GMP_INC_DIR/gmpxx.h" if [ -f "$GMPXX_LIB" ] && [ -r "$GMPXX_LIB" ] && [ -f "$GMPXX_H" ] && [ -r "$GMPXX_H" ] then HAVE_GMPXX=yes else HAVE_GMPXX=no fi if [ $HAVE_GMPXX = "yes" ] then /bin/ln -s "$GMPXX_H" "$EXTLIB_DIR/include/gmpxx.h" /bin/ln -s "$GMPXX_LIB" "$EXTLIB_DIR/lib/libgmpxx-symlink.$GMP_LIB_EXTN" # Tell user which version of GMP we are using. echo "Also have GMPXX:" echo " header is $GMPXX_H" echo " library is $GMPXX_LIB" echo fi echo ################################################################## # CYGWIN # Hack for cygwin (so it can use sigaction) CYGWIN=`uname -s | grep -F CYGWIN` if [ -n "$CYGWIN" ] then CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE" fi ################################################################## ################################################################## # external library: READLINE ################################################################## # Check whether libreadline is available; if so, we will use it # for compiling CoCoAInterpreter HAVE_READLINE=no if [ -z "$AVOID_READLINE" ] then if [ -z "$READLINE_LIB" ] then # No libreadline specified, so look for an installed version $SCRIPT_DIR/readline-try-default.sh > /dev/null 2>& 1 if [ $? = 0 ] then HAVE_READLINE=yes # Note that -lreadline includes also -lncurses or -ltermcap READLINE_LIB="-lreadline" else WARNINGS="libreadline not installed; $WARNINGS" echo "WARNING: readline is not installed" fi else # user specified a libreadline # Check the file passed is at least a readable file: if [ \! -f "$READLINE_LIB" -o \! -r "$READLINE_LIB" ] then echo "$0: ERROR: cannot read supplied libreadline: $READLINE_LIB" > /dev/stderr exit 1 fi # These lines should put absolute paths in LIB_DIR: READLINE_LIB_NAME=`basename "$READLINE_LIB"` READLINE_LIB_EXTN=`$SCRIPT_DIR/extn.sh "$READLINE_LIB"` READLINE_LIB_DIR=`dirname "$READLINE_LIB"` READLINE_LIB_DIR=`cd "$READLINE_LIB_DIR"; pwd` # Absolute paths for LIB: READLINE_LIB="$READLINE_LIB_DIR"/"$READLINE_LIB_NAME" READLINE_HDR=`$SCRIPT_DIR/readline-find-hdr.sh "$READLINE_LIB" 2> "$ERR_MESGS"` if [ $? -ne 0 ] then echo "$0: ERROR: cannot find header file for the specified libreadline." > /dev/stderr /bin/cat "$ERR_MESGS" > /dev/stderr exit 1 fi LIBTERMCAP=`$SCRIPT_DIR/readline-check-cxxflags.sh "$READLINE_HDR" "$READLINE_LIB"` if [ $? = 0 ] then HAVE_READLINE=yes READLINE_LIB="$READLINE_LIB $LIBTERMCAP" fi READLINE_INC_DIR="$(dirname "$(dirname "$READLINE_HDR")")" fi fi if [ $HAVE_READLINE = yes ] then READLINE_FLAG="-DCoCoA_WITH_READLINE" fi COCOA5_CXX_DEFINES="$READLINE_FLAG" ################################################################## # external library: CDD (GMP) ################################################################## if [ -n "$CDD_LIB" ] then # Check the file passed as CDD library is at least a readable file. if [ \! -f "$CDD_LIB" -o \! -r "$CDD_LIB" ] then echo "$0: ERROR: Specified CDD library is not a readable file \"$CDD_LIB\"" > /dev/stderr exit 1 fi # Check that the name is sane (need special handling for Microsoft) BAD_BASENAME=no; [ "`basename \"$CDD_LIB\" .a`" = "libcddgmp" ] || [ "`basename \"$CDD_LIB\" .dll.a`" = "libcddgmp" ] || BAD_BASENAME=yes if [ "$BAD_BASENAME" = "yes" ] then echo "$0: ERROR: Specified CDD library should have basename 'libcddgmp'" > /dev/stderr exit 1 fi HAVE_CDD=yes # These lines should put absolute paths in LIB_DIR: CDD_LIB_NAME=$(basename "$CDD_LIB") CDD_LIB_EXTN=$($SCRIPT_DIR/extn.sh "$CDD_LIB_NAME") CDD_LIB_DIR=$(dirname "$CDD_LIB") CDD_LIB_DIR=$(cd "$CDD_LIB_DIR"; pwd) # Absolute paths for LIB and INC_DIR: CDD_LIB="$CDD_LIB_DIR/$CDD_LIB_NAME" CDD_INC_DIR="$(dirname "$CDD_LIB_DIR")/include" if [ -d "$CDD_INC_DIR/cddlib" ] then CDD_INC_DIR="$CDD_INC_DIR/cddlib" fi if [ \! -d "$CDD_INC_DIR" -o \! -f "$CDD_INC_DIR/cdd.h" ] then echo "$0: ERROR: Did not find CDD header files where expected, in dir: \"$CDD_INC_DIR\"" > /dev/stderr exit 1 fi # Make symbolic links in $EXTLIB_DIR/lib and $EXTLIB_DIR/include: /bin/ln -s "$CDD_LIB" "$EXTLIB_DIR/lib/libcddgmp-symlink.$CDD_LIB_EXTN" /bin/ln -s "$CDD_INC_DIR" "$EXTLIB_DIR/include/cdd" else HAVE_CDD=no fi ################################################################## # external library: FROBBY ################################################################## # Check the file passed as libfrobby.a is at least a readable file. # Convert the file name into an absolute path (in case it was not). if [ -n "$FROBBY_LIB" ] then if [ \! -f "$FROBBY_LIB" -o \! -r "$FROBBY_LIB" ] then echo "$0: ERROR: Specified FROBBY library is not a readable file \"$FROBBY_LIB\"" > /dev/stderr exit 1 fi if [ "$HAVE_GMPXX" = "no" ] then echo "$0: ERROR: Frobby needs libgmpxx but your GMP installation does not have it." > /dev/stderr echo "$0: ERROR: Please specify a GMP installation with libgmpxx, or rebuild GMP" > /dev/stderr echo "$0: ERROR: specifying that you want the C++ library too (see GMP doc for details)." > /dev/stderr exit 1 fi # These lines should put absolute paths in FROBBY_LIB and FROBBY_DIR. HAVE_FROBBY=yes FROBBY_LIB_DIR=$(dirname "$FROBBY_LIB") FROBBY_LIB_DIR=$(cd "$FROBBY_LIB_DIR"; pwd) FROBBY_LIB="$FROBBY_LIB_DIR"/$(basename "$FROBBY_LIB") FROBBY_LIB_EXTN=$($SCRIPT_DIR/extn.sh "$FROBBY_LIB") # Make symbolic links in $EXTLIB_DIR/lib and $EXTLIB_DIR/include /bin/ln -s "$FROBBY_LIB" "$EXTLIB_DIR/lib/libfrobby-symlink.$FROBBY_LIB_EXTN" /bin/ln -s $(dirname "$FROBBY_LIB_DIR")/src/frobby.h "$EXTLIB_DIR/include/" if [ $? -ne 0 ] then echo "$0: ERROR: frobby.h header file not found in `dirname \"$FROBBY_LIB_DIR\"`" > /dev/stderr exit 1 fi else HAVE_FROBBY=no fi ################################################################## # external library: GFAN ################################################################## # Check the file passed as GFAN library is at least a readable file. # Convert the file name into an absolute path (in case it was not). if [ -n "$GFAN_LIB" ] then if [ "$HAVE_CDD" = "no" ] then echo "$0: ERROR: GFAN library requires also \"libcddgmp\"" > /dev/stderr exit 1 fi if [ \! -f "$GFAN_LIB" -o \! -r "$GFAN_LIB" ] then echo "$0: ERROR: Specified GFAN library is not a readable file \"$GFAN_LIB\"" > /dev/stderr exit 1 fi HAVE_GFAN=yes # These three lines should make sure GFAN_LIB is an absolute path. GFAN_LIB_NAME=$(basename "$GFAN_LIB") GFAN_LIB_EXTN=$($SCRIPT_DIR/extn.sh "$GFAN_LIB_NAME") GFAN_LIB_DIR=$(dirname "$GFAN_LIB") GFAN_LIB_DIR=$(cd "$GFAN_LIB_DIR"; pwd) GFAN_LIB="$GFAN_LIB_DIR/$GFAN_LIB_NAME" GFAN_INC_DIR="$GFAN_LIB_DIR" if ! [ -d "$GFAN_INC_DIR" ] then echo "$0: ERROR: Did not find GFAN header file where expected, in dir: \"$GFAN_INC_DIR\"" > /dev/stderr exit 1 fi # Make symbolic links in $EXTLIB_DIR/lib and $EXTLIB_DIR/include /bin/ln -s "$GFAN_LIB" "$EXTLIB_DIR/lib/libgfan-symlink.$GFAN_LIB_EXTN" /bin/ln -s "$GFAN_INC_DIR" "$EXTLIB_DIR/include/gfanlib" else HAVE_GFAN=no fi ################################################################## # external library: GSL ################################################################## # Check the file passed as GSL library is at least a readable file. # Convert the file name into an absolute path (in case it was not). if [ -n "$GSL_LIB" ] then if [ \! -f "$GSL_LIB" -o \! -r "$GSL_LIB" ] then echo "$0: ERROR: Specified GSL library is not a readable file \"$GSL_LIB\"" > /dev/stderr exit 1 fi HAVE_GSL=yes # These three lines should make sure GSL_LIB is an absolute path. GSL_LIB_NAME=$(basename "$GSL_LIB") GSL_LIB_EXTN=$($SCRIPT_DIR/extn.sh "$GSL_LIB_NAME") GSL_LIB_DIR=$(dirname "$GSL_LIB") GSL_LIB_DIR=$(cd "$GSL_LIB_DIR"; pwd) GSL_LIB="$GSL_LIB_DIR/$GSL_LIB_NAME" if [ "`basename \"$GSL_LIB_DIR\"`" = ".libs" ] then GSL_INC_DIR="`dirname \"$GSL_LIB_DIR\"`/gsl" else GSL_INC_DIR="`dirname \"$GSL_LIB_DIR\"`/include/gsl" fi if [ \! -d "$GSL_INC_DIR" ] then echo "$0: ERROR: Did not find GSL header file where expected, in dir: \"$GSL_INC_DIR\"" > /dev/stderr exit 1 fi # Make symbolic links in $EXTLIB_DIR/lib and $EXTLIB_DIR/include /bin/ln -s "$GSL_LIB" "$EXTLIB_DIR/lib/libgsl-symlink.$GSL_LIB_EXTN" /bin/ln -s "$GSL_INC_DIR" "$EXTLIB_DIR/include" else HAVE_GSL=no fi ################################################################## # external library: MATHSAT ################################################################## if [ -n "$MATHSAT_LIB" ] then # Check the file passed as libmathsat is at least a readable file: if [ \! -f "$MATHSAT_LIB" -o \! -r "$MATHSAT_LIB" ] then echo "$0: ERROR: Specified MATHSAT library is not a readable file \"$MATHSAT_LIB\"" > /dev/stderr exit 1 fi if [ "$HAVE_GMPXX" = "no" ] then echo "$0: ERROR: MathSAT needs libgmpxx but your GMP installation does not have it." > /dev/stderr echo "$0: ERROR: Please specify a GMP installation with libgmpxx, or rebuild GMP" > /dev/stderr echo "$0: ERROR: specifying that you want the C++ library too (see GMP doc for details)." > /dev/stderr exit 1 fi HAVE_MATHSAT=yes # These lines should put absolute paths in LIB_DIR: MATHSAT_LIB_NAME=$(basename "$MATHSAT_LIB") MATHSAT_LIB_EXTN=$($SCRIPT_DIR/extn.sh "$MATHSAT_LIB") MATHSAT_LIB_DIR=$(dirname "$MATHSAT_LIB") MATHSAT_LIB_DIR=$(cd "$MATHSAT_LIB_DIR"; pwd) # Absolute paths for LIB and INC_DIR: MATHSAT_LIB="$MATHSAT_LIB_DIR"/"$MATHSAT_LIB_NAME" ### MATHSAT_INC_DIR="$MATHSAT_LIB_DIR/../src/mathsat/api/" MATHSAT_INC_DIR="$(dirname "$MATHSAT_LIB_DIR")/include" if ! [ -f "$MATHSAT_INC_DIR/mathsat.h" ] then echo "$0: ERROR: Did not find mathsat.h in dir \"$MATHSAT_INC_DIR\"" > /dev/stderr exit 1 fi # Make symbolic links in $EXTLIB_DIR/lib and $EXTLIB_DIR/include: /bin/ln -s "$MATHSAT_LIB" "$EXTLIB_DIR/lib/libmathsat-symlink.$MATHSAT_LIB_EXTN" /bin/ln -s "$MATHSAT_INC_DIR/mathsat.h" "$EXTLIB_DIR/include/" else HAVE_MATHSAT=no fi ################################################################## # external library: NORMALIZ ################################################################## if [ -z "$NORMALIZ_LIB" ] then HAVE_NORMALIZ=no else # Check the path passed as libnormaliz is at least a readable file: if [ \! -f "$NORMALIZ_LIB" -o \! -r "$NORMALIZ_LIB" ] then echo "$0: ERROR: Specified NORMALIZ library is not a readable file \"$NORMALIZ_LIB\"" > /dev/stderr exit 1 fi HAVE_NORMALIZ=yes # These lines should put absolute paths in LIB_DIR: NORMALIZ_LIB_NAME=$(basename "$NORMALIZ_LIB") NORMALIZ_LIB_EXTN=$($SCRIPT_DIR/extn.sh "$NORMALIZ_LIB_NAME") NORMALIZ_LIB_DIR=$(dirname "$NORMALIZ_LIB") NORMALIZ_LIB_DIR=$(cd "$NORMALIZ_LIB_DIR"; pwd) # Absolute paths for LIB and INC_DIR: NORMALIZ_LIB="$NORMALIZ_LIB_DIR"/"$NORMALIZ_LIB_NAME" NORMALIZ_INC_DIR="$(dirname "$NORMALIZ_LIB_DIR")/include/libnormaliz" # if [ $(basename "$NORMALIZ_LIB_DIR") = ".libs" ] # then # # uninstalled # NORMALIZ_INC_DIR=$(dirname "$NORMALIZ_LIB_DIR")/libnormaliz # elif [ $(basename "$NORMALIZ_LIB_DIR") = "libnormaliz" ] # then # # uninstalled # NORMALIZ_INC_DIR="$NORMALIZ_LIB_DIR" # elif [ $(basename "$NORMALIZ_LIB_DIR") = "source" ] # then # # uninstalled # NORMALIZ_INC_DIR="$NORMALIZ_LIB_DIR/libnormaliz" #??? if [ $(basename "$NORMALIZ_LIB_DIR") != "lib" ] if ! [ -f "$NORMALIZ_INC_DIR/libnormaliz.h" ] then echo "$0: Please specify a properly installed version of libnormaliz" > /dev/stderr echo "$0: Did not find expected header file $NORMALIZ_INC_DIR/libnormaliz.h" > /dev/stderr #?? echo "$0: Path given was NORMALIZ_LIB_DIR = $NORMALIZ_LIB_DIR" > /dev/stderr exit 1 fi if [ "$HAVE_GMPXX" = "no" ] then echo "$0: ERROR: Normaliz requires libgmpxx." > /dev/stderr echo "$0: ERROR: Please use the command line option \"--with-libgmp=\" to specify" > /dev/stderr echo "$0: ERROR: a GMP installation with libgmpxx, or rebuild GMP specifying that" > /dev/stderr echo "$0: ERROR: you want the C++ library too (see GMP doc for details)." > /dev/stderr exit 1 fi NORMALIZ_VERSION=$(CXX=$CXX $SCRIPT_DIR/normaliz-version.sh "$NORMALIZ_INC_DIR/.." "$NORMALIZ_LIB" 2>$ERR_MESGS) if [ $? -ne 0 ] then echo "$0: ERROR: could not determine version of libnormaliz (req. v.3.8.10 or newer)" > /dev/stderr exit 1 fi if [ "$NORMALIZ_VERSION" -lt 30810 ] then echo "$0: ERROR: libnormaliz (v.$NORMALIZ_VERSION) is too old; must be v.30810 or newer" > /dev/stderr exit 1 fi # Make symbolic links in $EXTLIB_DIR/lib and $EXTLIB_DIR/include /bin/ln -s "$NORMALIZ_LIB" "$EXTLIB_DIR/lib/libnormaliz-symlink.$NORMALIZ_LIB_EXTN" /bin/ln -s "$NORMALIZ_INC_DIR" "$EXTLIB_DIR/include/libnormaliz" fi ################################################################## # Some special handling for Normaliz.. if [ $HAVE_NORMALIZ = "yes" ] then # Check whether Normaliz was compiled with OpenMP NORMALIZ_WITH_OPENMP=$($SCRIPT_DIR/normaliz-with-openmp.sh "$NORMALIZ_LIB") if [ -n "$NORMALIZ_WITH_OPENMP" ] then CXXFLAGS_FOR_NORMALIZ="$CXXFLAGS_FOR_NORMALIZ -fopenmp" fi fi CXXFLAGS="$CXXFLAGS $CXXFLAGS_FOR_NORMALIZ" ################################################################## # external library NTL ################################################################## # ***PRELIMINARY*** allows only NTL_LIB = /usr/local/lib/libntl.a if [ -z "$NTL_LIB" ] then HAVE_NTL=no else if [ \! -f "$NTL_LIB" -o \! -r "$NTL_LIB" ] then echo "$0: ERROR: Specified NTL library is not readable file \"$NTL_LIB\"" >/dev/stderr exit 1 fi HAVE_NTL=yes NTL_LIB_DIR=$(dirname "$NTL_LIB") NTL_INC_DIR=$(dirname "$NTL_LIB_DIR")/include # Make symbolic links in $EXTLIB_DIR/lib and $EXTLIB_DIR/include /bin/ln -s "$NTL_LIB" "$EXTLIB_DIR/lib/libntl-symlink.a" /bin/ln -s "$NTL_INC_DIR" "$EXTLIB_DIR/include/libntl" fi ################################################################## # external library: BOOST ################################################################## # BOOST installation needed for CoCoA-5 -- ignored for ONLY_COCOALIB. # Since BOOST is not (currently) essential for CoCoALib, we do # not give an error if the boost-find-hdrs.sh script cannot find it. # If a unique BOOST installation was not found, we set # BOOST_HDRS_NOT_FOUND to the error mesg (o/w it is left empty). # Otherwise the full path of the unique dir containing header files # is put in BOOST_INC_DIR. if [ "$ONLY_COCOALIB" = "no" ] then if [ -z "$BOOST_INC_DIR" ] then BOOST_INC_DIR=$($SCRIPT_DIR/boost-find-hdrs.sh 2> "$ERR_MESGS") BOOST_FIND_HDRS_EXIT_CODE=$? if [ $BOOST_FIND_HDRS_EXIT_CODE = 2 ] # 2 means terminating error then echo "ERROR: configuration for CoCoA-5 failed: BOOST headers missing" > /dev/stderr echo "HINT: Try one of the following: " > /dev/stderr echo "HINT: (1) ensure BOOST is installed: see http://www.boost.org/" > /dev/stderr echo "HINT: (2) use --with-boost-hdr-dir option to specify where BOOST is" > /dev/stderr echo "HINT: (3) use --only-cocoalib to configure just for CoCoALib" > /dev/stderr # /bin/cat "$ERR_MESGS" > /dev/stderr exit 1 fi if [ $BOOST_FIND_HDRS_EXIT_CODE = 1 ] then echo "INFO: More than one BOOST installation found:" /bin/cat "$ERR_MESGS" echo "INFO:" echo "INFO: Proceeding with choice: $BOOST_INC_DIR" echo sleep 3 fi fi # At this point BOOST_INC_DIR contains a plausible path. BOOST_INC_DIR=$(cd "$BOOST_INC_DIR"; pwd) /bin/ln -s "$BOOST_INC_DIR/boost" "$EXTLIB_5_DIR/include/" # boost-find-lib.sh also creates symlinks to libs BOOST_MESG=$($SCRIPT_DIR/boost-find-lib.sh "$BOOST_INC_DIR") if [ $? -ne 0 ] then echo "ERROR: BOOST library not found (or incomplete)" > /dev/stderr echo "ERROR: BOOST headers were found in:" > /dev/stderr echo "ERROR: $BOOST_INC_DIR" > /dev/stderr exit 1 fi eval "$BOOST_MESG" # sets BOOST_LIB_DIR and BOOST_LDLIBS # Check that the BOOST libs are compatible with CXX and CXXFLAGS BOOST_MESG=$($SCRIPT_DIR/boost-check-arch.sh "$BOOST_INC_DIR" "$BOOST_LIB_DIR" "$BOOST_LDLIBS" 2>&1) if [ $? -ne 0 ] then BOOST_LDLIBS_STATIC="-Wl,-Bstatic $BOOST_LDLIBS -Wl,-Bdynamic" BOOST_MESG2=$($SCRIPT_DIR/boost-check-arch.sh "$BOOST_INC_DIR" "$BOOST_LIB_DIR" "$BOOST_LDLIBS_STATIC" 2>&1) if [ $? -eq 0 ] then BOOST_LDLIBS=$BOOST_LDLIBS_STATIC else echo "ERROR: BOOST headers and libs found, but cannot link to BOOST libs!" > /dev/stderr echo "HINT: Your BOOST installation may be too old: version 1.80 works" > /dev/stderr exit 1 fi fi fi # Set HAVE_BOOST "english boolean" if [ "$ONLY_COCOALIB" = "no" ] then HAVE_BOOST=yes else HAVE_BOOST=no fi # Tell user which BOOST we are using. if [ "$ONLY_COCOALIB" = "no" ] then echo "Using BOOST:" echo " headers in $BOOST_INC_DIR/" echo " libraries in $BOOST_LIB_DIR/" fi echo ################################################################## # If we are intending to build the Qt GUI... # (0) if BOOST is absent, (silently) disable building the GUI # (1) check whether "qmake" is available -- needed for building the GUI # (2) assume that if "qmake" is available then all of QT is too. # (3) also check that "qmake" actually runs (Ubuntu 14.04 can have a broken symlink) # (4) also check that BOOST is available (o/w cannot build CoCoA-5) ##if [ "$BUILD_QT_GUI" = "yes" -a "$HAVE_BOOST" = "no" ] ##then ## BUILD_QT_GUI=no ## NO_GUI_REASON="No BOOST, so cannot build CoCoA-5" ##fi QT_ERR_MESG= if [ "$BUILD_QT_GUI" = 'yes' ] then if ! QMAKE=$("$SCRIPT_DIR/qt5-check.sh" 2> "ERR_MESGS") then BUILD_QT_GUI='no' QT_ERR_MESG=$(/bin/cat "ERR_MESGS") NO_GUI_REASON="Qt5 system absent or not working: (reason below)" else echo "Building Qt5 GUI" echo fi fi if [ "$ONLY_COCOALIB" = "no" ] && [ "$BUILD_QT_GUI" = 'no' ] then echo "Not building Qt5 GUI: $NO_GUI_REASON" if [ -n "$QT_ERR_MESG" ]; then echo "--> actual QT-$QT_ERR_MESG"; fi echo fi ################################################################## # Determine custom CPP flags (& add them to CXXFLAGS_COMMON) CXX="$CXX" CXXFLAGS="$CXXFLAGS" UL2L="`$SCRIPT_DIR/cpp-flags-ulong2long.sh \"$CONFIG_SCRIPT_DIR/include/CoCoA\" 2> \"$ERR_MESGS\"`" if [ $? -ne 0 ] then echo "$0: ERROR: ulong2long customization failed" > /dev/stderr /bin/cat "$ERR_MESGS" > /dev/stderr exit 1 fi CXX="$CXX" CXXFLAGS="$CXXFLAGS" ULL2LL="`$SCRIPT_DIR/cpp-flags-ulonglong2longlong.sh \"$CONFIG_SCRIPT_DIR/include/CoCoA\" 2> \"$ERR_MESGS\"`" if [ $? -ne 0 ] then echo "$0: ERROR: ulonglong2longlong Customization failed" > /dev/stderr /bin/cat "$ERR_MESGS" > /dev/stderr exit 1 fi # Tell user the compiler and default compilation flags put in the Makefile. echo "C++ compiler.....: CXX=$CXX" echo "Compilation flags: CXXFLAGS=\"$CXXFLAGS\"" echo ################################################################## ################################################################## # We have checked the compiler, GMP library etc., so now create the CONFIG_FILE echo "$ORIG_CMD $ORIG_ARGS" > "$CONFIG_DIR/last-config-cmd" ################################################################## # Place initial message and fixed_part1 in $CONFIG_FILE echo "# Makefile configuration for CoCoALib." > "$CONFIG_TMP" echo "# Created automatically by the configure script." >> "$CONFIG_TMP" echo "# Created on `date \"+%Y-%m-%d at time %H:%M:%S\"`" >> "$CONFIG_TMP" echo "# Command was: " >> "$CONFIG_TMP" echo "# $ORIG_CMD $ORIG_ARGS" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" echo "PLATFORM=`uname -s -r -m`" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" /bin/cat "$CONFIG_DIR/fixed_part1" >> "$CONFIG_TMP" ################################################################## # Append the CoCoALib version number. source "$CONFIG_DIR/version" COCOALIB_VERSION=$VER_MAJ.$VER_MIN$VER_PATCH echo "# Version number of CoCoALib we shall build." >> "$CONFIG_TMP" echo "COCOALIB_VERSION=$COCOALIB_VERSION" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" # Installation command and directory (just placeholders, 20140323) echo "Installation options are:" echo " command INSTALL_CMD = $INSTALL_CMD" echo " directory COCOALIB_INSTALL_DIR = $COCOALIB_INSTALL_DIR" if [ "$ONLY_COCOALIB" = "no" ] then echo " directory COCOA5_INSTALL_DIR = $COCOA5_INSTALL_DIR" fi echo echo "INSTALL_CMD=$INSTALL_CMD" >> "$CONFIG_TMP" echo "COCOALIB_INSTALL_DIR=$COCOALIB_INSTALL_DIR" >> "$CONFIG_TMP" if [ "$ONLY_COCOALIB" = "no" ] then echo "COCOA5_INSTALL_DIR=$COCOA5_INSTALL_DIR" >> "$CONFIG_TMP" fi echo >> "$CONFIG_TMP" echo "EXTLIBS=\$(COCOA_ROOT)/$EXTLIB_DIR" >> "$CONFIG_TMP" echo "EXTLIBS_5=\$(COCOA_ROOT)/$EXTLIB_5_DIR" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" echo "######################################################" >> "$CONFIG_TMP" echo "# Compilation settings." >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" echo "CXX=$CXX" >> "$CONFIG_TMP" echo "CXXFLAGS=$CXXFLAGS" >> "$CONFIG_TMP" echo "# for debugging/profiling append flag -g" >> "$CONFIG_TMP" echo "# append also -pg for profiling with gprof" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" echo "ARFLAGS=-rcS" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" echo "ISYSTEM=$ISYSTEM" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" ### External libraries: add appropriate definitions to the config file echo "######################################################" >> "$CONFIG_TMP" echo "# External libraries for CoCoALib:" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" echo "# We use the following GMP installation:" >> "$CONFIG_TMP" echo "GMP_VERSION=$GMP_VERSION" >> "$CONFIG_TMP" ###if [ $HAVE_DEFAULT_GMP = "no" ] ###then echo "GMP_LDLIB=-lgmp-symlink" >> "$CONFIG_TMP" if [ $HAVE_GMPXX = "yes" ] then echo "GMPXX_LDLIB=-lgmpxx-symlink" >> "$CONFIG_TMP" fi # else # echo "GMP_LDLIB=-lgmp" >> "$CONFIG_TMP" # if [ $HAVE_GMPXX = "yes" ] # then # echo "GMPXX_LDLIB=-lgmpxx" >> "$CONFIG_TMP" # fi # fi echo >> "$CONFIG_TMP" ################################################################## # settings for optional external libs echo "OPTIONAL external libraries for CoCoALib:" # FROBBY echo "# FROBBY settings:" >> "$CONFIG_TMP" echo "HAVE_FROBBY=$HAVE_FROBBY" >> "$CONFIG_TMP" echo "HAVE_FROBBY = $HAVE_FROBBY $FROBBY_LIB" if [ $HAVE_FROBBY = "yes" ] then # Recall that GMPXX_LIB is the libgmpxx.a library echo "FROBBY_LDLIBS=-lfrobby-symlink" >> "$CONFIG_TMP" echo "FROBBY_VERSION=" >> "$CONFIG_TMP" fi echo >> "$CONFIG_TMP" # CDD echo "# CDD settings:" >> "$CONFIG_TMP" echo "HAVE_CDD=$HAVE_CDD" >> "$CONFIG_TMP" echo "HAVE_CDD = $HAVE_CDD $CDD_LIB" if [ $HAVE_CDD = "yes" ] then echo "CDD_LDLIBS=-lcddgmp-symlink" >> "$CONFIG_TMP" echo "CDD_VERSION=" >> "$CONFIG_TMP" fi echo >> "$CONFIG_TMP" # GFAN echo "# GFAN settings:" >> "$CONFIG_TMP" echo "HAVE_GFAN=$HAVE_GFAN" >> "$CONFIG_TMP" echo "HAVE_GFAN = $HAVE_GFAN $GFAN_LIB" if [ $HAVE_GFAN = "yes" ] then echo "GFAN_LDLIBS=-lgfan-symlink" >> "$CONFIG_TMP" echo "GFAN_VERSION=" >> "$CONFIG_TMP" fi echo >> "$CONFIG_TMP" # GSL echo "# GSL settings:" >> "$CONFIG_TMP" echo "HAVE_GSL=$HAVE_GSL" >> "$CONFIG_TMP" echo "HAVE_GSL = $HAVE_GSL $GSL_LIB" if [ $HAVE_GSL = "yes" ] then #### echo "GSL_INC_DIR=\"$GSL_INC_DIR\"" >> "$CONFIG_TMP" #### echo "GSL_INCLUDE=-I \$(GSL_INC_DIR)" >> "$CONFIG_TMP" if "$PKGCONF" --exists gsl 2>/dev/null then GSL_LDLIBS=$($PKGCONF --libs gsl) echo "GSL_LDLIBS=$GSL_LDLIBS" >> "$CONFIG_TMP" else echo "GSL_LDLIBS=-lgsl-symlink -lgslcblas -llapack" >> "$CONFIG_TMP" fi # Can get version number from gsl_version.h: global var const char* gsl_version, or macro GSL_VERSION echo "GSL_VERSION=" >> "$CONFIG_TMP" fi echo >> "$CONFIG_TMP" # MATHSAT echo "# MathSAT settings:" >> "$CONFIG_TMP" echo "HAVE_MATHSAT =$HAVE_MATHSAT" >> "$CONFIG_TMP" echo "HAVE_MATHSAT = $HAVE_MATHSAT $MATHSAT_LIB" if [ $HAVE_MATHSAT = "yes" ] then # Recall that GMPXX_LIB is the libgmpxx.a library echo "MATHSAT_LDLIBS=-lmathsat-symlink" >> "$CONFIG_TMP" echo "MATHSAT_VERSION=" >> "$CONFIG_TMP" fi echo >> "$CONFIG_TMP" # NORMALIZ echo "# Normaliz settings:" >> "$CONFIG_TMP" echo "HAVE_NORMALIZ=$HAVE_NORMALIZ" >> "$CONFIG_TMP" echo "HAVE_NORMALIZ = $HAVE_NORMALIZ $NORMALIZ_LIB" if [ $HAVE_NORMALIZ = "yes" ] then # Recall that GMPXX_LIB is the libgmpxx.a library echo "NORMALIZ_LDLIBS=-lnormaliz-symlink" >> "$CONFIG_TMP" echo "NORMALIZ_VERSION=" >> "$CONFIG_TMP" fi echo >> "$CONFIG_TMP" # NTL -- preliminary!!! echo "# NTL settings: - preliminary!!!" >> "$CONFIG_TMP" echo "HAVE_NTL=$HAVE_NTL" >> "$CONFIG_TMP" echo "HAVE_NTL = $HAVE_NTL $NTL_LIB" if [ $HAVE_NTL = "yes" ] then echo "NTL_LDLIBS=-lntl-symlink -lpthread" >> "$CONFIG_TMP" echo "NTL_VERSION=" >> "$CONFIG_TMP" fi echo >> "$CONFIG_TMP" echo ### List of libraries echo "LDLIBS=$LDFPIC \$(COCOA_LIB) -L\$(EXTLIBS)/lib \$(FROBBY_LDLIBS) \$(GFAN_LDLIBS) \$(CDD_LDLIBS) \$(GSL_LDLIBS) \$(MATHSAT_LDLIBS) \$(NORMALIZ_LDLIBS) \$(NTL_LDLIBS) \$(GMPXX_LDLIB) \$(GMP_LDLIB)" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" ### 2019-12-17 JAA comment out this ancient code block -- delete??? # ################################################################## # # Some platforms need a special library to use sockets. # OSNAME=`uname` # if [ "$OSNAME" = "SunOS" ] # then # SOCKET_LIB="-lsocket -lnsl" # fi # if [ -n "$SOCKET_LIB" ] # then # echo "SOCKET_LIB=$SOCKET_LIB" >> "$CONFIG_TMP" # fi ####################################################### ## Flags/settings for CoCoA-5 echo >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" echo "###################################################" >> "$CONFIG_TMP" echo "# Flags/libraries/settings for CoCoA-5" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" if [ "$ONLY_COCOALIB" = "yes" ] then echo "# NOT BUILDING CoCoA-5: configure option" >> "$CONFIG_TMP" echo "HAVE_BOOST = no" >> "$CONFIG_TMP" echo "BOOST_LDLIBS=" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" else # Building CoCoA-5 echo "External libraries for CoCoA-5:" echo "HAVE_BOOST = yes $BOOST_LIB_DIR" echo "HAVE_READLINE = $HAVE_READLINE $READLINE_LIB" # BOOST settings into config file echo "# BOOST library:" >> "$CONFIG_TMP" echo "HAVE_BOOST=yes" >> "$CONFIG_TMP" echo "BOOST_LDLIBS=$BOOST_LDLIBS" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" # READLINE settings into config file echo "# READLINE settings:" >> "$CONFIG_TMP" echo "HAVE_READLINE=$HAVE_READLINE" >> "$CONFIG_TMP" if [ $HAVE_READLINE = "yes" ] then if ! [ -z "$READLINE_INC_DIR" ] then echo "ISYSTEM_READLINE_INCLUDE=-\$(ISYSTEM) $READLINE_INC_DIR" >> "$CONFIG_TMP" fi echo "READLINE_LDLIBS=$READLINE_LIB" >> "$CONFIG_TMP" fi echo >> "$CONFIG_TMP" echo "COCOA5_CXX_DEFINES=$COCOA5_CXX_DEFINES" >> "$CONFIG_TMP" echo "COCOA5_LDLIBS=-L\$(EXTLIBS_5)/lib \$(BOOST_LDLIBS) \$(READLINE_LDLIBS)" >> "$CONFIG_TMP" #echo "COCOA5_LDLIBS=\$(SOCKET_LIB) \$(BOOST_LDLIBS) \$(READLINE_LDLIBS)" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" fi ################################################################## # Put in flag for building Qt GUI echo "# Settings for CoCoA-5 Qt GUI" >> "$CONFIG_TMP" echo "BUILD_QT_GUI=$BUILD_QT_GUI" >> "$CONFIG_TMP" echo "QMAKE=$QMAKE" >> "$CONFIG_TMP" echo >> "$CONFIG_TMP" ################################################################## # Append the second fixed part to $CONFIG_TMP, then rename to $CONFIG_FILE /bin/cat "$CONFIG_DIR/fixed_part2" >> "$CONFIG_TMP" /bin/mv "$CONFIG_TMP" "$CONFIG_FILE" ################################################################## # Output PREPROCESSOR.H # At this point $CPPDEFNS_H should exist and be empty echo "#ifndef CoCoA_PREPROCESSOR_DEFNS_H" >> "$CPPDEFNS_H.part" echo "#define CoCoA_PREPROCESSOR_DEFNS_H" >> "$CPPDEFNS_H.part" echo >> "$CPPDEFNS_H.part" echo "// Created automatically by CoCoALib configure script." >> "$CPPDEFNS_H.part" echo "// Created on date `date \"+%Y-%m-%d at time %H:%M:%S\"`" >> "$CPPDEFNS_H.part" echo >> "$CPPDEFNS_H.part" echo "// Some defines are used in src/AlgebraicCore/BuildInfo.C" >> "$CPPDEFNS_H.part" echo >> "$CPPDEFNS_H.part" if [ "$COCOA_DEBUG" = "yes" ] then echo "// To disable debugging, reconfigure without \"--debug\"" >> "$CPPDEFNS_H.part" echo "#define CoCoA_DEBUG" >> "$CPPDEFNS_H.part" echo "#define CoCoA_DEBUG_MODE true" >> "$CPPDEFNS_H.part" else echo "// To enable debugging, reconfigure with option \"--debug\"">> "$CPPDEFNS_H.part" echo "#undef CoCoA_DEBUG" >> "$CPPDEFNS_H.part" echo "#define CoCoA_DEBUG_MODE false" >> "$CPPDEFNS_H.part" fi echo >> "$CPPDEFNS_H.part" echo "// define CoCoA_MEMPOOL_DEBUG if you have memory problems" >> "$CPPDEFNS_H.part" echo "#undef CoCoA_MEMPOOL_DEBUG" >> "$CPPDEFNS_H.part" echo "// define CoCoA_MEMPOOL_DISABLE to avoid using MemPools" >> "$CPPDEFNS_H.part" if [ "$DISABLE_MEMPOOL" = "yes" ] then echo "#define CoCoA_MEMPOOL_DISABLE" >> "$CPPDEFNS_H.part" else echo "#undef CoCoA_MEMPOOL_DISABLE" >> "$CPPDEFNS_H.part" fi echo >> "$CPPDEFNS_H.part" echo >> "$CPPDEFNS_H.part" echo "#define CoCoA_ULONG2LONG $UL2L" >> "$CPPDEFNS_H.part" echo "#define CoCoA_ULONGLONG2LONGLONG $ULL2LL" >> "$CPPDEFNS_H.part" echo >> "$CPPDEFNS_H.part" # aux fn: prints "#define" if arg is "yes"; otherwise prints "#undef" define_if() { if [ "$1" = "yes" ] then echo "#define" else echo "#undef" fi } echo "`define_if $THREADSAFE_HACK` CoCoA_THREADSAFE_HACK" >> "$CPPDEFNS_H.part" echo "`define_if $HAVE_NORMALIZ` CoCoA_WITH_NORMALIZ" >> "$CPPDEFNS_H.part" echo "`define_if $HAVE_FROBBY` CoCoA_WITH_FROBBY" >> "$CPPDEFNS_H.part" echo "`define_if $HAVE_GFAN` CoCoA_WITH_GFAN" >> "$CPPDEFNS_H.part" echo "`define_if $HAVE_MATHSAT` CoCoA_WITH_MATHSAT" >> "$CPPDEFNS_H.part" echo "`define_if $HAVE_GSL` CoCoA_WITH_GSL" >> "$CPPDEFNS_H.part" #?????echo "`define_if $HAVE_BOOST` CoCoA_WITH_BOOST" >> "$CPPDEFNS_H.part" ###???echo "`define_if $HAVE_READLINE` CoCoA_WITH_READLINE" >> "$CPPDEFNS_H.part" echo >> "$CPPDEFNS_H.part" echo "#endif" >> "$CPPDEFNS_H.part" # Should be unnecessary /bin/rm -f "$CPPDEFNS_H" /bin/mv "$CPPDEFNS_H.part" "$CPPDEFNS_H" ################################################################## # Configuration completed successfully. Print final message. echo if [ -n "$WARNINGS" ] then echo "-------------------------------------------------------" echo "WARNINGS: $WARNINGS" echo "-------------------------------------------------------" echo sleep 3 fi echo "=======================================================" echo "CoCoALib configuration process complete." echo "Configuration info saved in the following files:" echo "[1] $CONFIG_FILE" echo "[2] $CPPDEFNS_H" echo "======================================================="