~m-grant-prg/mget/buster-trunk

« back to all changes in this revision

Viewing changes to bootstrap.sh

  • Committer: Mark Grant
  • Date: 2021-07-06 08:34:09 UTC
  • mfrom: (1.1.15)
  • Revision ID: m.grant.prg@gmail.com-20210706083409-28ky94d4jr3a3xxe
Merge new upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#########################################################################
10
10
#                                                                       #
11
11
# Script ID: bootstrap.sh                                               #
12
 
# Author: Copyright (C) 2014-2019  Mark Grant                           #
 
12
# Author: Copyright (C) 2014-2019, 2021  Mark Grant                     #
13
13
#                                                                       #
14
14
# Released under the GPLv3 only.                                        #
15
15
# SPDX-License-Identifier: GPL-3.0                                      #
27
27
#                               [ -h || --help ] ||                     #
28
28
#                               [ -H || --header-check ] ||             #
29
29
#                               [ -K || --check ] ||                    #
 
30
#                               [ -m || --menu-config ] ||              #
30
31
#                               [ -p || --parallel-jobs ] ||            #
31
32
#                               [ -s || --sparse ] ||                   #
32
33
#                               [ -t || --testing-hacks ] ||            #
145
146
#                               so introduce unquoted basedirunq.       #
146
147
# 01/12/2019    MG      1.4.7   Add parallel jobs option to pass to     #
147
148
#                               make as --jobs                          #
 
149
# 14/04/2021    MG      1.4.8   Add menu-config option to invoke menu   #
 
150
#                               of configurable options.                #
 
151
# 28/05/2021    MG      1.4.9   Process menuconfig before using tee for #
 
152
#                               the build log as menuconfig may involve #
 
153
#                               dialog and redirection.                 #
 
154
#                               Use a temporary file to get result back #
 
155
#                               from configurable-options.sh            #
148
156
#                                                                       #
149
157
#########################################################################
150
158
 
153
161
# Init variables #
154
162
##################
155
163
 
156
 
readonly version=1.4.7                  # set version variable
157
 
readonly packageversion=1.3.9   # Version of the complete package
 
164
readonly version=1.4.9                  # set version variable
 
165
readonly packageversion=1.3.12  # Version of the complete package
158
166
 
159
167
# Set defaults
160
168
atonly=""
166
174
distcheck=false
167
175
gnulib=false
168
176
headercheck=""
 
177
menuconfig=false
169
178
par_jobs=""
170
179
sparse=""
171
180
tarball=false
203
212
        -h or --help displays usage information
204
213
        -H or --header-check show include stack depth
205
214
        -K or --check run make check
 
215
        -m or --menu-config Invoke menu of configurable options
206
216
        -p[X] or --parallel-jobs[=X] number of jobs to pass to make as --jobs=
207
217
                If not specified make is sequential
208
218
                If no value X is given then defaults to nproc
274
284
        local script_name="acmbuild.sh/bootstrap.sh"
275
285
        local tmp
276
286
 
277
 
        tmp="getopt -o abcCdDghHKp::stTvV "
278
 
        tmp+="--long at-only,build,check,config,distcheck,debug,dist,gnulib,"
279
 
        tmp+="help,header-check,parallel-jobs::,sparse,source-tarball,"
280
 
        tmp+="testing-hacks,verbose,version"
 
287
        tmp="getopt -o abcCdDghHKmp::stTvV "
 
288
        tmp+="--long at-only,build,check,config,distcheck,debug,dist,gnulib"
 
289
        tmp+=",help,header-check,menu-config,parallel-jobs::,sparse"
 
290
        tmp+=",source-tarball,testing-hacks,verbose,version"
281
291
        GETOPTTEMP=$($tmp -n "$script_name" -- "$@")
282
292
        std_cmd_err_handler $?
283
293
 
341
351
                        headercheck=" --enable-headercheck=yes"
