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
|
#! /usr/bin/env bash
#########################################################################
# #
# bootstrap.sh is automatically generated, #
# please do not modify! #
# #
#########################################################################
#########################################################################
# #
# Script ID: bootstrap.sh #
# Author: Copyright (C) 2014-2018 Mark Grant #
# #
# Released under the GPLv3 only. #
# SPDX-License-Identifier: GPL-3.0 #
# #
# Purpose: #
# To simplify the AutoTools distribution build. #
# #
# Syntax: bootstrap.sh [ -b || --build ] || #
# [ -c || --config ] || #
# [ -C || --distcheck ] || #
# [ -d || --debug ] || #
# [ -D || --dist ] || #
# [ -F || --distcheckfake ] || #
# [ -g || --gnulib ] || #
# [ -h || --help ] || #
# [ -H || --header-check ] || #
# [ -s || --sparse ] || #
# [ -T || --source-tarball ] || #
# [ -v || --verbose ] || #
# [ -V || --version ] #
# #
# Exit Codes: 0 - success #
# 1 - failure. #
# #
# Further Info: #
# #
#########################################################################
#########################################################################
# #
# Changelog #
# #
# Date Author Version Description #
# #
# 25/06/2014 MG 1.0.1 Created. #
# 02/08/2014 MG 1.0.2 Change naming from AutoTools to #
# AutoConf and Make. #
# 27/10/2014 MG 1.0.3 Seperated each command in order to test #
# exit status. #
# 13/11/2014 MG 1.0.4 Switched from getopts to GNU getopt to #
# allow long options. #
# 16/11/2014 MG 1.0.5 Modify getopt processing to allow for #
# FreeBSD's quirk of 2 different getopt #
# programs. See comments at the start of #
# "Main" #
# 16/11/2014 MG 1.0.6 Remove erroneous option. #
# 18/11/2014 MG 1.0.7 Change FreeBSD specifics to *BSD and #
# change Linux to be the default. #
# 24/11/2014 MG 1.0.8 Add overall package version to -V. #
# 28/03/2015 MG 1.0.9 Remove BSD support. #
# 31/01/2017 MG 1.1.1 Add debug make dist and make options. #
# 25/02/2017 MG 1.2.0 Add distcheck & distcheckfake options. #
# 25/06/2017 MG 1.2.1 Enforce 80 column rule. #
# 01/12/2017 MG 1.2.2 Add SPDX license tags to source files. #
# 04/12/2017 MG 1.2.3 Adopt standard exit codes; 0 on success #
# 1 on failure. #
# 06/02/2018 MG 1.3.1 Renamed from acmbuild. #
# Add -g option. #
# General script tidy up. #
# 09/02/2018 MG 1.3.2 Remove script name from -V --version #
# print as this may have been invoked by #
# acmbuild.sh. #
# 24/03/2018 MG 1.3.3 Add support for sparse CLA. #
# Add stderr log file. #
# 07/04/2018 MG 1.3.4 Add -t --source-tarball CLA to build a #
# source tarball. #
# 01/07/2018 MG 1.3.5 Separate configure from build actions #
# and make options more standardised. #
# 06/08/2018 MG 1.3.6 Add -H --header-check option. #
# Change error log file to build log. #
# 22/08/2018 MG 1.3.7 Add verbose option. #
# #
#########################################################################
##################
# Init variables #
##################
script_exit_code=0
version="1.3.7" # set version variable
packageversion=v1.2.11 # Version of the complete package
# Set defaults
build=FALSE
config=FALSE
debug=""
dist=FALSE
distcheck=FALSE
distcheckfake=FALSE
gnulib=FALSE
headercheck=""
sparse=""
tarball=FALSE
verbose=FALSE
verboseconfig=" --enable-silent-rules=yes"
verbosemake=" --quiet"
basedir="."
cmdline=""
#############
# Functions #
#############
# Output $1 to stdout or stderr depending on $2.
output()
{
if [ $2 = 0 ]
then
echo "$1"
else
echo "$1" 1>&2
fi
}
# Standard function to test command error ($1 is $?) and exit if non-zero
std_cmd_err_handler()
{
if [ $1 != 0 ]
then
script_exit_code=$1
script_exit
fi
}
# Standard function to cleanup and return exit code
script_exit()
{
exit $script_exit_code
}
# Standard trap exit function
trap_exit()
{
script_exit_code=1
output "Script terminating due to trap received." 1
script_exit
}
# Setup trap
trap trap_exit SIGHUP SIGINT SIGTERM
########
# Main #
########
# Process command line arguments with GNU getopt.
tmp="getopt -o bcCdDFghHsTvV "
tmp+="--long build,config,distcheck,debug,dist,distcheckfake,gnulib,help,"
tmp+="header-check,sparse,source-tarball,verbose,version "
tmp+="-n $0 -- $@"
GETOPTTEMP=`eval $tmp`
eval set -- "$GETOPTTEMP"
std_cmd_err_handler $?
while true
do
case "$1" in
-b|--build)
if [ $distcheck = TRUE -o $dist = TRUE \
-o $distcheckfake = TRUE -o $tarball = TRUE ]
then
script_exit_code=1
msg="Options b, C, D, F and T are mutually exclusive."
output "$msg" 1
script_exit
fi
build=TRUE
shift
;;
-c|--config)
config=TRUE
shift
;;
-C|--distcheck)
if [ $build = TRUE -o $dist = TRUE -o $distcheckfake = TRUE \
-o $tarball = TRUE ]
then
script_exit_code=1
msg="Options b, C, D, F and T are mutually exclusive."
output "$msg" 1
script_exit
fi
distcheck=TRUE
shift
;;
-d|--debug)
debug=" --enable-debug=yes"
shift
;;
-D|--dist)
if [ $build = TRUE -o $distcheck = TRUE \
-o $distcheckfake = TRUE -o $tarball = TRUE ]
then
script_exit_code=1
msg="Options b, C, D, F and T are mutually exclusive."
output "$msg" 1
script_exit
fi
dist=TRUE
shift
;;
-F|--distcheckfake)
if [ $build = TRUE -o $distcheck = TRUE -o $dist = TRUE \
-o $tarball = TRUE ]
then
script_exit_code=1
msg="Options b, C, D, F and T are mutually exclusive."
output "$msg" 1
script_exit
fi
distcheckfake=TRUE
shift
;;
-g|--gnulib)
gnulib=TRUE
shift
;;
-h|--help)
echo "Usage is:-"
echo " -b or --build make the project"
echo " -c or --config congigure the project"
echo " -C or --distcheck perform normal distcheck"
echo " -d or --debug build with appropriate debug flags"
echo " -D or --dist perform a make dist"
echo " -F or --distcheckfake fake a distcheck for fixed root"
echo " -g or --gnulib run gnulib-tool --update"
echo " -h or --help displays usage information"
echo " -H or --header-check show include stack depth"
echo " -s or --sparse build using sparse"
echo " -T or --source-tarball create source tarball"
echo " -v or --verbose emit extra information"
echo " -V or --version displays version information"
shift
script_exit_code=0
script_exit
;;
-H|--header-check)
headercheck=" --enable-headercheck=yes"
shift
;;
-s|--sparse)
sparse=" --enable-sparse=yes"
shift
;;
-T|--source-tarball)
if [ $build = TRUE -o $distcheck = TRUE -o $dist = TRUE \
-o $distcheckfake = TRUE ]
then
script_exit_code=1
msg="Options b, C, D, F and T are mutually exclusive."
output "$msg" 1
script_exit
fi
tarball=TRUE
shift
;;
-v|--verbose)
verbose=TRUE
verboseconfig=""
verbosemake=""
shift
;;
-V|--version)
echo "Script version "$version
echo "Package version "$packageversion
shift
script_exit_code=0
script_exit
;;
--) shift
break
;;
*) script_exit_code=1
output "Internal error." 1
script_exit
;;
esac
done
if [ "$debug" != "" -o $distcheckfake = TRUE -o "$headercheck" != "" \
-o "$sparse" != "" -o "$verbose" = TRUE ]
then
if [ $config = FALSE ]
then
script_exit_code=1
msg="Options d, F, H, s and v require option c."
output "$msg" 1
script_exit
fi
fi
# One option has to be selected.
if [ $build = FALSE -a $config = FALSE -a $distcheck = FALSE -a $dist = FALSE \
-a $distcheckfake = FALSE -a $gnulib = FALSE -a $tarball = FALSE ]
then
script_exit_code=1
output "Either b, c, C, D, F, g or T must be set." 1
script_exit
fi
# Script can accept 1 other argument, the base directory.
if [ $# -gt 1 ]
then
script_exit_code=1
output "Invalid argument." 1
script_exit
fi
if [ $# -eq 1 ]
then
basedir=$1
fi
# Create build log.
exec 1> >(tee build-output.txt) 2>&1
# Now the main processing.
if [ $gnulib = TRUE ]
then
if [ -f $basedir/m4/gnulib-cache.m4 ]
then
cmdline="gnulib-tool --update"$verbosemake$verbosemake
cmdline+=" --dir="$basedir
eval "$cmdline"
status=$?
output "$cmdline completed with exit status: $status" $status
std_cmd_err_handler $status
else
msg="Option -g --gnulib ignored - "
msg+="missing $basedir/m4/gnulib-cache.m4"
output "$msg" 0
fi
fi
if [ $config = TRUE ]
then
autoreconf -if $basedir
status=$?
msg="autoreconf -if "$basedir" completed with exit status: $status"
output "$msg" $status
std_cmd_err_handler $status
cmdline=$basedir"/configure"$verboseconfig$debug$headercheck$sparse
if [ $distcheckfake = TRUE ]
then
cmdline=$cmdline" --enable-distcheckfake=yes"
fi
eval "$cmdline"
status=$?
output "$cmdline completed with exit status: $status" $status
std_cmd_err_handler $status
fi
cmdline=""
if [ $build = TRUE ]
then
cmdline="make"$verbosemake
fi
if [ $distcheck = TRUE ]
then
cmdline="make"$verbosemake" distcheck clean"
fi
if [ $dist = TRUE ]
then
cmdline="make"$verbosemake" dist clean"
fi
if [ $distcheckfake = TRUE ]
then
cmdline="make"$verbosemake" distcheck clean"
cmdline=$cmdline" DISTCHECK_CONFIGURE_FLAGS=--enable-distcheckfake=yes"
fi
if [ $tarball = TRUE ]
then
cmdline="make"$verbosemake" srctarball clean"
fi
# May get here with cmdline empty if, for example, only the -g option was set.
if [ "$cmdline" != "" ]
then
eval "$cmdline"
status=$?
output "$cmdline completed with exit status: $status" $status
std_cmd_err_handler $status
fi
script_exit_code=0
script_exit
|