~m-grant-prg/dnsmasq-logrotate/stretch

« back to all changes in this revision

Viewing changes to bootstrap.sh

  • Committer: Mark Grant
  • Date: 2020-12-21 11:13:16 UTC
  • mfrom: (43.1.1 stretch-trunk)
  • Revision ID: m.grant.prg@gmail.com-20201221111316-3ukoaigbpxf3bos4
Merge from stretch-trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#                               [ -h || --help ] ||                     #
28
28
#                               [ -H || --header-check ] ||             #
29
29
#                               [ -K || --check ] ||                    #
 
30
#                               [ -p || --parallel-jobs ] ||            #
30
31
#                               [ -s || --sparse ] ||                   #
31
32
#                               [ -t || --testing-hacks ] ||            #
32
33
#                               [ -T || --source-tarball ] ||           #
138
139
# 25/06/2019    MG      1.4.5   Remove distcheckfake option. Now done   #
139
140
#                               by distcheck with configure flags in    #
140
141
#                               top level makefile.                     #
 
142
# 28/10/2019    MG      1.4.6   Move script_exit() before it is used.   #
 
143
#                               Cannot test for existence of file with  #
 
144
#                               a variable which has retained quotes,   #
 
145
#                               so introduce unquoted basedirunq.       #
 
146
# 01/12/2019    MG      1.4.7   Add parallel jobs option to pass to     #
 
147
#                               make as --jobs                          #
141
148
#                                                                       #
142
149
#########################################################################
143
150
 
146
153
# Init variables #
147
154
##################
148
155
 
149
 
readonly version=1.4.5                  # set version variable
150
 
readonly packageversion=1.3.6   # Version of the complete package
 
156
readonly version=1.4.7                  # set version variable
 
157
readonly packageversion=1.3.9   # Version of the complete package
151
158
 
152
159
# Set defaults
153
160
atonly=""
159
166
distcheck=false
160
167
gnulib=false
161
168
headercheck=""
 
169
par_jobs=""
162
170
sparse=""
163
171
tarball=false
164
172
testinghacks=""
165
173
verbose=false
166
174
verboseconfig=" --enable-silent-rules=yes"
167
175
verbosemake=" --quiet"
168
 
basedir="."
 
176
basedir="."                     # Retain quotes
 
177
basedirunq=$basedir             # Without retaining quotes
169
178
configcli_extra_args=""
170
179
 
171
180
 
194
203
        -h or --help displays usage information
195
204
        -H or --header-check show include stack depth
196
205
        -K or --check run make check
 
206
        -p[X] or --parallel-jobs[=X] number of jobs to pass to make as --jobs=
 
207
                If not specified make is sequential
 
208
                If no value X is given then defaults to nproc
197
209
        -s or --sparse build using sparse
198
210
        -t or --testing-hacks some build changes may be required for testing
199
211
                purposes. e.g. A script may invoke a project jar file which
219
231
        fi
220
232
}
221
233
 
 
234
# Standard function to tidy up and return exit code.
 
235
# Parameters -  $1 is the exit code.
 
236
# No return value.
 
237
script_exit()
 
238
{
 
239
        exit $1
 
240
}
 
241
 
222
242
# Standard function to test command error and exit if non-zero.
223
243
# Parameters -  $1 is the exit code, (normally $? from the preceeding command).
224
244
# No return value.
229
249
        fi
230
250
}
231
251
 
232
 
# Standard function to tidy up and return exit code.
233
 
# Parameters -  $1 is the exit code.
234
 
# No return value.
235
 
script_exit()
236
 
{
237
 
        exit $1
238
 
}
239
 
 
240
252
# Standard trap exit function.
241
253
# No parameters.
242
254
# No return value.
262
274
        local script_name="acmbuild.sh/bootstrap.sh"
263
275
        local tmp
264
276
 
265
 
        tmp="getopt -o abcCdDghHKstTvV "
 
277
        tmp="getopt -o abcCdDghHKp::stTvV "
266
278
        tmp+="--long at-only,build,check,config,distcheck,debug,dist,gnulib,"
267
 
        tmp+="help,header-check,sparse,source-tarball,testing-hacks,verbose,"
268
 
        tmp+="version"
 
279
        tmp+="help,header-check,parallel-jobs::,sparse,source-tarball,"
 
280
        tmp+="testing-hacks,verbose,version"
269
281
        GETOPTTEMP=$($tmp -n "$script_name" -- "$@")
270
282
        std_cmd_err_handler $?
271
283
 
329
341
                        headercheck=" --enable-headercheck=yes"
330
342
                        shift
331
343
                        ;;
 
344
                -p|--parallel-jobs)
 
345
                        if [[ -z "$2" ]]; then
 
346
                                par_jobs=" --jobs=$(nproc)"
 
347
                        else
 
348
                                par_jobs=" --jobs=$2"
 
349
                        fi
 
350
                        shift 2
 
351
                        ;;
332
352
                -K|--check)
333
353
                        if $distcheck || $dist || $tarball; then
334
354
                                msg="Options C, D, K and T are mutually "
401
421
        # original quoting. They can then be 'eval'ed.
402
422
        if (( $# )); then
403
423
                basedir=${1@Q}
 
424
                basedirunq="$1"         # Unquoted version
404
425
                shift
405
426
                configcli_extra_args=" "${@@Q}
406
427
        fi
415
436
        local msg
416
437
        local status
417
438
 
418
 
        if [[ -f $basedir/m4/gnulib-cache.m4 ]]; then
 
439
        if [[ -f "$basedirunq/m4/gnulib-cache.m4" ]]; then
419
440
                cmdline="gnulib-tool --update"$verbosemake$verbosemake
420
441
                cmdline+=" --dir="$basedir
421
442
                eval "$cmdline"
463
484
        local status
464
485
 
465
486
        if $build ; then
466
 
                cmdline="make"$verbosemake
 
487
                cmdline="make"$verbosemake$par_jobs
467
488
        fi
468
489
 
469
490
        if $check ; then
470
491
                if [[ ! $cmdline ]]; then
471
 
                        cmdline="make"$verbosemake
 
492
                        cmdline="make"$verbosemake$par_jobs
472
493
                fi
473
494
                cmdline+=" check"
474
495
        fi
475
496
 
476
497
        if $distcheck ; then
477
 
                cmdline="make"$verbosemake" distcheck clean"
 
498
                cmdline="make"$verbosemake$par_jobs" distcheck clean"
478
499
        fi
479
500
 
480
501
        if $dist ; then
481
 
                cmdline="make"$verbosemake" dist clean"
 
502
                cmdline="make"$verbosemake$par_jobs" dist clean"
482
503
        fi
483
504
 
484
505
        if $tarball ; then
485
 
                cmdline="make"$verbosemake" srctarball clean"
 
506
                cmdline="make"$verbosemake$par_jobs" srctarball clean"
486
507
        fi
487
508
 
488
509
        # May get here with cmdline empty if, for example, only the -g option