#!/usr/bin/env bash # # This is the script we use to build SWI-Prolog and all its packages. # Copy the script to `build', edit to suit the local installation # requirements and run it. Once correct, upgrading to a new release is # now limited to getting the new sources and run ./build. # [EDIT] Prefix location of the installation. It is _not_ adviced to use # a versioned prefix. The system will install in # $PREFIX/lib/swipl- and create symlinks from $PREFIX/bin for # the main programs. Users can always use older versions by running # $PREFIX/lib/swipl-/bin//pl # # If you change PREFIX such that the system is installed in a place for # which you have no write access, set SUDO to the command to run the # remainder of the commandline as privilaged user. E.g., if you change # PREFIX to /usr/local you typically must change SUDO to "sudo" #PREFIX=$HOME PREFIX=/opt/logicmoo_workspace SUDO= #SUDO="sudo" # [EDIT] Version of make to use. This must be GNU-make. On many Unix # systems this is installed as 'gmake'. On most GNU-based systems (e.g., # linux), the default make is GNU-make. You can use 'make --jobs=' # to build the system faster using all your cores. The optimal value # depends a lot on your hardware. Unfortunately, not all dependencies # are covered by the Makefiles. If your build fails on what might be a # missing dependency, try re-running without --jobs and report the # issue. # MAKE=make MAKE='make --jobs=4' # [EDIT] Compiler and options. # # CC: Which C-compiler to use # COFLAGS: Flags for the optimizer such as "-O3" or "-g" # CMFLAGS: Machine flags such as "-m64" (64-bits on gcc) # CIFLAGS: Include-path such as "-I/opt/include" # LDFLAGS: Link flags such as "-L/opt/lib" # # Leaving an option blank leaves the choice to configure. The commented # values below enable much better C-level debugging with almost the same # performance on GCC based systems (the default is to compile using -O3) # For optiomal performance, see also --enable-useprofile below. # export CC= # export COFLAGS="-O2 -fno-strict-aliasing -gdwarf-2 -g3" # export CMFLAGS= # export CIFLAGS= # export LDFLAGS="-O2 -g" # On MacOS you need this to get some libraries from Macports. There are # three commonly used C compilers on the Mac: gcc (based on llvm) and # clang that come with XCode and (native) gcc from Macports. The current # SWI-Prolog sources compile and work with all these alternatives. There # are a few gotchas: # # - The ssl package uses the Apple security API that can only be # compiled using the XCode compilers. Compiled with native # gcc SSL has no access to the OS root certificates and can only # be used without certificate validation or with certificates # explicitly provided by the user. # - If you want the last bit of performance and don't mind some extra # work, get a recent native GCC, set CC below and enable # --enable-useprofile (see below). You could compile SSL using # the XCode compiler. # # Recent versions of Quartz (X11) seem to install the headers into # /opt/X11/include. We put this after /opt/local/include, to use the # Macport version of X11 if this is installed. # # As of MacOS 10.9, Apple's Java does not include the headers for # linking to C. Therefore you need to install Oracle's JDK and set # $JAVAPREFIX to the bin directory holding =java=. We try to find it at # the most likely places below. # If you use HomeBrew as your Mac OS package manager, uncomment the # following line to use the default installation locations for shared # libraries and header files. # USE_HOMEBREW=yes if [ "`uname`" = Darwin ]; then if [ "x$USE_HOMEBREW" = xyes ]; then export LIBRARY_PATH=/usr/local/lib:/usr/lib export CPATH=/usr/local/include:/usr/include:/opt/X11/include else export LIBRARY_PATH=/usr/lib:/opt/local/lib:/opt/local/lib/db60 export CPATH=/usr/include:/opt/local/include:/opt/local/include/db60:/opt/X11/include fi export PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig:/opt/local/lib/pkgconfig:/opt/X11/lib/pkgconfig if [ -f "$JAVA_HOME/bin/java" ]; then export JAVAPREFIX="$JAVA_HOME/bin" elif [ -f /usr/libexec/java_home ]; then export JAVAPREFIX=$(/usr/libexec/java_home)/bin elif [ -f /Library/Java/Home/bin/java ]; then export JAVAPREFIX=/Library/Java/Home/bin elif [ -d /Library/Java/JavaVirtualMachines/*/Contents/Home/bin ]; then export JAVAPREFIX="`echo /Library/Java/JavaVirtualMachines/*/Contents/Home/bin`" fi # export CC="gcc-4.2" # export CXX="g++-4.2" # export CXXCPP="g++-4.2 -E" fi # [EDIT] On Solaris also puts there stuff everywhere ... # export CIFLAGS=-I/opt/csw/include/ncurses # export LDFLAGS=-L/opt/csw/lib # [EDIT] On FreeBSD, java is installed under /usr/local/jdk, # and the executables are _copied_ to /usr/local/bin. Unfortunately, the # copy leaves the headers out, so the original files must be used. # export JAVAC=/usr/local/jdk1.6.0/bin/javac # [EDIT] On FreeBSD, the following is needed to fetch the headers for # GMP. # export CIFLAGS='-I/usr/local/include' # [EDIT] Open OpenBSD, the following are needed to fetch the required # non-default dependencies. Using "CC=cc" the preferred clang compiler # is used. SWI-Prolog compiles both with clang and gcc. # export CC=cc # export CIFLAGS="-I/usr/local/include" # export LDFLAGS="-O2 -g -L/usr/local/lib" export CFLAGS="$COFLAGS $CMFLAGS $CIFLAGS" ################################################################ # Package (add-ons) selection ################################################################ # [EDIT] Packages to configure. Leaving it blank compiles all default # packages. The final set of packages is # # ${PKG-} + $EXTRA_PKGS - $DISABLE_PKGS # export PKG= # [EDIT] Packages to skip. Leaving it blank compiles all default packages. # export DISABLE_PKGS="jpl ssl odbc utf8proc" # [EDIT] Packages to add. # export EXTRA_PKGS="bdb ltx2htm space" # [EDIT] Where to find the jar for Junit 3.8. Needed to test jpl # export JUNIT=/opt/local/share/java/junit.jar ################################################################ # Misc stuff ################################################################ # [EDIT] Extra options to pass to the toplevel configure. # --link # Using --link, the system is installed using symbolic links. This means # you cannot remove or clean the sources, but it largely simplifies # editing the system Prolog files during development. # # --enable-useprofile # The config --enable-useprofile exploits GCC -fprofile-use option. The # system is compiled, profiled and re-compiled to get better # branch-prediction. This makes the system approx. 10% faster. Do not # use this for developing the kernel because it complicates maintenance. # # --disable-libdirversion # By default, the system is installed in $libdir/swipl-. Using # this option drops . Using versions, you can install multiple # versions side-by-site and run old versions at any time by starting # $libdir/swipl-/bin/$arch/swipl. Without, the system is always # at a nice stable place, so external foreign objects linked against the # binary need not be updated with a Prolog update. # # --enable-shared # Use this to create a shared object for the Prolog kernel. The default # depends on the platform. Creating a shared object is the default on # most platforms, either because it is needed or because it does no # harm. The only exception to this rule is Linux on x86 (Intel 32-bit). # It is not needed on this platform and Linux shared object model costs # a CPU register. Given the limited number of CPU registers on the x86 # platform, this results in a performance degradation of about 10%. EXTRACFG+=" --link" # EXTRACFG+=" --enable-useprofile" # EXTRACFG+=" --disable-libdirversion" EXTRACFG+=" --enable-shared" export EXTRACFG # One possiblity to make relocatable executables on Linux is by using # the RPATH mechanism. See ld.so(1) and chrpath(1). However, chrpath # cannot enlarge the path. Uncommenting the line below adds :xxx... to # the RPATH, where the given count is the number of x-s. # # export RPATH_RESERVE=70 ################################################################ # No edit should be needed below this line ################################################################ V=`cat VERSION` config=true make=true install=true done=false setvars=false while test "$done" = false; do case "$1" in --config) make=false install=false shift ;; --make) config=false install=false shift ;; --install) config=false make=false shift ;; --prefix=*) PREFIX=`echo "$1" | sed 's/--prefix=//'` shift ;; --setvars) setvars=true shift ;; *) done=true ;; esac done if [ "$setvars" = "false" ]; then rm -f packages/.failed.* if [ "$config" = "true" ]; then ./configure --prefix=$PREFIX --with-world $EXTRACFG $@ 2>&1 | tee configure.out if [ "${PIPESTATUS[0]}" != 0 ]; then exit 1; fi fi if [ "$make" = "true" ]; then $MAKE $@ 2>&1 | tee make.out if [ "${PIPESTATUS[0]}" != 0 ]; then exit 1; fi fi if [ "$install" = "true" ]; then $SUDO $MAKE install $@ 2>&1 | tee make-install.out if [ "${PIPESTATUS[0]}" != 0 ]; then exit 1; fi fi if [ -z "$DESTDIR" ]; then $MAKE check-installation fi # Parse build log for warnings that may indicate serious runtime issues if [ "$make" = "true" ]; then [ -f make.out ] && bash scripts/check_build_log.sh make.out fi # See whether any package failed to build bash packages/report-failed || exit 1 fi # setvars