342
352
                        shift
343
353
                        ;;
 
354
                -K|--check)
 
355
                        if $distcheck || $dist || $tarball; then
 
356
                                msg="Options C, D, K and T are mutually "
 
357
                                msg+="exclusive."
 
358
                                output "$msg" 1
 
359
                                script_exit 64
 
360
                        fi
 
361
                        check=true
 
362
                        shift
 
363
                        ;;
 
364
                -m|--menu-config)
 
365
                        which whiptail > /dev/null
 
366
                        status=$?
 
367
                        if (( $status != 0 )); then
 
368
                                output "Please first install whiptail." 1
 
369
                                script_exit 64
 
370
                        fi
 
371
                        menuconfig=true
 
372
                        shift
 
373
                        ;;
344
374
                -p|--parallel-jobs)
345
375
                        if [[ -z "$2" ]]; then
346
376
                                par_jobs=" --jobs=$(nproc)"
349
379
                        fi
350
380
                        shift 2
351
381
                        ;;
352
 
                -K|--check)
353
 
                        if $distcheck || $dist || $tarball; then
354
 
                                msg="Options C, D, K and T are mutually "
355
 
                                msg+="exclusive."
356
 
                                output "$msg" 1
357
 
                                script_exit 64
358
 
                        fi
359
 
                        check=true
360
 
                        shift
361
 
                        ;;
362
382
                -s|--sparse)
363
383
                        sparse=" --enable-sparse=yes"
364
384
                        shift
414
434
                script_exit 64
415
435
        fi
416
436
 
 
437
        # menu-config can only be selected with config
 
438
        if $menuconfig && ! $config; then
 
439
                output "Option c must be selected with option m." 1
 
440
                script_exit 64
 
441
        fi
 
442
 
417
443
        # First non-option argument which is not an option argument is the base
418
444
        # directory, all others are passed straight to the configure command
419
445
        # line, (to support things like  --prefix=... etc). Both of these need
423
449
                basedir=${1@Q}
424
450
                basedirunq="$1"         # Unquoted version
425
451
                shift
426
 
                configcli_extra_args=" "${@@Q}
 
452
                configcli_extra_args+=" "${@@Q}
427
453
        fi
428
454
}
429
455
 
450
476
        fi
451
477
}
452
478
 
 
479
# Process the configurable options menu
 
480
# No parameters
 
481
# No return value
 
482
proc_menuconfig()
 
483
{
 
484
        local msg
 
485
        local readonly tmp_file=/tmp/$$.$(basename $0).tmp
 
486
 
 
487
        if [[ ! -f $basedirunq/configurable-options.sh \
 
488
                || ! -r $basedirunq/configurable-options.sh \
 
489
                || ! -x $basedirunq/configurable-options.sh ]]; then
 
490
                msg="The script configurable-options.sh must; exist in the"
 
491
                msg+=" project root directory, be readable and be executable."
 
492
                output "$msg" 1
 
493
                script_exit 77
 
494
        fi
 
495
        $basedirunq/configurable-options.sh $tmp_file
 
496
        std_cmd_err_handler $?
 
497
        configcli_extra_args+=$(cat < $tmp_file)
 
498
        std_cmd_err_handler $?
 
499
        rm -f $tmp_file
 
500
        std_cmd_err_handler $?
 
501
}
 
502
 
453
503
# Process configure
454
504
# No parameters
455
505
# No return value
525
575
 
526
576
proc_CL "$@"
527
577
 
528
 
# Create build log.
 
578
# Now the main processing.
 
579
if $menuconfig; then
 
580
        proc_menuconfig
 
581
fi
 
582
 
 
583
# Create build log after menuconfig which may use dialog and redirections.
529
584
exec 1> >(tee build-output.txt) 2>&1
530
585
 
531
 
# Now the main processing.
532
586
if $gnulib ; then
533
587
        proc_gnulib
534
588
fi