forked from SWI-Prolog/swipl-devel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.templ
executable file
·264 lines (226 loc) · 9.52 KB
/
build.templ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#!/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/swipl-<version> and create symlinks from $PREFIX/bin for
# the main programs. Users can always use older versions by running
# $PREFIX/lib/swipl-<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=$HOME
SUDO=
#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. Unfortunately, not all dependencies
# are covered by the Makefiles. If your build fails on what might be a
# missing dependency, try re-running without --jobs and report the
# issue.
# 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 -fno-strict-aliasing -gdwarf-2 -g3"
# export CMFLAGS=
# export CIFLAGS=
# export LDFLAGS="-O2 -g"
# On MacOS you need this to get some libraries from Macports. There are
# three commonly used C compilers on the Mac: gcc (based on llvm) and
# clang that come with XCode and (native) gcc from Macports. The current
# SWI-Prolog sources compile and work with all these alternatives. There
# are a few gotchas:
#
# - The ssl package uses the Apple security API that can only be
# compiled using the XCode compilers. Compiled with native
# gcc SSL has no access to the OS root certificates and can only
# be used without certificate validation or with certificates
# explicitly provided by the user.
# - 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). You could compile SSL using
# the XCode compiler.
#
# 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 you use HomeBrew as your Mac OS package manager, uncomment the
# following line to use the default installation locations for shared
# libraries and header files.
# USE_HOMEBREW=yes
if [ "`uname`" = Darwin ]; then
if [ "x$USE_HOMEBREW" = xyes ]; then
export LIBRARY_PATH=/usr/local/lib:/usr/lib
export CPATH=/usr/local/include:/usr/include:/opt/X11/include
else
export LIBRARY_PATH=/usr/lib:/opt/local/lib:/opt/local/lib/db60
export CPATH=/usr/include:/opt/local/include:/opt/local/include/db60:/opt/X11/include
fi
export PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig:/opt/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
if [ -f "$JAVA_HOME/bin/java" ]; then
export JAVAPREFIX="$JAVA_HOME/bin"
elif [ -f /usr/libexec/java_home ]; then
export JAVAPREFIX=$(/usr/libexec/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'
# [EDIT] Open OpenBSD, the following are needed to fetch the required
# non-default dependencies. Using "CC=cc" the preferred clang compiler
# is used. SWI-Prolog compiles both with clang and gcc.
# export CC=cc
# export CIFLAGS="-I/usr/local/include"
# export LDFLAGS="-O2 -g -L/usr/local/lib"
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="jpl ssl odbc utf8proc"
# [EDIT] Packages to add.
# export EXTRA_PKGS="bdb 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 ] && bash scripts/check_build_log.sh make.out
fi
# See whether any package failed to build
bash packages/report-failed || exit 1
fi # setvars