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 samer@75: # $PREFIX/lib/swipl- and create symlinks from $PREFIX/bin for samer@75: # the main programs. Users can always use older versions by running samer@75: # $PREFIX/lib/swipl-/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 samer@75: #SUDO= 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 samer@75: # depends a lot on your hardware. Unfortunately, not all dependencies samer@75: # are covered by the Makefiles. If your build fails on what might be a samer@75: # missing dependency, try re-running without --jobs and report the samer@75: # issue. daniel@53: samer@75: # MAKE=make samer@75: MAKE='make --jobs=8' 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: samer@75: # On MacOS you need this to get some libraries from Macports. There are samer@75: # three commonly used C compilers on the Mac: gcc (based on llvm) and samer@75: # clang that come with XCode and (native) gcc from Macports. The current samer@75: # SWI-Prolog sources compile and work with all these alternatives. There samer@75: # are a few gotchas: samer@75: # samer@75: # - The ssl package uses the Apple security API that can only be samer@75: # compiled using the XCode compilers. Compiled with native samer@75: # gcc SSL has no access to the OS root certificates and can only samer@75: # be used without certificate validation or with certificates samer@75: # explicitly provided by the user. samer@75: # - If you want the last bit of performance and don't mind some extra samer@75: # work, get a recent native GCC, set CC below and enable samer@75: # --enable-useprofile (see below). You could compile SSL using samer@75: # the XCode compiler. 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: samer@75: # If you use HomeBrew as your Mac OS package manager, uncomment the samer@75: # following line to use the default installation locations for shared samer@75: # libraries and header files. samer@75: samer@75: # USE_HOMEBREW=yes samer@75: daniel@53: if [ "`uname`" = Darwin ]; then samer@75: if [ "x$USE_HOMEBREW" = xyes ]; then samer@75: echo USING HOMEBREW PATHS samer@75: export LIBRARY_PATH=/usr/local/lib:/usr/lib samer@75: export CPATH=/usr/local/include:/usr/include:/opt/X11/include samer@75: else samer@75: echo USING MACPORTS PATHS samer@75: export LIBRARY_PATH=/usr/lib:/opt/local/lib:/opt/local/lib/db60 samer@75: export CPATH=/usr/include:/opt/local/include:/opt/local/include/db60:/opt/X11/include samer@75: fi samer@75: samer@75: export PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig:/opt/local/lib/pkgconfig:/opt/X11/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. samer@75: export DISABLE_PKGS="jasmine R PDT tipc jpl" daniel@53: daniel@53: # [EDIT] Packages to add. daniel@53: # export EXTRA_PKGS="db ltx2htm space" samer@75: export EXTRA_PKGS="bdb" 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: