-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathautogen-all-variants.sh
executable file
·487 lines (434 loc) · 12 KB
/
autogen-all-variants.sh
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
#!/usr/bin/env bash
#
# Project : ipv6calc
# File : autogen-all-variants.sh
# Copyright : 2011-2025 by Peter Bieringer <pb (at) bieringer.de>
#
# Information: run autogen.sh with all supported variants
#
# history: can run also through various version of GeoIP (-g) and IP2Location (-i) libraries
# see autogen-support.sh for details
status_file="autogen-all-variants.status"
## Generate configure variants
autogen_variants() {
autogen_variants_list
autogen_variants_list | while IFS="#" read token options testlist; do
options_extra=""
if [[ $token =~ APACHE ]]; then
# https://github.com/pbiering/ipv6calc/issues/45
options_extra=" --disable-mod_ipv6calc"
fi
echo "$token#${options:+$options } --clang$options_extra#$testlist"
done
case "$OSTYPE" in
freebsd*)
# skip 32-bit builds on FreeBSD
return
;;
esac
if [ -e /etc/os-release ]; then
source /etc/os-release
fi
skip32=""
el=""
if [ -n "$VERSION_ID" ]; then
if [ -n "$ID_LIKE" ]; then
if [[ $ID_LIKE =~ (rhel|centos) ]]; then
el=1
if [ ${VERSION_ID/.*} -ge 9 ]; then
# skip 32-bit builds on Enterprise Linux 9+
skip32=1
fi
fi
fi
if [ -n "$ID" ]; then
if [[ $ID =~ (rhel|centos|almalinux) ]]; then
el=1
if [ ${VERSION_ID/.*} -ge 9 ]; then
# skip 32-bit builds on Enterprise Linux 9+
skip32=1
fi
fi
fi
fi
if [ "$skip32" = 1 ]; then
return
fi
# 32-bit builds
autogen_variants_list | while IFS="#" read token options testlist; do
if [ "$el" = 1 ]; then
if [[ $token =~ IP2LOCATION ]]; then
# skip 32-bit builds on Enterprise Linux as IP2Location devel is not built for i686 on EPEL
continue
fi
fi
echo "$token#${options:+$options } --m32#$teslist"
done
# 32-bit builds with clang
autogen_variants_list | while IFS="#" read token options testlist; do
if [[ $token =~ APACHE ]]; then
# https://github.com/pbiering/ipv6calc/issues/45
options_extra=" --disable-mod_ipv6calc"
fi
if [ "$el" = 1 ]; then
if [[ $token =~ IP2LOCATION ]]; then
# skip 32-bit builds on Enterprise Linux as IP2Location devel is not built for i686 on EPEL
continue
fi
fi
echo "$token#${options:+$options } --clang --m32$options_extra#$testlist"
done
}
autogen_variants_list() {
if ! $skip_main_test; then
cat <<END | grep -v ^#
NONE#
NONE#--external
BUNDLED#--enable-bundled-md5 --enable-bundled-getopt
OPENSSL#--enable-openssl-md5 --no-static-build
OPENSSL#--enable-openssl-evp-md5
LIBMD#--enable-libmd-md5 --no-static-build
IP2LOCATION#-i
IP2LOCATION#-I
GEOIP2 DBIP2 IP2LOCATION2#-m
GEOIP2 DBIP2 IP2LOCATION2#-M
GEOIP2#-m --disable-dbip2
GEOIP2#-M --disable-dbip2
GEOIP2#-m --disable-dbip2 --disable-ip2location2
GEOIP2#-M --disable-dbip2 --disable-ip2location2
GEOIP2#-m --disable-ip2location2
GEOIP2#-M --disable-ip2location2
DBIP2#-m --disable-geoip2
DBIP2#-M --disable-geoip2
DBIP2#-m --disable-geoip2 --disable-ip2location2
DBIP2#-M --disable-geoip2 --disable-ip2location2
DBIP2#-m --disable-ip2location2
DBIP2#-M --disable-ip2location2
IP2LOCATION2#-m --disable-dbip2
IP2LOCATION2#-M --disable-dbip2
IP2LOCATION2#-m --disable-dbip2 --disable-geoip2
IP2LOCATION2#-M --disable-dbip2 --disable-geoip2
IP2LOCATION2#-m --disable-geoip2
IP2LOCATION2#-M --disable-geoip2
APACHE IP2LOCATION GEOIP2 DBIP2 IP2LOCATION2#-a
APACHE IP2LOCATION GEOIP2 DBIP2 IP2LOCATION2#-A
NONE#--disable-db-ieee
NONE#--disable-db-ipv4
NONE#--disable-db-ipv6
NONE#--disable-db-ipv6 --disable-db-ipv4
NONE#--disable-db-ipv6 --disable-db-ipv4 --disable-db-ieee
NONE#--disable-db-ipv6 --disable-db-ipv4 --disable-db-ieee --disable-as-registry
NONE#--disable-db-ipv6 --disable-db-ipv4 --disable-db-ieee --disable-cc-registry
NONE#--disable-db-ipv6 --disable-db-ipv4 --disable-db-ieee --disable-as-registry --disable-cc-registry
NONE#--disable-db-ipv6 --disable-db-ieee
NONE#--disable-db-ipv4 --disable-db-ieee
NONE#--disable-db-builtin
END
fi
if $ip2location_versions_test; then
for version in $ip2location_versions; do
[ ${version:0:1} = "!" ] && continue
local testlist=""
local option=""
for version_test in $ip2location_versions; do
if [ "$dynamic_load" = "1" ]; then
option="--ip2location-dyn"
# unconditionally test all versions
testlist="$testlist I:$version_test"
else
[ ${version_test:0:1} = "!" ] && continue
if ip2location_cross_version_test_blacklist $version $version_test; then
testlist="$testlist I:$version_test"
fi
fi
done
echo "IP2LOCATION#--enable-ip2location $option $(options_from_name_version IP2Location $version)#$testlist"
done
fi
}
help() {
cat <<END
$0
-h|-? this online help
-f force new run, remove status file unconditionally
-r force re-run, after finished one, remove status file
-N add --no-static-build to autogen.sh
-I skip IP2Location builds using system wide available library
-i run through internal defined IP2Location versions
-D enable dynamic library loading in run through versions
-M skip main tests
-T skip "make test"
-n dry-run, show only what would be build
-c cross version test
-b batch test (do not stop on error)
END
}
batch=false
cross_versions_test=false
dry_run=false
dynamic_load=false
force=false
no_static_build=false
rerun=false
skip_main_test=false
skip_make_test=false
skip_shared=false
ip2location_versions_test=false
while getopts ":cbDNMTirIfWn?h" opt; do
case $opt in
'b')
batch=true
;;
'f')
force=true
;;
'r')
rerun=true
;;
'N')
no_static_build=true
;;
'n')
dry_run=true
;;
'M')
skip_main_test=true
;;
'T')
skip_make_test=true
;;
'I')
skip_token="IP2LOCATION"
;;
'i')
ip2location_versions_test=true
skip_shared=true
no_static_build=true
;;
'c')
cross_versions_test=true
;;
'D')
dynamic_load=true
;;
\?|h)
help
exit 1
;;
*)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
shift $[ $OPTIND - 1 ]
source ./autogen-support.sh "source"
if [ -n "$options_add" ]; then
echo "INFO : additional options: $options_add"
fi
if [ -f "$status_file" ] && ! $dry_run; then
echo "INFO : status file found: $status_file"
if $force; then
echo "NOTICE: remove status file (force)"
rm $status_file
else
if grep -q ":END:" $status_file; then
if $rerun; then
echo "NOTICE: all runs successful, option -r given, status file removed (re-run)"
rm $status_file
else
echo "NOTICE: all runs successful, nothing more to do (use -r for force a re-run)"
exit 0
fi
else
if $rerun; then
echo "NOTICE: option -r for forcing a re-run is useless, last run was not finished (use -f)"
exit 0
fi
fi
fi
fi
if ! $dry_run; then
if [ ! -f "$status_file" ]; then
echo "INFO : status file missing, create: $status_file"
date "+%s:START:${batch:+BATCHMODE}" >$status_file
fi
fi
IONICE="ionice -c 3"
if ! $IONICE true; then
echo "NOTICE: disable use of ionice, not supported"
IONICE=""
fi
# variants
for liboption in "normal" "shared"; do
if $skip_shared && [ "$liboption" = "shared" ]; then
continue
fi
autogen_variants | while IFS="#" read token buildoptions testlist; do
case "$OSTYPE" in
freebsd*)
case $token in
BUNDLED)
echo "NOTICE: disable on OSTYPE=$OSTYPE: $buildoptions"
continue
;;
esac
esac
buildoptions=$(echo $buildoptions)
if [ -n "$options_add" ]; then
if $no_static_build; then
options="--no-static-build $options_add $buildoptions"
else
options="${options_add:+$options_add }$buildoptions"
fi
else
if $no_static_build; then
options="--no-static-build $buildoptions"
else
options="$buildoptions"
fi
fi
case $liboption in
shared)
options="${options:+$options }-S"
;;
esac
# extend options in fallback case
if [ -n "$ip2location_options_extra" ]; then
if echo "$token" | grep -Fwq "IP2LOCATION"; then
options="${options:+$options }$ip2location_options_extra"
fi
fi
# check for already executed option combination
if [ -f "$status_file" ]; then
if [ -z "$testlist" ]; then
if grep -Eq ":FINISHED:variants:$options:" $status_file; then
echo "NOTICE: skip variant run (already finished) with: $options"
continue
fi
else
echo "NOTICE: testlist not empty, check dedicated build (testlist: $testlist) with: $options"
fi
fi
if [ -n "$skip_token" ]; then
if echo "$token" | grep -Ewq "$skip_token"; then
echo "NOTICE: skip variant because of token: $token"
if $dry_run; then
date "+%s:FINISHED:variants:$options:SKIPPED" >>$status_file
fi
continue
fi
fi
options_test=""
if $skip_make_test; then
options_test="--no-test"
fi
if $dry_run; then
echo "INFO : would call(dry-run): ./autogen.sh $options_test $options"
if [ -z "$testlist" ]; then
continue
fi
else
# run autogen
echo "INFO : call: ./autogen.sh $options_test $options"
nice -n 20 $IONICE ./autogen.sh $options_test $options
if [ $? -ne 0 ]; then
echo "ERROR : autogen.sh reports an error with options: $options_test $options"
if $batch; then
date "+%s:BROKEN:variants:$options" >>$status_file
else
exit 1
fi
else
# add entry in log
date "+%s:FINISHED:variants:$options:OK" >>$status_file
fi
fi
if [ -n "$testlist" ]; then
for entry in $testlist; do
if grep -Eq ":FINISHED:variants:$options:TESTLIST-ENTRY=$entry" $status_file; then
echo "NOTICE: skip variant test (already finished) with: $options and $entry"
continue
fi
if $dry_run; then
echo "INFO : would call(dry-run): ./autogen.sh $options (testlist entry: $entry)"
continue
fi
name=${entry/:*}
version=${entry/*:}
lib=$(options_from_name_version $name $version "only-lib")
libdir=$(options_from_name_version $name $version "only-libdir")
if [ -z "$lib" ]; then
echo "ERROR : something wrong in call of: options_from_name_version $name $version 'only-lib'"
exit 1
fi
if [ -z "$libdir" ]; then
echo "ERROR : something wrong in call of: options_from_name_version $name $version 'only-libdir'"
exit 1
fi
if [ ! -e "$lib" ]; then
echo "ERROR : library missing: $lib (got from: options_from_name_version $name $version 'only-lib')"
exit 1
fi
if [ ! -d "$libdir" ]; then
echo "ERROR : library directory missing: $libdir (got from: options_from_name_version $name $version 'only-libdir')"
exit 1
fi
if $dynamic_load; then
case $name in
I*)
feature_string="IP2Location"
;;
G*)
feature_string="GeoIP"
;;
esac
# check for feature dynamic load
echo "INFO : call: LD_LIBRARY_PATH=$libdir ./ipv6calc/ipv6calc -v"
if ! LD_LIBRARY_PATH="$libdir" ./ipv6calc/ipv6calc -v 2>&1 | grep version | grep -qw $feature_string; then
echo "ERROR : call has not included required feature string '$feature_string': LD_LIBRARY_PATH=$libdir ./ipv6calc/ipv6calc -v"
exit 1
fi
echo "INFO : call: LD_LIBRARY_PATH=$libdir make test-ldlibpath"
LD_LIBRARY_PATH="$libdir" $MAKE test-ldlibpath
result=$?
else
echo "INFO : call: LD_PRELOAD=$lib make test-ldlibpath"
LD_LIBRARY_PATH="$libdir" $MAKE test-ldlibpath
result=$?
fi
if [ $result -ne 0 ]; then
echo "ERROR : autogen.sh reports an error with options: $options during testlist entry: $entry"
if $dynamic_load; then
echo "NOTICE: executed command: LD_LIBRARY_PATH=$libdir make test-ldlibpath"
else
echo "NOTICE: executed command: LD_PRELOAD="$lib" make test-ldlibpath"
fi
if $batch; then
date "+%s:BROKEN:variants:$options:TESTLIST-ENTRY=$entry" >>$status_file
else
exit 1
fi
else
date "+%s:FINISHED:variants:$options:TESTLIST-ENTRY=$entry" >>$status_file
fi
done
fi
done || exit 1
done
if ! $dry_run; then
if grep -q ":BROKEN:" $status_file; then
echo "ERROR : there are BROKEN builds:"
grep ":BROKEN:" $status_file
exit 1
else
echo "INFO : congratulations, all variants built successful!"
fi
date "+%s:END:" >>$status_file
cat $status_file
$MAKE autoclean >/dev/null
if [ $? -ne 0 ]; then
echo "ERROR : 'make autoclean' failed"
exit 1
fi
fi