2
#########################################################################
4
# bootstrap.sh is automatically generated, #
5
# please do not modify! #
7
#########################################################################
9
#########################################################################
11
# Script ID: bootstrap.sh #
12
# Author: Copyright (C) 2014-2018 Mark Grant #
14
# Released under the GPLv3 only. #
15
# SPDX-License-Identifier: GPL-3.0 #
18
# To simplify the AutoTools distribution build. #
20
# Syntax: bootstrap.sh [ -c || --distcheck ] || #
21
# [ -d || --debug ] || #
22
# [ -D || --dist ] || #
23
# [ -f || --distcheckfake ] || #
24
# [ -g || --gnulib ] || #
25
# [ -h || --help ] || #
26
# [ -m || --make ] || #
27
# [ -s || --sparse ] || #
28
# [ -t || --source-tarball ] || #
29
# [ -V || --version-V ] #
31
# Exit Codes: 0 - success #
36
#########################################################################
38
#########################################################################
42
# Date Author Version Description #
44
# 25/06/2014 MG 1.0.1 Created. #
45
# 02/08/2014 MG 1.0.2 Change naming from AutoTools to #
46
# AutoConf and Make. #
47
# 27/10/2014 MG 1.0.3 Seperated each command in order to test #
49
# 13/11/2014 MG 1.0.4 Switched from getopts to GNU getopt to #
50
# allow long options. #
51
# 16/11/2014 MG 1.0.5 Modify getopt processing to allow for #
52
# FreeBSD's quirk of 2 different getopt #
53
# programs. See comments at the start of #
55
# 16/11/2014 MG 1.0.6 Remove erroneous option. #
56
# 18/11/2014 MG 1.0.7 Change FreeBSD specifics to *BSD and #
57
# change Linux to be the default. #
58
# 24/11/2014 MG 1.0.8 Add overall package version to -V. #
59
# 28/03/2015 MG 1.0.9 Remove BSD support. #
60
# 31/01/2017 MG 1.1.1 Add debug make dist and make options. #
61
# 25/02/2017 MG 1.2.0 Add distcheck & distcheckfake options. #
62
# 25/06/2017 MG 1.2.1 Enforce 80 column rule. #
63
# 01/12/2017 MG 1.2.2 Add SPDX license tags to source files. #
64
# 04/12/2017 MG 1.2.3 Adopt standard exit codes; 0 on success #
66
# 06/02/2018 MG 1.3.1 Renamed from acmbuild. #
68
# General script tidy up. #
69
# 09/02/2018 MG 1.3.2 Remove script name from -V --version #
70
# print as this may have been invoked by #
72
# 24/03/2018 MG 1.3.3 Add support for sparse CLA. #
73
# Add stderr log file. #
74
# 07/04/2018 MG 1.3.4 Add -t --source-tarball CLA to build a #
77
#########################################################################
83
version="1.3.4" # set version variable
84
packageversion=v1.2.7 # Version of the complete package
102
# Output $1 to stdout or stderr depending on $2.
113
# Standard function to test command error ($1 is $?) and exit if non-zero
114
std_cmd_err_handler()
123
# Standard function to cleanup and return exit code
126
exit $script_exit_code
129
# Standard trap exit function
133
output "Script terminating due to trap received." 1
138
trap trap_exit SIGHUP SIGINT SIGTERM
143
# Process command line arguments with GNU getopt.
144
tmp="getopt -o cdDfghmstV "
145
tmp+="--long distcheck,debug,dist,distcheckfake,gnulib,help,make,sparse,"
146
tmp+="source-tarball,version "
148
GETOPTTEMP=`eval $tmp`
149
eval set -- "$GETOPTTEMP"
150
std_cmd_err_handler $?
157
if [ $dist = TRUE -o $distcheckfake = TRUE -o $make = TRUE \
161
msg="Options c, D, f, m and t are mutually exclusive."
169
debug=" --enable-debug=yes"
173
if [ $distcheck = TRUE -o $distcheckfake = TRUE \
174
-o $make = TRUE -o $tarball = TRUE ]
177
msg="Options c, D, f, m and t are mutually exclusive."
185
if [ $distcheck = TRUE -o $dist = TRUE -o $make = TRUE \
189
msg="Options c, D, f, m and t are mutually exclusive."
202
echo " -c or --distcheck perform normal distcheck"
203
echo " -d or --debug build with appropriate debug flags"
204
echo " -D or --dist perform a make dist"
205
echo " -f or --distcheckfake fake a distcheck for fixed root"
206
echo " -g or --gnulib run gnulib-tool --update"
207
echo " -h or --help displays usage information"
208
echo " -m or --make compile and link - plain make"
209
echo " -s or --sparse build using sparse"
210
echo " -t or --source-tarball create source tarball"
211
echo " -V or --version displays version information"
217
if [ $distcheck = TRUE -o $dist = TRUE \
218
-o $distcheckfake = TRUE -o $tarball = TRUE ]
221
msg="Options c, D, f, m and t are mutually exclusive."
229
sparse=" --enable-sparse=yes"
233
if [ $distcheck = TRUE -o $dist = TRUE \
234
-o $distcheckfake = TRUE -o $make = TRUE ]
237
msg="Options c, D, f, m and t are mutually exclusive."
245
echo "Script version "$version
246
echo "Package version "$packageversion
254
*) script_exit_code=1
255
output "Internal error." 1
261
# Script can accept 1 other argument, the base directory.
265
output "Invalid argument." 1
274
# One option has to be selected.
275
if [ $distcheck = FALSE -a $dist = FALSE -a $distcheckfake = FALSE \
276
-a $make = FALSE -a $tarball = FALSE ]
279
output "Either c, D, f, m or t must be set." 1
283
# Create build error log.
284
exec 2> >(tee build-stderr.txt >&2)
287
# Now the main processing.
288
if [ $gnulib = TRUE ]
290
if [ -f $basedir/m4/gnulib-cache.m4 ]
292
cmdline="gnulib-tool --update --quiet --quiet --dir="$basedir
295
output "$cmdline completed with exit status: $status" $status
296
std_cmd_err_handler $status
298
msg="Option -g --gnulib ignored - "
299
msg+="missing $basedir/m4/gnulib-cache.m4"
304
autoreconf -if $basedir
306
output "autoreconf -if "$basedir" completed with exit status: $status" $status
307
std_cmd_err_handler $status
309
cmdline=$basedir"/configure --enable-silent-rules=yes"$debug$sparse
311
if [ $distcheckfake = TRUE ]
313
cmdline=$cmdline" --enable-distcheckfake=yes"
318
output "$cmdline completed with exit status: $status" $status
319
std_cmd_err_handler $status
321
cmdline="make --quiet"
322
if [ $distcheck = TRUE ]
324
cmdline=$cmdline" distcheck distclean"
329
cmdline=$cmdline" dist clean distclean"
332
if [ $distcheckfake = TRUE ]
334
cmdline=$cmdline" distcheck distclean"
335
cmdline=$cmdline" DISTCHECK_CONFIGURE_FLAGS=--enable-distcheckfake=yes"
338
if [ $tarball = TRUE ]
340
cmdline=$cmdline" srctarball distclean"
345
output "$cmdline completed with exit status: $status" $status
346
std_cmd_err_handler $status