annotate src/swipl/build @ 100:a4cd935561d4 dml-dockerised tip

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