annotate src/swipl/build @ 60:1a2e9d3adcb2

Update SWISH settings.
author samer
date Wed, 20 May 2015 16:58:09 +0100
parents c7720fefea26
children 271cbb745f91
rev   line source
daniel@53 1 #!/usr/bin/env bash
daniel@53 2 #
daniel@53 3 # This is the script we use to build SWI-Prolog and all its packages.
daniel@53 4 # Copy the script to `build', edit to suit the local installation
daniel@53 5 # requirements and run it. Once correct, upgrading to a new release is
daniel@53 6 # now limited to getting the new sources and run ./build.
daniel@53 7
daniel@53 8 # [EDIT] Prefix location of the installation. It is _not_ adviced to use
daniel@53 9 # a versioned prefix. The system will install in
daniel@53 10 # $PREFIX/lib/pl-<version> and create symlinks from $PREFIX/bin for the
daniel@53 11 # main programs. Users can always use older versions by running
daniel@53 12 # $PREFIX/lib/pl-<version>/bin/<arch>/pl
daniel@53 13 #
daniel@53 14 # If you change PREFIX such that the system is installed in a place for
daniel@53 15 # which you have no write access, set SUDO to the command to run the
daniel@53 16 # remainder of the commandline as privilaged user. E.g., if you change
daniel@53 17 # PREFIX to /usr/local you typically must change SUDO to "sudo"
daniel@53 18
daniel@53 19 PREFIX=/usr/local
daniel@53 20 SUDO="sudo"
daniel@53 21
daniel@53 22 # [EDIT] Version of make to use. This must be GNU-make. On many Unix
daniel@53 23 # systems this is installed as 'gmake'. On most GNU-based systems (e.g.,
daniel@53 24 # linux), the default make is GNU-make. You can use 'make --jobs=<max>'
daniel@53 25 # to build the system faster using all your cores. The optimal value
daniel@53 26 # depends a lot on your hardware. Using 4 jobs on a dual-core machines
daniel@53 27 # seems enough to keep both cores busy.
daniel@53 28
daniel@53 29 MAKE=make
daniel@53 30 # MAKE='make --jobs=4'
daniel@53 31
daniel@53 32 # [EDIT] Compiler and options.
daniel@53 33 #
daniel@53 34 # CC: Which C-compiler to use
daniel@53 35 # COFLAGS: Flags for the optimizer such as "-O3" or "-g"
daniel@53 36 # CMFLAGS: Machine flags such as "-m64" (64-bits on gcc)
daniel@53 37 # CIFLAGS: Include-path such as "-I/opt/include"
daniel@53 38 # LDFLAGS: Link flags such as "-L/opt/lib"
daniel@53 39 #
daniel@53 40 # Leaving an option blank leaves the choice to configure. The commented
daniel@53 41 # values below enable much better C-level debugging with almost the same
daniel@53 42 # performance on GCC based systems (the default is to compile using -O3)
daniel@53 43 # For optiomal performance, see also --enable-useprofile below.
daniel@53 44
daniel@53 45 # export CC=
daniel@53 46 # export COFLAGS="-O2 -gdwarf-2 -g3"
daniel@53 47 # export CMFLAGS=
daniel@53 48 # export CIFLAGS=
daniel@53 49 # export LDFLAGS="-O2 -g"
daniel@53 50
daniel@53 51 # On MacOS you need this to get some libraries from Macports. Since
daniel@53 52 # recently, there are three C compilers: gcc-llvm and clang come with
daniel@53 53 # XCode. Native gcc can be installed in various ways (e.g., using
daniel@53 54 # Macports). Current SWI-Prolog sources compile and work with all these
daniel@53 55 # alternatives. If you want the last bit of performance and don't mind
daniel@53 56 # some extra work, get a recent native GCC, set CC below and enable
daniel@53 57 # --enable-useprofile (see below).
daniel@53 58 #
daniel@53 59 # Recent versions of Quartz (X11) seem to install the headers into
daniel@53 60 # /opt/X11/include. We put this after /opt/local/include, to use the
daniel@53 61 # Macport version of X11 if this is installed.
daniel@53 62 #
daniel@53 63 # As of MacOS 10.9, Apple's Java does not include the headers for
daniel@53 64 # linking to C. Therefore you need to install Oracle's JDK and set
daniel@53 65 # $JAVAPREFIX to the bin directory holding =java=. We try to find it at
daniel@53 66 # the most likely places below.
daniel@53 67
daniel@53 68 if [ "`uname`" = Darwin ]; then
daniel@53 69 export LIBRARY_PATH=/usr/lib:/opt/local/lib
daniel@53 70 export CPATH=/usr/include:/opt/local/include:/opt/X11/include
daniel@53 71 export PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig:/opt/local/lib/pkgconfig
daniel@53 72 if [ -f "$JAVA_HOME/bin/java" ]; then
daniel@53 73 export JAVAPREFIX="$JAVA_HOME/bin"
daniel@53 74 elif [ -f /Library/Java/Home/bin/java ]; then
daniel@53 75 export JAVAPREFIX=/Library/Java/Home/bin
daniel@53 76 elif [ -d /Library/Java/JavaVirtualMachines/*/Contents/Home/bin ]; then
daniel@53 77 export JAVAPREFIX="`echo /Library/Java/JavaVirtualMachines/*/Contents/Home/bin`"
daniel@53 78 fi
daniel@53 79 # export CC="gcc-4.2"
daniel@53 80 # export CXX="g++-4.2"
daniel@53 81 # export CXXCPP="g++-4.2 -E"
daniel@53 82 fi
daniel@53 83
daniel@53 84 # [EDIT] On Solaris also puts there stuff everywhere ...
daniel@53 85 # export CIFLAGS=-I/opt/csw/include/ncurses
daniel@53 86 # export LDFLAGS=-L/opt/csw/lib
daniel@53 87
daniel@53 88 # [EDIT] On FreeBSD, java is installed under /usr/local/jdk<version>,
daniel@53 89 # and the executables are _copied_ to /usr/local/bin. Unfortunately, the
daniel@53 90 # copy leaves the headers out, so the original files must be used.
daniel@53 91 # export JAVAC=/usr/local/jdk1.6.0/bin/javac
daniel@53 92
daniel@53 93 # [EDIT] On FreeBSD, the following is needed to fetch the headers for
daniel@53 94 # GMP.
daniel@53 95 # export CIFLAGS='-I/usr/local/include'
daniel@53 96
daniel@53 97 export CFLAGS="$COFLAGS $CMFLAGS $CIFLAGS"
daniel@53 98
daniel@53 99 ################################################################
daniel@53 100 # Package (add-ons) selection
daniel@53 101 ################################################################
daniel@53 102
daniel@53 103 # [EDIT] Packages to configure. Leaving it blank compiles all default
daniel@53 104 # packages. The final set of packages is
daniel@53 105 #
daniel@53 106 # ${PKG-<default>} + $EXTRA_PKGS - $DISABLE_PKGS
daniel@53 107
daniel@53 108 # export PKG=
daniel@53 109
daniel@53 110 # [EDIT] Packages to skip. Leaving it blank compiles all default packages.
daniel@53 111 export DISABLE_PKGS="jasmine PDT R jpl"
daniel@53 112
daniel@53 113 # [EDIT] Packages to add.
daniel@53 114 # export EXTRA_PKGS="db ltx2htm space"
daniel@53 115
daniel@53 116 # [EDIT] Where to find the jar for Junit 3.8. Needed to test jpl
daniel@53 117 # export JUNIT=/opt/local/share/java/junit.jar
daniel@53 118
daniel@53 119 ################################################################
daniel@53 120 # Misc stuff
daniel@53 121 ################################################################
daniel@53 122
daniel@53 123 # [EDIT] Extra options to pass to the toplevel configure.
daniel@53 124
daniel@53 125 # --link
daniel@53 126 # Using --link, the system is installed using symbolic links. This means
daniel@53 127 # you cannot remove or clean the sources, but it largely simplifies
daniel@53 128 # editing the system Prolog files during development.
daniel@53 129 #
daniel@53 130 # --enable-useprofile
daniel@53 131 # The config --enable-useprofile exploits GCC -fprofile-use option. The
daniel@53 132 # system is compiled, profiled and re-compiled to get better
daniel@53 133 # branch-prediction. This makes the system approx. 10% faster. Do not
daniel@53 134 # use this for developing the kernel because it complicates maintenance.
daniel@53 135 #
daniel@53 136 # --disable-libdirversion
daniel@53 137 # By default, the system is installed in $libdir/swipl-<version>. Using
daniel@53 138 # this option drops <version>. Using versions, you can install multiple
daniel@53 139 # versions side-by-site and run old versions at any time by starting
daniel@53 140 # $libdir/swipl-<version>/bin/$arch/swipl. Without, the system is always
daniel@53 141 # at a nice stable place, so external foreign objects linked against the
daniel@53 142 # binary need not be updated with a Prolog update.
daniel@53 143 #
daniel@53 144 # --enable-shared
daniel@53 145 # Use this to create a shared object for the Prolog kernel. The default
daniel@53 146 # depends on the platform. Creating a shared object is the default on
daniel@53 147 # most platforms, either because it is needed or because it does no
daniel@53 148 # harm. The only exception to this rule is Linux on x86 (Intel 32-bit).
daniel@53 149 # It is not needed on this platform and Linux shared object model costs
daniel@53 150 # a CPU register. Given the limited number of CPU registers on the x86
daniel@53 151 # platform, this results in a performance degradation of about 10%.
daniel@53 152
daniel@53 153 # EXTRACFG+=" --link"
daniel@53 154 # EXTRACFG+=" --enable-useprofile"
daniel@53 155 # EXTRACFG+=" --disable-libdirversion"
daniel@53 156 # EXTRACFG+=" --enable-shared"
daniel@53 157 export EXTRACFG
daniel@53 158
daniel@53 159 # One possiblity to make relocatable executables on Linux is by using
daniel@53 160 # the RPATH mechanism. See ld.so(1) and chrpath(1). However, chrpath
daniel@53 161 # cannot enlarge the path. Uncommenting the line below adds :xxx... to
daniel@53 162 # the RPATH, where the given count is the number of x-s.
daniel@53 163 #
daniel@53 164 # export RPATH_RESERVE=70
daniel@53 165
daniel@53 166 ################################################################
daniel@53 167 # No edit should be needed below this line
daniel@53 168 ################################################################
daniel@53 169
daniel@53 170 V=`cat VERSION`
daniel@53 171 config=true
daniel@53 172 make=true
daniel@53 173 install=true
daniel@53 174 done=false
daniel@53 175 setvars=false
daniel@53 176
daniel@53 177 while test "$done" = false; do
daniel@53 178 case "$1" in
daniel@53 179 --config) make=false
daniel@53 180 install=false
daniel@53 181 shift
daniel@53 182 ;;
daniel@53 183 --make) config=false
daniel@53 184 install=false
daniel@53 185 shift
daniel@53 186 ;;
daniel@53 187 --install) config=false
daniel@53 188 make=false
daniel@53 189 shift
daniel@53 190 ;;
daniel@53 191 --prefix=*) PREFIX=`echo "$1" | sed 's/--prefix=//'`
daniel@53 192 shift
daniel@53 193 ;;
daniel@53 194 --setvars) setvars=true
daniel@53 195 shift
daniel@53 196 ;;
daniel@53 197 *) done=true
daniel@53 198 ;;
daniel@53 199 esac
daniel@53 200 done
daniel@53 201
daniel@53 202 if [ "$setvars" = "false" ]; then
daniel@53 203 rm -f packages/.failed.*
daniel@53 204
daniel@53 205 if [ "$config" = "true" ]; then
daniel@53 206 ./configure --prefix=$PREFIX --with-world $EXTRACFG $@ 2>&1 | tee configure.out
daniel@53 207 if [ "${PIPESTATUS[0]}" != 0 ]; then exit 1; fi
daniel@53 208 fi
daniel@53 209
daniel@53 210 if [ "$make" = "true" ]; then
daniel@53 211 $MAKE $@ 2>&1 | tee make.out
daniel@53 212 if [ "${PIPESTATUS[0]}" != 0 ]; then exit 1; fi
daniel@53 213 fi
daniel@53 214
daniel@53 215 if [ "$install" = "true" ]; then
daniel@53 216 $SUDO $MAKE install $@ 2>&1 | tee make-install.out
daniel@53 217 if [ "${PIPESTATUS[0]}" != 0 ]; then exit 1; fi
daniel@53 218 fi
daniel@53 219
daniel@53 220 if [ -z "$DESTDIR" ]; then
daniel@53 221 make check-installation
daniel@53 222 fi
daniel@53 223
daniel@53 224 # Parse build log for warnings that may indicate serious runtime issues
daniel@53 225 if [ "$make" = "true" ]; then
daniel@53 226 [ -f make.out ] && scripts/check_build_log.sh make.out
daniel@53 227 fi
daniel@53 228
daniel@53 229 # See whether any package failed to build
daniel@53 230 ./packages/report-failed || exit 1
daniel@53 231 fi # setvars
daniel@53 232