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