Mercurial > hg > dml-home
diff src/swipl/build @ 53:c7720fefea26
Added helpers and info about building SWI Prolog
author | daniel |
---|---|
date | Thu, 14 May 2015 15:35:04 +0100 |
parents | |
children | 271cbb745f91 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/swipl/build Thu May 14 15:35:04 2015 +0100 @@ -0,0 +1,232 @@ +#!/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/pl-<version> and create symlinks from $PREFIX/bin for the +# main programs. Users can always use older versions by running +# $PREFIX/lib/pl-<version>/bin/<arch>/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=/usr/local +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=<max>' +# to build the system faster using all your cores. The optimal value +# depends a lot on your hardware. Using 4 jobs on a dual-core machines +# seems enough to keep both cores busy. + +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 -gdwarf-2 -g3" +# export CMFLAGS= +# export CIFLAGS= +# export LDFLAGS="-O2 -g" + +# On MacOS you need this to get some libraries from Macports. Since +# recently, there are three C compilers: gcc-llvm and clang come with +# XCode. Native gcc can be installed in various ways (e.g., using +# Macports). Current SWI-Prolog sources compile and work with all these +# alternatives. 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). +# +# 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 [ "`uname`" = Darwin ]; then + export LIBRARY_PATH=/usr/lib:/opt/local/lib + export CPATH=/usr/include:/opt/local/include:/opt/X11/include + export PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig:/opt/local/lib/pkgconfig + if [ -f "$JAVA_HOME/bin/java" ]; then + export JAVAPREFIX="$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<version>, +# 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' + +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-<default>} + $EXTRA_PKGS - $DISABLE_PKGS + +# export PKG= + +# [EDIT] Packages to skip. Leaving it blank compiles all default packages. +export DISABLE_PKGS="jasmine PDT R jpl" + +# [EDIT] Packages to add. +# export EXTRA_PKGS="db 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-<version>. Using +# this option drops <version>. Using versions, you can install multiple +# versions side-by-site and run old versions at any time by starting +# $libdir/swipl-<version>/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 ] && scripts/check_build_log.sh make.out + fi + + # See whether any package failed to build + ./packages/report-failed || exit 1 +fi # setvars +