forked from mighty-gerbils/gerbil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·231 lines (189 loc) · 5.56 KB
/
configure
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
#!/bin/sh
set -e
cd $(dirname "$0")
die() {
echo "configuration failed"
exit 1
}
usage() {
local gambit_config_help="$(cd src/gambit && ./configure --help | tail -n +63)"
cat <<EOF
This script configures the Gerbil and integrated Gambit build.
Usage: $0 [option] ... [var=value]...
Options controlling integrated Gambit configuration:
${gambit_config_help}
Options understood and processed by Gerbil:
--prefix=PREFIX where to install Gerbil; default prefix is /opt/gerbil
--with-gambit=TAG integrated gambit git tag to check out for the build;
defaults to ${default_gambit_tag}
--enable-march=ARCH specify the machine architecture; it can be empty.
defaults to native
--enable-shared[=no] do (not) use shared libraries for libgerbil and libgambit
--disable-shared default is to enable shared libraries
Gerbil Standard Library features:
--enable-deprecated Enable building of deprecated packages; disabled by default
--enable-zlib Enable or disable zlib support; enabled by default
--disable-zlib
--enable-sqlite Enable or disable sqlite support; enabled by default
--disable-sqlite
Default integrated Gambit configuration: ${default_gambit_config}
EOF
}
std_patch_feature() {
sed -i -e "$1" src/std/build-features.ss
}
std_enable_feature() {
std_patch_feature "s/$1 #f/$1 #t/"
}
std_disable_feature() {
std_patch_feature "s/$1 #t/$1 #f/"
}
package_out_of_tree() {
local pkg="$1"
echo "*** ERROR package ${pkg} has been moved out of the master Gerbil tree"
echo "It is now available as an external package: github.com/mighty-gerbils/gerbil-${pkg}"
}
readonly gerbil_version="$(git describe --tags --always)"
readonly gerbil_targets=""
readonly default_gambit_tag=24201248effa23d5017be4992b5b9879e4cd3a4c
readonly default_gambit_config="--enable-targets=${gerbil_targets} --enable-single-host --enable-dynamic-clib --enable-default-runtime-options=tE8,f8,-8 --enable-trust-c-tco"
prefix="/opt/gerbil"
readonly cflags_opt="-foptimize-sibling-calls"
readonly ldflags_rpath="-Wl,-rpath"
if [ $(uname) = "Darwin" ];
then
readonly rpath_sep=","
else
readonly rpath_sep="="
fi
case $(uname) in
OpenBSD)
gambit_march=""
;;
*)
gambit_march="native"
;;
esac
gerbil_shared=t
gambit_tag="${default_gambit_tag}"
gambit_config="${default_gambit_config}"
gambit_shared="--enable-shared"
while [ $# -gt 0 ]; do
case "$1" in
--help)
usage
exit 0
;;
--prefix=*)
prefix=$(echo "$1" | cut -d = -f 2-)
shift
;;
--with-gambit=*)
gambit_tag=$(echo "$1" | cut -d = -f 2-)
shift
;;
--enable-march=*)
gambit_march=$(echo "$1" | cut -d = -f 2-)
shift
;;
--enable-shared)
gerbil_shared=t
gambit_shared="--enable-shared"
shift
;;
--disable-shared|--enable-shared=no)
gerbil_shared=f
unset gambit_shared
shift
;;
--enable-deprecated)
std_enable_feature deprecated
shift
;;
--enable-zlib)
std_enable_feature zlib
shift
;;
--disable-zlib)
std_disable_feature zlib
shift
;;
--enable-sqlite)
std_enable_feature sqlite
shift
;;
--disable-sqlite)
std_disable_feature sqlite
shift
;;
--*-libxml)
package_out_of_tree libxml
exit 42
;;
--*-libyaml)
package_out_of_tree libyaml
exit 42
;;
--*-mysql)
package_out_of_tree mysql
exit 42
;;
--*-lmdb)
package_out_of_tree lmdb
exit 42
;;
--*-leveldb)
package_out_of_tree leveldb
exit 42
;;
CFLAGS=*)
flags=$(echo "$1" | cut -d = -f 2-)
if [ -z "$CFLAGS" ]; then
CFLAGS="$flags"
else
CFLAGS="$CFLAGS $flags"
fi
shift
;;
LDFLAGS=*)
flags=$(echo "$1" | cut -d = -f 2-)
if [ -z "${LDFLAGS}" ]; then
LDFLAGS="${flags}"
else
LDFLAGS="${LDFLAGS} ${flags}"
fi
shift
;;
*)
gambit_config="${gambit_config} $1"
shift
;;
esac
done
gerbil_prefix="${prefix}/${gerbil_version}"
if [ -z "${CFLAGS}" ]; then
CFLAGS="${cflags_opt}"
else
CFLAGS="${CFLAGS} ${cflags_opt}"
fi
if [ -z "${LDFLAGS}" ]; then
if [ "${gerbil_shared}" = "t" ]; then
LDFLAGS="${ldflags_rpath}$rpath_sep${gerbil_prefix}/lib"
fi
else
if [ "${gerbil_shared}" = "t" ]; then
LDFLAGS="${LDFLAGS} ${ldflags_rpath}$rpath_sep${gerbil_prefix}/lib"
fi
fi
git submodule init || die
git submodule update --force || die
(cd src/gambit && git fetch origin && git checkout "${gambit_tag}" && touch configure config.status) || die
gambit_config="--prefix=${gerbil_prefix} --enable-march=${gambit_march} ${gambit_shared} ${gambit_config}"
(export LDFLAGS="$LDFLAGS"; export CFLAGS="$CFLAGS"; cd src/gambit && ./configure $gambit_config ) || die
rm -f build-env.sh
cat > build-env.sh <<EOF
GERBIL_PREFIX=${gerbil_prefix}
GERBIL_VERSION=${gerbil_version}
export GERBIL_PREFIX GERBIL_VERSION
EOF
exit 0