2 ## DO NOT EDIT - This file generated from build-aux/bootstrap.in
3 ## by inline-source v2019-02-19.15
5 # Bootstrap an Autotooled package from checked-out sources.
6 # Written by Gary V. Vaughan, 2010
7 # Inspired by a script written by Paul Eggert.
9 # This is free software. There is NO warranty; not even for
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # Copyright (C) 2010-2019 Bootstrap Authors
14 # This file is dual licensed under the terms of the MIT license
15 # <https://opensource.org/license/MIT>, and GPL version 2 or later
16 # <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of
17 # these licenses when using or redistributing this software or any of
18 # the files within it. See the URLs above, or the file `LICENSE`
19 # included in the Bootstrap distribution for the full license texts.
21 # You should place a copy of this script under version control in the
22 # top-level directory of your project. The intent is that all
23 # customization can be done with a `bootstrap.conf` file also maintained
24 # in your version control.
26 # Please report bugs or propose patches to:
27 # <https://github.com/gnulib-modules/bootstrap/issues>
34 # Most GNUish projects do not keep all of the generated Autotool
35 # files under version control, but running all of the right tools
36 # with the right arguments, in the correct order to regenerate
37 # all of those files in readiness for configuration and building
38 # can be surprisingly involved! Many projects have a 'bootstrap'
39 # script under version control to invoke Autotools and perform
40 # other assorted book-keeping with version numbers and the like.
42 # This bootstrap script aims to probe the configure.ac and top
43 # Makefile.am of your project to automatically determine what
44 # the correct ordering and arguments are and then run the tools for
45 # you. In order to use it, you can generate an initial standalone
48 # gl/build-aux/inline-source gl/build-aux/bootstrap.in > bootstrap
50 # You should then store than script in version control for other
51 # developers in you project. It will give you instructions about
52 # how to keep it up to date if the sources change.
54 # See gl/doc/bootstrap.texi for documentation on how to write
55 # a bootstrap.conf to customize it for your project's
59 ## ================================================================== ##
61 ## DO NOT EDIT THIS FILE, CUSTOMIZE IT USING A BOOTSTRAP.CONF ##
63 ## ================================================================== ##
65 ## ------------------------------- ##
66 ## User overridable command paths. ##
67 ## ------------------------------- ##
69 # All uppercase denotes values stored in the environment. These
70 # variables should generally be overridden by the user - however, we do
71 # set them to 'true' in some parts of this script to prevent them being
72 # called at the wrong time by other tools that we call ('autoreconf',
75 # We also allow 'LIBTOOLIZE', 'M4', 'SHA1SUM' and some others to be
76 # overridden, and export the result for child processes, but they are
77 # handled by the function 'func_find_tool' and not defaulted in this
80 : ${ACLOCAL="aclocal"}
81 : ${AUTOCONF="autoconf"}
82 : ${AUTOHEADER="autoheader"}
83 : ${AUTOM4TE="autom4te"}
84 : ${AUTOHEADER="autoheader"}
85 : ${AUTOMAKE="automake"}
86 : ${AUTOPOINT="autopoint"}
87 : ${AUTORECONF="autoreconf"}
89 : ${CONFIG_SHELL="/bin/sh"}
110 # A newline delimited list of triples of programs (that respond to
111 # --version), the minimum version numbers required (or just '-' in the
112 # version field if any version will be sufficient) and homepage URLs
113 # to help locate missing packages.
116 # Name of a file containing instructions on installing missing packages
117 # required in 'buildreq'.
118 buildreq_readme=README-hacking
120 # These are extracted from AC_INIT in configure.ac, though you can
121 # override those values in 'bootstrap.conf' if you prefer.
129 # These are extracted from 'gnulib-cache.m4', or else fall-back
130 # automatically on the gnulib defaults; unless you set the values
131 # manually in 'bootstrap.conf'.
139 # The list of gnulib modules required at 'gnulib-tool' time. If you
140 # check 'gnulib-cache.m4' into your repository, then this list will be
141 # extracted automatically.
144 # Extra gnulib files that are not in modules, which override files of
145 # the same name installed by other bootstrap tools.
146 gnulib_non_module_files="
150 build-aux/texinfo.tex
152 build-aux/config.guess
157 # Relative path to the local gnulib submodule, and url to the upstream
158 # git repository. If you have a gnulib entry in your .gitmodules file,
159 # these values are ignored.
163 # Date from which to clone github, to avoid a full clone.
166 # Additional gnulib-tool options to use.
167 gnulib_tool_options="
171 # bootstrap removes any macro-files that are not included by aclocal.m4,
172 # except for files listed in this variable that are always kept.
177 # When truncating long commands for display, always allow at least this
178 # many characters before truncating.
181 # The command to download all .po files for a specified domain into
182 # a specified directory. Fill in the first %s is the domain name, and
183 # the second with the destination directory. Use rsync's -L and -r
184 # options because the latest/%s directory and the .po files within are
186 po_download_command_format=\
187 "rsync --delete --exclude '*.s1' -Lrtvz \
188 'translationproject.org::tp/latest/%s/' '%s'"
190 # Other locale categories that need message catalogs.
191 extra_locale_categories=
193 # Additional xgettext options to use. Gnulib might provide you with an
194 # extensive list of additional options to append to this, but gettext
195 # 0.16.1 and newer appends them automaticaly, so you can safely ignore
196 # the complaints from 'gnulib-tool' if your $configure_ac states:
198 # AM_GNU_GETTEXT_VERSION([0.16.1])
200 --flag=_:1:pass-c-format
201 --flag=N_:1:pass-c-format
204 # Package copyright holder for gettext files. Defaults to FSF if unset.
207 # File that should exist in the top directory of a checked out hierarchy,
208 # but not in a distribution tarball.
211 # Whether to use copies instead of symlinks by default (if set to true,
212 # the --copy option has no effect).
215 # Set this to ".cvsignore .gitignore" in 'bootstrap.conf' if you want
216 # those files to be generated in directories like 'lib/', 'm4/', and 'po/',
217 # or set it to "auto" to make this script select what to use based
218 # on what version control system (if any) is used in the source directory.
219 # Or set it to "none" to ignore VCS ignore files entirely. Default is
224 ## ------------------- ##
225 ## External Libraries. ##
226 ## ------------------- ##
228 # Source required external libraries:
229 # Set a version string for this script.
230 scriptversion=2019-02-19.15; # UTC
232 # General shell script boiler plate, and helper functions.
233 # Written by Gary V. Vaughan, 2004
235 # This is free software. There is NO warranty; not even for
236 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
238 # Copyright (C) 2004-2019 Bootstrap Authors
240 # This file is dual licensed under the terms of the MIT license
241 # <https://opensource.org/license/MIT>, and GPL version 2 or later
242 # <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of
243 # these licenses when using or redistributing this software or any of
244 # the files within it. See the URLs above, or the file `LICENSE`
245 # included in the Bootstrap distribution for the full license texts.
247 # Please report bugs or propose patches to:
248 # <https://github.com/gnulib-modules/bootstrap/issues>
255 # Evaluate this file near the top of your script to gain access to
256 # the functions and variables defined here:
258 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
260 # If you need to override any of the default environment variable
261 # settings, do that before evaluating this file.
264 ## -------------------- ##
265 ## Shell normalisation. ##
266 ## -------------------- ##
268 # Some shells need a little help to be as Bourne compatible as possible.
269 # Before doing anything else, make sure all that help has been provided!
271 DUALCASE=1; export DUALCASE # for MKS sh
272 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
275 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
276 # is contrary to our usage. Disable this feature.
277 alias -g '${1+"$@"}'='"$@"'
280 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
283 # NLS nuisances: We save the old values in case they are required later.
286 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
288 eval "if test set = \"\${$_G_var+set}\"; then
289 save_$_G_var=\$$_G_var
292 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
293 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
297 # Make sure IFS has a sensible default
303 # There are apparently some retarded systems that use ';' as a PATH separator!
304 if test "${PATH_SEPARATOR+set}" != set; then
306 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
307 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
315 # Portably unset VAR.
316 # In some shells, an 'unset VAR' statement leaves a non-zero return
317 # status if VAR is already unset, which might be problematic if the
318 # statement is used at the end of a function (thus poisoning its return
319 # value) or when 'set -e' is active (causing even a spurious abort of
320 # the script in this case).
323 { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }
327 # Make sure CDPATH doesn't cause `cd` commands to output the target dir.
330 # Make sure ${,E,F}GREP behave sanely.
331 func_unset GREP_OPTIONS
334 ## ------------------------- ##
335 ## Locate command utilities. ##
336 ## ------------------------- ##
339 # func_executable_p FILE
340 # ----------------------
341 # Check that FILE is an executable regular file.
344 test -f "$1" && test -x "$1"
348 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
349 # --------------------------------------------
350 # Search for either a program that responds to --version with output
351 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
352 # trying all the directories in PATH with each of the elements of
355 # CHECK_FUNC should accept the path to a candidate program, and
356 # set $func_check_prog_result if it truncates its output less than
357 # $_G_path_prog_max characters.
365 _G_path_prog_found=false
366 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
367 for _G_dir in $_G_PATH; do
369 test -z "$_G_dir" && _G_dir=.
370 for _G_prog_name in $_G_progs_list; do
371 for _exeext in '' .EXE; do
372 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
373 func_executable_p "$_G_path_prog" || continue
374 case `"$_G_path_prog" --version 2>&1` in
375 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
376 *) $_G_check_func $_G_path_prog
377 func_path_progs_result=$func_check_prog_result
380 $_G_path_prog_found && break 3
385 test -z "$func_path_progs_result" && {
386 echo "no acceptable sed could be found in \$PATH" >&2
392 # We want to be able to use the functions in this file before configure
393 # has figured out where the best binaries are kept, which means we have
394 # to search for them ourselves - except when the results are already set
395 # where we skip the searches.
397 # Unless the user overrides by setting SED, search the path for either GNU
398 # sed, or the sed that truncates its output the least.
400 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
401 for _G_i in 1 2 3 4 5 6 7; do
402 _G_sed_script=$_G_sed_script$nl$_G_sed_script
404 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
407 func_check_prog_sed ()
412 printf 0123456789 >conftest.in
415 cat conftest.in conftest.in >conftest.tmp
416 mv conftest.tmp conftest.in
417 cp conftest.in conftest.nl
418 echo '' >> conftest.nl
419 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
420 diff conftest.out conftest.nl >/dev/null 2>&1 || break
421 _G_count=`expr $_G_count + 1`
422 if test "$_G_count" -gt "$_G_path_prog_max"; then
423 # Best one so far, save it but keep looking for a better one
424 func_check_prog_result=$_G_path_prog
425 _G_path_prog_max=$_G_count
427 # 10*(2^10) chars as input seems more than enough
428 test 10 -lt "$_G_count" && break
430 rm -f conftest.in conftest.tmp conftest.nl conftest.out
433 func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"
435 SED=$func_path_progs_result
439 # Unless the user overrides by setting GREP, search the path for either GNU
440 # grep, or the grep that truncates its output the least.
442 func_check_prog_grep ()
448 printf 0123456789 >conftest.in
451 cat conftest.in conftest.in >conftest.tmp
452 mv conftest.tmp conftest.in
453 cp conftest.in conftest.nl
454 echo 'GREP' >> conftest.nl
455 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
456 diff conftest.out conftest.nl >/dev/null 2>&1 || break
457 _G_count=`expr $_G_count + 1`
458 if test "$_G_count" -gt "$_G_path_prog_max"; then
459 # Best one so far, save it but keep looking for a better one
460 func_check_prog_result=$_G_path_prog
461 _G_path_prog_max=$_G_count
463 # 10*(2^10) chars as input seems more than enough
464 test 10 -lt "$_G_count" && break
466 rm -f conftest.in conftest.tmp conftest.nl conftest.out
469 func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"
470 GREP=$func_path_progs_result
474 ## ------------------------------- ##
475 ## User overridable command paths. ##
476 ## ------------------------------- ##
478 # All uppercase variable names are used for environment variables. These
479 # variables can be overridden by the user before calling a script that
480 # uses them if a suitable command of that name is not already available
481 # in the command search PATH.
484 : ${ECHO="printf %s\n"}
485 : ${EGREP="$GREP -E"}
486 : ${FGREP="$GREP -F"}
492 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
495 ## -------------------- ##
496 ## Useful sed snippets. ##
497 ## -------------------- ##
499 sed_dirname='s|/[^/]*$||'
500 sed_basename='s|^.*/||'
502 # Sed substitution that helps us do robust quoting. It backslashifies
503 # metacharacters that are still active within double-quoted strings.
504 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
506 # Same as above, but do not quote variable references.
507 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
509 # Sed substitution that turns a string into a regex matching for the
511 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
513 # Sed substitution that converts a w32 file name or path
514 # that contains forward slashes, into one that contains
515 # (escaped) backslashes. A very naive implementation.
516 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
518 # Re-'\' parameter expansions in output of sed_double_quote_subst that
519 # were '\'-ed in input to the same. If an odd number of '\' preceded a
520 # '$' in input to sed_double_quote_subst, that '$' was protected from
521 # expansion. Since each input '\' is now two '\'s, look for any number
522 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
527 sed_double_backslash="\
530 s/^$_G_bs2$_G_dollar/$_G_bs&/
531 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
535 ## ----------------- ##
536 ## Global variables. ##
537 ## ----------------- ##
539 # Except for the global variables explicitly listed below, the following
540 # functions in the '^func_' namespace, and the '^require_' namespace
541 # variables initialised in the 'Resource management' section, sourcing
542 # this file will not pollute your global namespace with anything
543 # else. There's no portable way to scope variables in Bourne shell
544 # though, so actually running these functions will sometimes place
545 # results into a variable named after the function, and often use
546 # temporary variables in the '^_G_' namespace. If you are careful to
547 # avoid using those namespaces casually in your sourcing script, things
548 # should continue to work as you expect. And, of course, you can freely
549 # overwrite any of the functions or variables defined here before
550 # calling anything to customize them.
554 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
555 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
557 # Allow overriding, eg assuming that you follow the convention of
558 # putting '$debug_cmd' at the start of all your functions, you can get
559 # bash to show function call trace with:
561 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
562 debug_cmd=${debug_cmd-":"}
565 # By convention, finish your script with:
569 # so that you can set exit_status to non-zero if you want to indicate
570 # something went wrong during execution without actually bailing out at
571 # the point of failure.
572 exit_status=$EXIT_SUCCESS
574 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
575 # is ksh but when the shell is invoked as "sh" and the current value of
576 # the _XPG environment variable is not equal to 1 (one), the special
577 # positional parameter $0, within a function call, is the name of the
581 # The name of this program.
582 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
584 # Make sure we have an absolute progpath for reexecution:
586 [\\/]*|[A-Za-z]:\\*) ;;
588 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
589 progdir=`cd "$progdir" && pwd`
590 progpath=$progdir/$progname
594 IFS=${PATH_SEPARATOR-:}
595 for progdir in $PATH; do
597 test -x "$progdir/$progname" && break
600 test -n "$progdir" || progdir=`pwd`
601 progpath=$progdir/$progname
606 ## ----------------- ##
607 ## Standard options. ##
608 ## ----------------- ##
610 # The following options affect the operation of the functions defined
611 # below, and should be set appropriately depending on run-time para-
612 # meters passed on the command line.
618 # Categories 'all' and 'none' are always available. Append any others
619 # you will pass as the first argument to func_warning from your own
623 # By default, display warnings according to 'opt_warning_types'. Set
624 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
625 # treat the next displayed warning as a fatal error.
626 warning_func=func_warn_and_continue
628 # Set to 'all' to display all warnings, 'none' to suppress all
629 # warnings, or a space delimited list of some subset of
630 # 'warning_categories' to display only the listed warnings.
631 opt_warning_types=all
634 ## -------------------- ##
635 ## Resource management. ##
636 ## -------------------- ##
638 # This section contains definitions for functions that each ensure a
639 # particular resource (a file, or a non-empty configuration variable for
640 # example) is available, and if appropriate to extract default values
641 # from pertinent package files. Call them using their associated
642 # 'require_*' variable to ensure that they are executed, at most, once.
644 # It's entirely deliberate that calling these functions can set
645 # variables that don't obey the namespace limitations obeyed by the rest
646 # of this file, in order that that they be as useful as possible to
650 # require_term_colors
651 # -------------------
652 # Allow display of bold text on terminals that support it.
653 require_term_colors=func_require_term_colors
654 func_require_term_colors ()
659 # COLORTERM and USE_ANSI_COLORS environment variables take
660 # precedence, because most terminfo databases neglect to describe
661 # whether color sequences are supported.
662 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
664 if test 1 = "$USE_ANSI_COLORS"; then
665 # Standard ANSI escape sequences
667 tc_bold='
\e[1m'; tc_standout='
\e[7m'
668 tc_red='
\e[31m'; tc_green='
\e[32m'
669 tc_blue='
\e[34m'; tc_cyan='
\e[36m'
671 # Otherwise trust the terminfo database after all.
672 test -n "`tput sgr0 2>/dev/null`" && {
674 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
676 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
677 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
678 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
679 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
680 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
685 require_term_colors=:
689 ## ----------------- ##
690 ## Function library. ##
691 ## ----------------- ##
693 # This section contains a variety of useful functions to call in your
694 # scripts. Take note of the portable wrappers for features provided by
695 # some modern shells, which will fall back to slower equivalents on
696 # less featureful shells.
699 # func_append VAR VALUE
700 # ---------------------
701 # Append VALUE onto the existing contents of VAR.
703 # We should try to minimise forks, especially on Windows where they are
704 # unreasonably slow, so skip the feature probes when bash or zsh are
706 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
707 : ${_G_HAVE_ARITH_OP="yes"}
708 : ${_G_HAVE_XSI_OPS="yes"}
709 # The += operator was introduced in bash 3.1
710 case $BASH_VERSION in
711 [12].* | 3.0 | 3.0*) ;;
713 : ${_G_HAVE_PLUSEQ_OP="yes"}
719 # Can be empty, in which case the shell is probed, "yes" if += is
720 # useable or anything else if it does not work.
721 test -z "$_G_HAVE_PLUSEQ_OP" \
722 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
723 && _G_HAVE_PLUSEQ_OP=yes
725 if test yes = "$_G_HAVE_PLUSEQ_OP"
727 # This is an XSI compatible shell, allowing a faster implementation...
735 # ...otherwise fall back to using expr, which is often a shell builtin.
745 # func_append_quoted VAR VALUE
746 # ----------------------------
747 # Quote VALUE and append to the end of shell variable VAR, separated
749 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
750 eval 'func_append_quoted ()
754 func_quote_arg pretty "$2"
755 eval "$1+=\\ \$func_quote_arg_result"
758 func_append_quoted ()
762 func_quote_arg pretty "$2"
763 eval "$1=\$$1\\ \$func_quote_arg_result"
768 # func_append_uniq VAR VALUE
769 # --------------------------
770 # Append unique VALUE onto the existing contents of VAR, assuming
771 # entries are delimited by the first character of VALUE. For example:
773 # func_append_uniq options " --another-option option-argument"
775 # will only append to $options if " --another-option option-argument "
776 # is not already present somewhere in $options already (note spaces at
777 # each end implied by leading space in second argument).
782 eval _G_current_value='`$ECHO $'$1'`'
783 _G_delim=`expr "$2" : '\(.\)'`
785 case $_G_delim$_G_current_value$_G_delim in
787 *) func_append "$@" ;;
794 # Set func_arith_result to the result of evaluating TERMs.
795 test -z "$_G_HAVE_ARITH_OP" \
796 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
797 && _G_HAVE_ARITH_OP=yes
799 if test yes = "$_G_HAVE_ARITH_OP"; then
804 func_arith_result=$(( $* ))
811 func_arith_result=`expr "$@"`
818 # Set func_basename_result to FILE with everything up to and including
819 # the last / stripped.
820 if test yes = "$_G_HAVE_XSI_OPS"; then
821 # If this shell supports suffix pattern removal, then use it to avoid
822 # forking. Hide the definitions single quotes in case the shell chokes
823 # on unsupported syntax...
824 _b='func_basename_result=${1##*/}'
826 */*) func_dirname_result=${1%/*}$2 ;;
827 * ) func_dirname_result=$3 ;;
831 # ...otherwise fall back to using sed.
832 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
833 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
834 if test "X$func_dirname_result" = "X$1"; then
835 func_dirname_result=$3
837 func_append func_dirname_result "$2"
841 eval 'func_basename ()
849 # func_dirname FILE APPEND NONDIR_REPLACEMENT
850 # -------------------------------------------
851 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
852 # otherwise set result to NONDIR_REPLACEMENT.
853 eval 'func_dirname ()
861 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
862 # --------------------------------------------------------
863 # Perform func_basename and func_dirname in a single function
865 # dirname: Compute the dirname of FILE. If nonempty,
866 # add APPEND to the result, otherwise set result
867 # to NONDIR_REPLACEMENT.
868 # value returned in "$func_dirname_result"
869 # basename: Compute filename of FILE.
870 # value retuned in "$func_basename_result"
871 # For efficiency, we do not delegate to the functions above but instead
872 # duplicate the functionality here.
873 eval 'func_dirname_and_basename ()
884 # Echo program name prefixed message.
893 for _G_line in $_G_message; do
895 $ECHO "$progname: $_G_line"
901 # func_echo_all ARG...
902 # --------------------
903 # Invoke $ECHO with all args, space-separated.
910 # func_echo_infix_1 INFIX ARG...
911 # ------------------------------
912 # Echo program name, followed by INFIX on the first line, with any
913 # additional lines not showing INFIX.
922 _G_prefix="$progname: $_G_infix: "
925 # Strip color escape sequences before counting printable length
926 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
928 test -n "$_G_tc" && {
929 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
930 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
933 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
935 func_echo_infix_1_IFS=$IFS
937 for _G_line in $_G_message; do
938 IFS=$func_echo_infix_1_IFS
939 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
942 IFS=$func_echo_infix_1_IFS
948 # Echo program name prefixed message to standard error.
955 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
959 # func_fatal_error ARG...
960 # -----------------------
961 # Echo program name prefixed message to standard error, and exit.
971 # func_grep EXPRESSION FILENAME
972 # -----------------------------
973 # Check whether EXPRESSION matches any line of FILENAME, without output.
978 $GREP "$1" "$2" >/dev/null 2>&1
984 # Set func_len_result to the length of STRING. STRING may not
985 # start with a hyphen.
986 test -z "$_G_HAVE_XSI_OPS" \
988 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
989 && _G_HAVE_XSI_OPS=yes
991 if test yes = "$_G_HAVE_XSI_OPS"; then
996 func_len_result=${#1}
1003 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
1008 # func_mkdir_p DIRECTORY-PATH
1009 # ---------------------------
1010 # Make sure the entire path to DIRECTORY-PATH is available.
1015 _G_directory_path=$1
1018 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
1020 # Protect directory names starting with '-'
1021 case $_G_directory_path in
1022 -*) _G_directory_path=./$_G_directory_path ;;
1025 # While some portion of DIR does not yet exist...
1026 while test ! -d "$_G_directory_path"; do
1027 # ...make a list in topmost first order. Use a colon delimited
1028 # list incase some portion of path contains whitespace.
1029 _G_dir_list=$_G_directory_path:$_G_dir_list
1031 # If the last portion added has no slash in it, the list is done
1032 case $_G_directory_path in */*) ;; *) break ;; esac
1034 # ...otherwise throw away the child directory and loop
1035 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
1037 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
1039 func_mkdir_p_IFS=$IFS; IFS=:
1040 for _G_dir in $_G_dir_list; do
1041 IFS=$func_mkdir_p_IFS
1042 # mkdir can fail with a 'File exist' error if two processes
1043 # try to create one of the directories concurrently. Don't
1044 # stop in that case!
1045 $MKDIR "$_G_dir" 2>/dev/null || :
1047 IFS=$func_mkdir_p_IFS
1049 # Bail out if we (or some other process) failed to create a directory.
1050 test -d "$_G_directory_path" || \
1051 func_fatal_error "Failed to create '$1'"
1056 # func_mktempdir [BASENAME]
1057 # -------------------------
1058 # Make a temporary directory that won't clash with other running
1059 # libtool processes, and avoids race conditions if possible. If
1060 # given, BASENAME is the basename for that directory.
1065 _G_template=${TMPDIR-/tmp}/${1-$progname}
1067 if test : = "$opt_dry_run"; then
1068 # Return a directory name, but don't create it in dry-run mode
1069 _G_tmpdir=$_G_template-$$
1072 # If mktemp works, use that first and foremost
1073 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
1075 if test ! -d "$_G_tmpdir"; then
1076 # Failing that, at least try and use $RANDOM to avoid a race
1077 _G_tmpdir=$_G_template-${RANDOM-0}$$
1079 func_mktempdir_umask=`umask`
1082 umask $func_mktempdir_umask
1085 # If we're not in dry-run mode, bomb out on failure
1086 test -d "$_G_tmpdir" || \
1087 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
1094 # func_normal_abspath PATH
1095 # ------------------------
1096 # Remove doubled-up and trailing slashes, "." path components,
1097 # and cancel out any ".." path components in PATH after making
1098 # it an absolute path.
1099 func_normal_abspath ()
1103 # These SED scripts presuppose an absolute path with a trailing slash.
1104 _G_pathcar='s|^/\([^/]*\).*$|\1|'
1105 _G_pathcdr='s|^/[^/]*||'
1106 _G_removedotparts=':dotsl
1110 _G_collapseslashes='s|/\{1,\}|/|g'
1111 _G_finalslash='s|/*$|/|'
1113 # Start from root dir and reassemble the path.
1114 func_normal_abspath_result=
1115 func_normal_abspath_tpath=$1
1116 func_normal_abspath_altnamespace=
1117 case $func_normal_abspath_tpath in
1119 # Empty path, that just means $cwd.
1120 func_stripname '' '/' "`pwd`"
1121 func_normal_abspath_result=$func_stripname_result
1124 # The next three entries are used to spot a run of precisely
1125 # two leading slashes without using negated character classes;
1126 # we take advantage of case's first-match behaviour.
1128 # Unusual form of absolute path, do nothing.
1131 # Not necessarily an ordinary path; POSIX reserves leading '//'
1132 # and for example Cygwin uses it to access remote file shares
1133 # over CIFS/SMB, so we conserve a leading double slash if found.
1134 func_normal_abspath_altnamespace=/
1137 # Absolute path, do nothing.
1140 # Relative path, prepend $cwd.
1141 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
1145 # Cancel out all the simple stuff to save iterations. We also want
1146 # the path to end with a slash for ease of parsing, so make sure
1147 # there is one (and only one) here.
1148 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1149 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
1151 # Processed it all yet?
1152 if test / = "$func_normal_abspath_tpath"; then
1153 # If we ascended to the root using ".." the result may be empty now.
1154 if test -z "$func_normal_abspath_result"; then
1155 func_normal_abspath_result=/
1159 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
1161 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1163 # Figure out what to do with it
1164 case $func_normal_abspath_tcomponent in
1166 # Trailing empty path component, ignore it.
1169 # Parent dir; strip last assembled component from result.
1170 func_dirname "$func_normal_abspath_result"
1171 func_normal_abspath_result=$func_dirname_result
1174 # Actual path component, append it.
1175 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1179 # Restore leading double-slash if one was found on entry.
1180 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1184 # func_notquiet ARG...
1185 # --------------------
1186 # Echo program name prefixed message only when not in quiet mode.
1191 $opt_quiet || func_echo ${1+"$@"}
1193 # A bug in bash halts the script if the last line of a function
1194 # fails when set -e is in force, so we need another command to
1200 # func_relative_path SRCDIR DSTDIR
1201 # --------------------------------
1202 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1203 func_relative_path ()
1207 func_relative_path_result=
1208 func_normal_abspath "$1"
1209 func_relative_path_tlibdir=$func_normal_abspath_result
1210 func_normal_abspath "$2"
1211 func_relative_path_tbindir=$func_normal_abspath_result
1213 # Ascend the tree starting from libdir
1215 # check if we have found a prefix of bindir
1216 case $func_relative_path_tbindir in
1217 $func_relative_path_tlibdir)
1218 # found an exact match
1219 func_relative_path_tcancelled=
1222 $func_relative_path_tlibdir*)
1223 # found a matching prefix
1224 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1225 func_relative_path_tcancelled=$func_stripname_result
1226 if test -z "$func_relative_path_result"; then
1227 func_relative_path_result=.
1232 func_dirname $func_relative_path_tlibdir
1233 func_relative_path_tlibdir=$func_dirname_result
1234 if test -z "$func_relative_path_tlibdir"; then
1235 # Have to descend all the way to the root!
1236 func_relative_path_result=../$func_relative_path_result
1237 func_relative_path_tcancelled=$func_relative_path_tbindir
1240 func_relative_path_result=../$func_relative_path_result
1245 # Now calculate path; take care to avoid doubling-up slashes.
1246 func_stripname '' '/' "$func_relative_path_result"
1247 func_relative_path_result=$func_stripname_result
1248 func_stripname '/' '/' "$func_relative_path_tcancelled"
1249 if test -n "$func_stripname_result"; then
1250 func_append func_relative_path_result "/$func_stripname_result"
1253 # Normalisation. If bindir is libdir, return '.' else relative path.
1254 if test -n "$func_relative_path_result"; then
1255 func_stripname './' '' "$func_relative_path_result"
1256 func_relative_path_result=$func_stripname_result
1259 test -n "$func_relative_path_result" || func_relative_path_result=.
1265 # func_quote_portable EVAL ARG
1266 # ----------------------------
1267 # Internal function to portably implement func_quote_arg. Note that we still
1268 # keep attention to performance here so we as much as possible try to avoid
1269 # calling sed binary (so far O(N) complexity as long as func_append is O(1)).
1270 func_quote_portable ()
1274 func_quote_portable_result=$2
1276 # one-time-loop (easy break)
1280 func_quote_portable_result=`$ECHO "$2" | $SED \
1281 -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
1286 case $func_quote_portable_result in
1288 case $func_quote_portable_result in
1290 func_quote_portable_result=`$ECHO "$func_quote_portable_result" \
1291 | $SED "$sed_quote_subst"`
1296 func_quote_portable_old_IFS=$IFS
1297 for _G_char in '\' '`' '"' '$'
1299 # STATE($1) PREV($2) SEPARATOR($3)
1301 func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
1303 for _G_part in $func_quote_portable_result
1307 func_append func_quote_portable_result "$3$2"
1308 set quote "$_G_part" "\\$_G_char"
1312 func_quote_portable_result=
1315 set quote "$_G_part" ""
1320 IFS=$func_quote_portable_old_IFS
1327 func_quote_portable_unquoted_result=$func_quote_portable_result
1328 case $func_quote_portable_result in
1329 # double-quote args containing shell metacharacters to delay
1330 # word splitting, command substitution and variable expansion
1331 # for a subsequent eval.
1332 # many bourne shells cannot handle close brackets correctly
1333 # in scan sets, so we specify it separately.
1334 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1335 func_quote_portable_result=\"$func_quote_portable_result\"
1341 # func_quotefast_eval ARG
1342 # -----------------------
1343 # Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG',
1344 # but optimized for speed. Result is stored in $func_quotefast_eval.
1345 if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
1346 printf -v _GL_test_printf_tilde %q '~'
1347 if test '\~' = "$_GL_test_printf_tilde"; then
1348 func_quotefast_eval ()
1350 printf -v func_quotefast_eval_result %q "$1"
1353 # Broken older Bash implementations. Make those faster too if possible.
1354 func_quotefast_eval ()
1358 func_quote_portable false "$1"
1359 func_quotefast_eval_result=$func_quote_portable_result
1362 printf -v func_quotefast_eval_result %q "$1"
1368 func_quotefast_eval ()
1370 func_quote_portable false "$1"
1371 func_quotefast_eval_result=$func_quote_portable_result
1376 # func_quote_arg MODEs ARG
1377 # ------------------------
1378 # Quote one ARG to be evaled later. MODEs argument may contain zero or more
1379 # specifiers listed below separated by ',' character. This function returns two
1381 # i) func_quote_arg_result
1382 # double-quoted (when needed), suitable for a subsequent eval
1383 # ii) func_quote_arg_unquoted_result
1384 # has all characters that are still active within double
1385 # quotes backslashified. Available only if 'unquoted' is specified.
1390 # - escape shell special characters
1392 # - the same as 'eval'; but do not quote variable references
1394 # - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might
1395 # be used later in func_quote to get output like: 'echo "a b"' instead
1396 # of 'echo a\ b'. This is slower than default on some shells.
1398 # - produce also $func_quote_arg_unquoted_result which does not contain
1399 # wrapping double-quotes.
1401 # Examples for 'func_quote_arg pretty,unquoted string':
1403 # string | *_result | *_unquoted_result
1404 # ------------+-----------------------+-------------------
1407 # "a b" | "\"a b\"" | \"a b\"
1409 # z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\"
1411 # Examples for 'func_quote_arg pretty,unquoted,expand string':
1413 # string | *_result | *_unquoted_result
1414 # --------------+---------------------+--------------------
1415 # z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\"
1418 _G_quote_expand=false
1426 *,pretty,*|*,expand,*|*,unquoted,*)
1427 func_quote_portable $_G_quote_expand "$2"
1428 func_quote_arg_result=$func_quote_portable_result
1429 func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
1432 # Faster quote-for-eval for some shells.
1433 func_quotefast_eval "$2"
1434 func_quote_arg_result=$func_quotefast_eval_result
1440 # func_quote MODEs ARGs...
1441 # ------------------------
1442 # Quote all ARGs to be evaled later and join them into single command. See
1443 # func_quote_arg's description for more info.
1447 _G_func_quote_mode=$1 ; shift
1449 while test 0 -lt $#; do
1450 func_quote_arg "$_G_func_quote_mode" "$1"
1451 if test -n "$func_quote_result"; then
1452 func_append func_quote_result " $func_quote_arg_result"
1454 func_append func_quote_result "$func_quote_arg_result"
1461 # func_stripname PREFIX SUFFIX NAME
1462 # ---------------------------------
1463 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1464 # PREFIX and SUFFIX must not contain globbing or regex special
1465 # characters, hashes, percent signs, but SUFFIX may contain a leading
1466 # dot (in which case that matches only a dot).
1467 if test yes = "$_G_HAVE_XSI_OPS"; then
1468 eval 'func_stripname ()
1472 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1473 # positional parameters, so assign one to ordinary variable first.
1474 func_stripname_result=$3
1475 func_stripname_result=${func_stripname_result#"$1"}
1476 func_stripname_result=${func_stripname_result%"$2"}
1484 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1485 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1491 # func_show_eval CMD [FAIL_EXP]
1492 # -----------------------------
1493 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1494 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1495 # is given, then evaluate it.
1501 _G_fail_exp=${2-':'}
1503 func_quote_arg pretty,expand "$_G_cmd"
1504 eval "func_notquiet $func_quote_arg_result"
1509 if test 0 -ne "$_G_status"; then
1510 eval "(exit $_G_status); $_G_fail_exp"
1516 # func_show_eval_locale CMD [FAIL_EXP]
1517 # ------------------------------------
1518 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1519 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1520 # is given, then evaluate it. Use the saved locale for evaluation.
1521 func_show_eval_locale ()
1526 _G_fail_exp=${2-':'}
1529 func_quote_arg expand,pretty "$_G_cmd"
1530 eval "func_echo $func_quote_arg_result"
1534 eval "$_G_user_locale
1537 eval "$_G_safe_locale"
1538 if test 0 -ne "$_G_status"; then
1539 eval "(exit $_G_status); $_G_fail_exp"
1547 # Turn $1 into a string suitable for a shell variable name.
1548 # Result is stored in $func_tr_sh_result. All characters
1549 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1550 # if $1 begins with a digit, a '_' is prepended as well.
1556 [0-9]* | *[!a-zA-Z0-9_]*)
1557 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1560 func_tr_sh_result=$1
1566 # func_verbose ARG...
1567 # -------------------
1568 # Echo program name prefixed message in verbose mode only.
1573 $opt_verbose && func_echo "$*"
1579 # func_warn_and_continue ARG...
1580 # -----------------------------
1581 # Echo program name prefixed warning message to standard error.
1582 func_warn_and_continue ()
1586 $require_term_colors
1588 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1592 # func_warning CATEGORY ARG...
1593 # ----------------------------
1594 # Echo program name prefixed warning message to standard error. Warning
1595 # messages can be filtered according to CATEGORY, where this function
1596 # elides messages where CATEGORY is not listed in the global variable
1597 # 'opt_warning_types'.
1602 # CATEGORY must be in the warning_categories list!
1603 case " $warning_categories " in
1605 *) func_internal_error "invalid warning category '$1'" ;;
1611 case " $opt_warning_types " in
1612 *" $_G_category "*) $warning_func ${1+"$@"} ;;
1617 # func_sort_ver VER1 VER2
1618 # -----------------------
1619 # 'sort -V' is not generally available.
1620 # Note this deviates from the version comparison in automake
1621 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1622 # but this should suffice as we won't be specifying old
1623 # version formats or redundant trailing .0 in bootstrap.conf.
1624 # If we did want full compatibility then we should probably
1625 # use m4_version_compare from autoconf.
1630 printf '%s\n%s\n' "$1" "$2" \
1631 | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
1634 # func_lt_ver PREV CURR
1635 # ---------------------
1636 # Return true if PREV and CURR are in the correct order according to
1637 # func_sort_ver, otherwise false. Use it like this:
1639 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1644 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1649 # mode: shell-script
1651 # eval: (add-hook 'before-save-hook 'time-stamp)
1652 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1653 # time-stamp-time-zone: "UTC"
1657 # A portable, pluggable option parser for Bourne shell.
1658 # Written by Gary V. Vaughan, 2010
1660 # This is free software. There is NO warranty; not even for
1661 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1663 # Copyright (C) 2010-2019 Bootstrap Authors
1665 # This file is dual licensed under the terms of the MIT license
1666 # <https://opensource.org/license/MIT>, and GPL version 2 or later
1667 # <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of
1668 # these licenses when using or redistributing this software or any of
1669 # the files within it. See the URLs above, or the file `LICENSE`
1670 # included in the Bootstrap distribution for the full license texts.
1672 # Please report bugs or propose patches to:
1673 # <https://github.com/gnulib-modules/bootstrap/issues>
1675 # Set a version string for this script.
1676 scriptversion=2019-02-19.15; # UTC
1683 # This file is a library for parsing options in your shell scripts along
1684 # with assorted other useful supporting features that you can make use
1687 # For the simplest scripts you might need only:
1690 # . relative/path/to/funclib.sh
1691 # . relative/path/to/options-parser
1693 # func_options ${1+"$@"}
1694 # eval set dummy "$func_options_result"; shift
1695 # ...rest of your script...
1697 # In order for the '--version' option to work, you will need to have a
1698 # suitably formatted comment like the one at the top of this file
1699 # starting with '# Written by ' and ending with '# Copyright'.
1701 # For '-h' and '--help' to work, you will also need a one line
1702 # description of your script's purpose in a comment directly above the
1703 # '# Written by ' line, like the one at the top of this file.
1705 # The default options also support '--debug', which will turn on shell
1706 # execution tracing (see the comment above debug_cmd below for another
1707 # use), and '--verbose' and the func_verbose function to allow your script
1708 # to display verbose messages only when your user has specified
1711 # After sourcing this file, you can plug in processing for additional
1712 # options by amending the variables from the 'Configuration' section
1713 # below, and following the instructions in the 'Option parsing'
1714 # section further down.
1716 ## -------------- ##
1717 ## Configuration. ##
1718 ## -------------- ##
1720 # You should override these variables in your script after sourcing this
1721 # file so that they reflect the customisations you have added to the
1724 # The usage line for option parsing errors and the start of '-h' and
1725 # '--help' output messages. You can embed shell variables for delayed
1726 # expansion at the time the message is displayed, but you will need to
1727 # quote other shell meta-characters carefully to prevent them being
1728 # expanded when the contents are evaled.
1729 usage='$progpath [OPTION]...'
1731 # Short help message in response to '-h' and '--help'. Add to this or
1732 # override it after sourcing this library to reflect the full set of
1733 # options your script accepts.
1735 --debug enable verbose shell tracing
1736 -W, --warnings=CATEGORY
1737 report the warnings falling in CATEGORY [all]
1738 -v, --verbose verbosely report processing
1739 --version print version information and exit
1740 -h, --help print short or long help message and exit
1743 # Additional text appended to 'usage_message' in response to '--help'.
1745 Warning categories include:
1746 'all' show all warnings
1747 'none' turn off all the warnings
1748 'error' warnings are treated as fatal errors"
1750 # Help message printed before fatal option parsing errors.
1751 fatal_help="Try '\$progname --help' for more information."
1755 ## ------------------------- ##
1756 ## Hook function management. ##
1757 ## ------------------------- ##
1759 # This section contains functions for adding, removing, and running hooks
1760 # in the main code. A hook is just a list of function names that can be
1761 # run in order later on.
1763 # func_hookable FUNC_NAME
1764 # -----------------------
1765 # Declare that FUNC_NAME will run hooks added with
1766 # 'func_add_hook FUNC_NAME ...'.
1771 func_append hookable_fns " $1"
1775 # func_add_hook FUNC_NAME HOOK_FUNC
1776 # ---------------------------------
1777 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
1778 # first have been declared "hookable" by a call to 'func_hookable'.
1783 case " $hookable_fns " in
1785 *) func_fatal_error "'$1' does not accept hook functions." ;;
1788 eval func_append ${1}_hooks '" $2"'
1792 # func_remove_hook FUNC_NAME HOOK_FUNC
1793 # ------------------------------------
1794 # Remove HOOK_FUNC from the list of hook functions to be called by
1800 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1804 # func_propagate_result FUNC_NAME_A FUNC_NAME_B
1805 # ---------------------------------------------
1806 # If the *_result variable of FUNC_NAME_A _is set_, assign its value to
1807 # *_result variable of FUNC_NAME_B.
1808 func_propagate_result ()
1812 func_propagate_result_result=:
1813 if eval "test \"\${${1}_result+set}\" = set"
1815 eval "${2}_result=\$${1}_result"
1817 func_propagate_result_result=false
1822 # func_run_hooks FUNC_NAME [ARG]...
1823 # ---------------------------------
1824 # Run all hook functions registered to FUNC_NAME.
1825 # It's assumed that the list of hook functions contains nothing more
1826 # than a whitespace-delimited list of legal shell function names, and
1827 # no effort is wasted trying to catch shell meta-characters or preserve
1833 case " $hookable_fns " in
1835 *) func_fatal_error "'$1' does not support hook functions." ;;
1838 eval _G_hook_fns=\$$1_hooks; shift
1840 for _G_hook in $_G_hook_fns; do
1841 func_unset "${_G_hook}_result"
1842 eval $_G_hook '${1+"$@"}'
1843 func_propagate_result $_G_hook func_run_hooks
1844 if $func_propagate_result_result; then
1845 eval set dummy "$func_run_hooks_result"; shift
1852 ## --------------- ##
1853 ## Option parsing. ##
1854 ## --------------- ##
1856 # In order to add your own option parsing hooks, you must accept the
1857 # full positional parameter list from your hook function. You may remove
1858 # or edit any options that you action, and then pass back the remaining
1859 # unprocessed options in '<hooked_function_name>_result', escaped
1860 # suitably for 'eval'.
1862 # The '<hooked_function_name>_result' variable is automatically unset
1863 # before your hook gets called; for best performance, only set the
1864 # *_result variable when necessary (i.e. don't call the 'func_quote'
1865 # function unnecessarily because it can be an expensive operation on some
1870 # my_options_prep ()
1874 # # Extend the existing usage message.
1875 # usage_message=$usage_message'
1876 # -s, --silent don'\''t print informational messages
1878 # # No change in '$@' (ignored completely by this hook). Leave
1879 # # my_options_prep_result variable intact.
1881 # func_add_hook func_options_prep my_options_prep
1884 # my_silent_option ()
1888 # args_changed=false
1890 # # Note that, for efficiency, we parse as many options as we can
1891 # # recognise in a loop before passing the remainder back to the
1892 # # caller on the first unrecognised argument we encounter.
1893 # while test $# -gt 0; do
1896 # --silent|-s) opt_silent=:
1899 # # Separate non-argument short options:
1900 # -s*) func_split_short_opt "$_G_opt"
1901 # set dummy "$func_split_short_opt_name" \
1902 # "-$func_split_short_opt_arg" ${1+"$@"}
1906 # *) # Make sure the first unrecognised option "$_G_opt"
1907 # # is added back to "$@" in case we need it later,
1908 # # if $args_changed was set to 'true'.
1909 # set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1913 # # Only call 'func_quote' here if we processed at least one argument.
1914 # if $args_changed; then
1915 # func_quote eval ${1+"$@"}
1916 # my_silent_option_result=$func_quote_result
1919 # func_add_hook func_parse_options my_silent_option
1922 # my_option_validation ()
1926 # $opt_silent && $opt_verbose && func_fatal_help "\
1927 # '--silent' and '--verbose' options are mutually exclusive."
1929 # func_add_hook func_validate_options my_option_validation
1931 # You'll also need to manually amend $usage_message to reflect the extra
1932 # options you parse. It's preferable to append if you can, so that
1933 # multiple option parsing hooks can be added safely.
1936 # func_options_finish [ARG]...
1937 # ----------------------------
1938 # Finishing the option parse loop (call 'func_options' hooks ATM).
1939 func_options_finish ()
1943 func_run_hooks func_options ${1+"$@"}
1944 func_propagate_result func_run_hooks func_options_finish
1948 # func_options [ARG]...
1949 # ---------------------
1950 # All the functions called inside func_options are hookable. See the
1951 # individual implementations for details.
1952 func_hookable func_options
1957 _G_options_quoted=false
1959 for my_func in options_prep parse_options validate_options options_finish
1961 func_unset func_${my_func}_result
1962 func_unset func_run_hooks_result
1963 eval func_$my_func '${1+"$@"}'
1964 func_propagate_result func_$my_func func_options
1965 if $func_propagate_result_result; then
1966 eval set dummy "$func_options_result"; shift
1971 $_G_options_quoted || {
1972 # As we (func_options) are top-level options-parser function and
1973 # nobody quoted "$@" for us yet, we need to do it explicitly for
1975 func_quote eval ${1+"$@"}
1976 func_options_result=$func_quote_result
1981 # func_options_prep [ARG]...
1982 # --------------------------
1983 # All initialisations required before starting the option parse loop.
1984 # Note that when calling hook functions, we pass through the list of
1985 # positional parameters. If a hook function modifies that list, and
1986 # needs to propagate that back to rest of this script, then the complete
1987 # modified list must be put in 'func_run_hooks_result' before returning.
1988 func_hookable func_options_prep
1989 func_options_prep ()
1997 func_run_hooks func_options_prep ${1+"$@"}
1998 func_propagate_result func_run_hooks func_options_prep
2002 # func_parse_options [ARG]...
2003 # ---------------------------
2004 # The main option parsing loop.
2005 func_hookable func_parse_options
2006 func_parse_options ()
2010 _G_parse_options_requote=false
2011 # this just eases exit handling
2012 while test $# -gt 0; do
2013 # Defer to hook functions for initial option parsing, so they
2014 # get priority in the event of reusing an option name.
2015 func_run_hooks func_parse_options ${1+"$@"}
2016 func_propagate_result func_run_hooks func_parse_options
2017 if $func_propagate_result_result; then
2018 eval set dummy "$func_parse_options_result"; shift
2019 # Even though we may have changed "$@", we passed the "$@" array
2020 # down into the hook and it quoted it for us (because we are in
2021 # this if-branch). No need to quote it again.
2022 _G_parse_options_requote=false
2025 # Break out of the loop if we already parsed every option.
2026 test $# -gt 0 || break
2028 # We expect that one of the options parsed in this function matches
2029 # and thus we remove _G_opt from "$@" and need to re-quote.
2030 _G_match_parse_options=:
2034 --debug|-x) debug_cmd='set -x'
2035 func_echo "enabling shell trace mode" >&2
2039 --no-warnings|--no-warning|--no-warn)
2040 set dummy --warnings none ${1+"$@"}
2044 --warnings|--warning|-W)
2045 if test $# = 0 && func_missing_arg $_G_opt; then
2046 _G_parse_options_requote=:
2049 case " $warning_categories $1" in
2051 # trailing space prevents matching last $1 above
2052 func_append_uniq opt_warning_types " $1"
2055 opt_warning_types=$warning_categories
2058 opt_warning_types=none
2062 opt_warning_types=$warning_categories
2063 warning_func=func_fatal_error
2067 "unsupported warning category: '$1'"
2073 --verbose|-v) opt_verbose=: ;;
2074 --version) func_version ;;
2075 -\?|-h) func_usage ;;
2076 --help) func_help ;;
2078 # Separate optargs to long options (plugins may need this):
2079 --*=*) func_split_equals "$_G_opt"
2080 set dummy "$func_split_equals_lhs" \
2081 "$func_split_equals_rhs" ${1+"$@"}
2085 # Separate optargs to short options:
2087 func_split_short_opt "$_G_opt"
2088 set dummy "$func_split_short_opt_name" \
2089 "$func_split_short_opt_arg" ${1+"$@"}
2093 # Separate non-argument short options:
2095 func_split_short_opt "$_G_opt"
2096 set dummy "$func_split_short_opt_name" \
2097 "-$func_split_short_opt_arg" ${1+"$@"}
2101 --) _G_parse_options_requote=: ; break ;;
2102 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
2103 *) set dummy "$_G_opt" ${1+"$@"}; shift
2104 _G_match_parse_options=false
2109 if $_G_match_parse_options; then
2110 _G_parse_options_requote=:
2114 if $_G_parse_options_requote; then
2115 # save modified positional parameters for caller
2116 func_quote eval ${1+"$@"}
2117 func_parse_options_result=$func_quote_result
2122 # func_validate_options [ARG]...
2123 # ------------------------------
2124 # Perform any sanity checks on option settings and/or unconsumed
2126 func_hookable func_validate_options
2127 func_validate_options ()
2131 # Display all warnings if -W was not given.
2132 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
2134 func_run_hooks func_validate_options ${1+"$@"}
2135 func_propagate_result func_run_hooks func_validate_options
2137 # Bail if the options were screwed!
2138 $exit_cmd $EXIT_FAILURE
2143 ## ----------------- ##
2144 ## Helper functions. ##
2145 ## ----------------- ##
2147 # This section contains the helper functions used by the rest of the
2148 # hookable option parser framework in ascii-betical order.
2151 # func_fatal_help ARG...
2152 # ----------------------
2153 # Echo program name prefixed message to standard error, followed by
2154 # a help hint, and exit.
2159 eval \$ECHO \""Usage: $usage"\"
2160 eval \$ECHO \""$fatal_help"\"
2161 func_error ${1+"$@"}
2168 # Echo long help message to standard output and exit.
2174 $ECHO "$long_help_message"
2179 # func_missing_arg ARGNAME
2180 # ------------------------
2181 # Echo program name prefixed message to standard error and set global
2187 func_error "Missing argument for '$1'."
2192 # func_split_equals STRING
2193 # ------------------------
2194 # Set func_split_equals_lhs and func_split_equals_rhs shell variables
2195 # after splitting STRING at the '=' sign.
2196 test -z "$_G_HAVE_XSI_OPS" \
2198 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
2199 && _G_HAVE_XSI_OPS=yes
2201 if test yes = "$_G_HAVE_XSI_OPS"
2203 # This is an XSI compatible shell, allowing a faster implementation...
2204 eval 'func_split_equals ()
2208 func_split_equals_lhs=${1%%=*}
2209 func_split_equals_rhs=${1#*=}
2210 if test "x$func_split_equals_lhs" = "x$1"; then
2211 func_split_equals_rhs=
2215 # ...otherwise fall back to using expr, which is often a shell builtin.
2216 func_split_equals ()
2220 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
2221 func_split_equals_rhs=
2222 test "x$func_split_equals_lhs" = "x$1" \
2223 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
2225 fi #func_split_equals
2228 # func_split_short_opt SHORTOPT
2229 # -----------------------------
2230 # Set func_split_short_opt_name and func_split_short_opt_arg shell
2231 # variables after splitting SHORTOPT after the 2nd character.
2232 if test yes = "$_G_HAVE_XSI_OPS"
2234 # This is an XSI compatible shell, allowing a faster implementation...
2235 eval 'func_split_short_opt ()
2239 func_split_short_opt_arg=${1#??}
2240 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
2243 # ...otherwise fall back to using expr, which is often a shell builtin.
2244 func_split_short_opt ()
2248 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
2249 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
2251 fi #func_split_short_opt
2256 # Echo short help message to standard output and exit.
2262 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
2267 # func_usage_message
2268 # ------------------
2269 # Echo short help message to standard output.
2270 func_usage_message ()
2274 eval \$ECHO \""Usage: $usage"\"
2281 /^Written by/q' < "$progpath"
2283 eval \$ECHO \""$usage_message"\"
2289 # Echo version message to standard output and exit.
2290 # The version message is extracted from the calling file's header
2291 # comments, with leading '# ' stripped:
2292 # 1. First display the progname and version
2293 # 2. Followed by the header comment line matching /^# Written by /
2294 # 3. Then a blank line followed by the first following line matching
2296 # 4. Immediately followed by any lines between the previous matches,
2297 # except lines preceding the intervening completely blank line.
2298 # For example, see the header comments of this file.
2303 printf '%s\n' "$progname $scriptversion"
2324 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
2334 # mode: shell-script
2336 # eval: (add-hook 'before-save-hook 'time-stamp)
2337 # time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2338 # time-stamp-time-zone: "UTC"
2342 # Extract macro arguments from autotools input with GNU M4.
2343 # Written by Gary V. Vaughan, 2010
2345 # This is free software. There is NO warranty; not even for
2346 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2348 # Copyright (C) 2010-2019 Bootstrap Authors
2350 # This file is dual licensed under the terms of the MIT license
2351 # <https://opensource.org/license/MIT>, and GPL version 2 or later
2352 # <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of
2353 # these licenses when using or redistributing this software or any of
2354 # the files within it. See the URLs above, or the file `LICENSE`
2355 # included in the Bootstrap distribution for the full license texts.
2357 # Please report bugs or propose patches to:
2358 # <https://github.com/gnulib-modules/bootstrap/issues>
2360 # Make sure we've evaluated scripts we depend on.
2361 test -z "$progpath" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/funclib.sh
2362 test extract-trace = "$progname" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/options-parser
2364 # Set a version string.
2365 scriptversion=2019-02-19.15; # UTC
2372 # Run './extract-trace --help' for help with using this script from the
2375 # Or source first 'options-parser' and then this file into your own
2376 # scripts in order to make use of the function and variable framework
2377 # they define, and also to avoid the overhead of forking to run this
2378 # script in its own process on every call.
2382 ## ----------------- ##
2383 ## Helper functions. ##
2384 ## ----------------- ##
2386 # This section contains the helper functions used by the rest of
2390 # func_autoconf_configure MAYBE-CONFIGURE-FILE
2391 # --------------------------------------------
2392 # Ensure that MAYBE-CONFIGURE-FILE is the name of a file in the current
2393 # directory that contains an uncommented call to AC_INIT.
2394 func_autoconf_configure ()
2404 # If we were passed a genuine file, make sure it calls AC_INIT.
2406 && _G_ac_init=`$SED "$_G_sed_no_comment" "$1" |$GREP AC_INIT`
2408 # Otherwise it is not a genuine Autoconf input file.
2409 test -n "$_G_ac_init"
2412 test 0 -ne "$_G_status" \
2413 && func_verbose "'$1' not using Autoconf"
2419 # func_tool_version_output CMD [FATAL-ERROR-MSG]
2420 # ----------------------------------------------
2421 # Attempt to run 'CMD --version', discarding errors. The output can be
2422 # ignored by redirecting stdout, and this function used simply to test
2423 # whether the command exists and exits normally when passed a
2424 # '--version' argument.
2425 # When FATAL-ERROR-MSG is given, then this function will display the
2426 # message and exit if running 'CMD --version' returns a non-zero exit
2428 func_tool_version_output ()
2433 _G_fatal_error_msg=$2
2435 # Some tools, like 'git2cl' produce thousands of lines of output
2436 # unless stdin is /dev/null - in that case we want to return
2437 # successfully without saving all of that output. Other tools,
2438 # such as 'help2man' exit with a non-zero status when stdin comes
2439 # from /dev/null, so we re-execute without /dev/null if that
2440 # happens. This means that occasionally, the output from both calls
2441 # ends up in the result, but the alternative would be to discard the
2442 # output from one call, and hope the other produces something useful.
2443 { $_G_cmd --version </dev/null || $_G_cmd --version; } 2>/dev/null
2446 test 0 -ne "$_G_status" && test -n "$_G_fatal_error_msg" \
2447 && func_fatal_error "$_G_fatal_error_msg"
2453 # func_tool_version_number CMD [FATAL-ERROR-MSG]
2454 # ----------------------------------------------
2455 # Pass arguments to func_tool_version_output, but set
2456 # $func_tool_version_number_result to the last dot delimited digit string
2457 # on the first line of output.
2458 func_tool_version_number ()
2462 _G_verout=`func_tool_version_output "$@"`
2465 # A version number starts with a digit following a space on the first
2466 # line of output from `--version`.
2467 _G_verout=`echo "$_G_verout" |sed 1q`
2468 if test -n "$_G_verout"; then
2469 _G_vernum=`expr "$_G_verout" : '.* \([0-9][^ ]*\)'`
2472 if test -n "$_G_vernum"; then
2473 printf '%s\n' "$_G_vernum"
2475 printf '%s\n' "$_G_verout"
2482 # func_find_tool ENVVAR NAMES...
2483 # ------------------------------
2484 # Search for a required program. Use the value of ENVVAR, if set,
2485 # otherwise find the first of the NAMES that can be run (i.e.,
2486 # supports --version). If found, set ENVVAR to the program name,
2492 _G_find_tool_envvar=$1
2494 _G_find_tool_names=$@
2495 eval "_G_find_tool_res=\$$_G_find_tool_envvar"
2496 if test -n "$_G_find_tool_res"; then
2497 _G_find_tool_error_prefix="\$$find_tool_envvar: "
2503 _G_find_tool_save_IFS=$IFS
2504 IFS=${PATH_SEPARATOR-:}
2505 for _G_dir in $PATH; do
2506 IFS=$_G_find_tool_save_IFS
2507 _G_progpath=$_G_dir/$_G_prog
2508 test -r "$_G_progpath" && {
2509 _G_curver=`func_tool_version_number $_G_progpath`
2510 case $_G_bestver,$_G_curver in
2512 # first non--version responsive prog sticks!
2513 test -n "$_G_progpath" || _G_find_tool_res=$_G_progpath
2516 # first --version responsive prog beats non--version responsive!
2517 _G_find_tool_res=$_G_progpath
2518 _G_bestver=$_G_curver
2521 # another --version responsive prog must be newer to beat previous one!
2522 test "x$_G_curver" = "x$_G_bestver" \
2523 || func_lt_ver "$_G_curver" "$_G_bestver" \
2525 _G_find_tool_res=$_G_progpath
2526 _G_bestver=$_G_curver
2532 IFS=$_G_find_tool_save_IFS
2535 if test -n "$_G_find_tool_res"; then
2536 func_tool_version_number >/dev/null $_G_find_tool_res "\
2537 ${_G_find_tool_error_prefix}Cannot run '$_G_find_tool_res --version'"
2539 # Make sure the result is exported to the environment for children
2541 eval "$_G_find_tool_envvar=\$_G_find_tool_res"
2542 eval "export $_G_find_tool_envvar"
2545 One of these is required:
2546 $_G_find_tool_names"
2552 ## -------------------- ##
2553 ## Resource management. ##
2554 ## -------------------- ##
2556 # This section contains definitions for functions that each ensure a
2557 # particular resource (a file, or a non-empty configuration variable for
2558 # example) is available, and if appropriate to extract default values
2559 # from pertinent package files. Where a variable already has a non-
2560 # empty value (as set by the package's 'bootstrap.conf'), that value is
2561 # used in preference to deriving the default. Call them using their
2562 # associated 'require_*' variable to ensure that they are executed, at
2565 # It's entirely deliberate that calling these functions can set
2566 # variables that don't obey the namespace limitations obeyed by the rest
2567 # of this file, in order that that they be as useful as possible to
2571 # require_configure_ac
2572 # --------------------
2573 # Ensure that there is a 'configure.ac' or 'configure.in' file in the
2574 # current directory that contains an uncommented call to AC_INIT, and
2575 # that '$configure_ac' contains its name.
2576 require_configure_ac=func_require_configure_ac
2577 func_require_configure_ac ()
2581 test -z "$configure_ac" \
2582 && func_autoconf_configure configure.ac && configure_ac=configure.ac
2583 test -z "$configure_ac" \
2584 && func_autoconf_configure configure.in && configure_ac=configure.in
2585 test -z "$configure_ac" \
2586 || func_verbose "found '$configure_ac'"
2588 require_configure_ac=:
2594 # Search for GNU M4, and export it in $M4.
2595 require_gnu_m4=func_require_gnu_m4
2596 func_require_gnu_m4 ()
2601 # Find the first m4 binary that responds to --version.
2602 func_find_tool M4 gm4 gnum4 m4
2605 test -n "$M4" || func_fatal_error "\
2606 Please install GNU M4, or 'export M4=/path/to/gnu/m4'."
2608 func_verbose "export M4='$M4'"
2610 # Make sure the search result is visible to subshells
2617 ## --------------- ##
2618 ## Core functions. ##
2619 ## --------------- ##
2621 # This section contains the high level functions used when calling this
2622 # file as a script. 'func_extract_trace' is probably the only one that you
2623 # won't want to replace if you source this file into your own script.
2626 # func_extract_trace MACRO_NAMES [FILENAME]...
2627 # --------------------------------------------
2628 # set '$func_extract_trace_result' to a colon delimited list of arguments
2629 # to any of the comma separated list of MACRO_NAMES in FILENAME. If no
2630 # FILENAME is given, then '$configure_ac' is assumed.
2631 func_extract_trace ()
2635 $require_configure_ac
2638 _G_m4_traces=`$ECHO "--trace=$1" |$SED 's%,% --trace=%g'`
2639 _G_re_macros=`$ECHO "($1)" |$SED 's%,%|%g'`
2640 _G_macros="$1"; shift
2642 set dummy $configure_ac
2646 # Generate an error if the first file is missing
2649 # Sadly, we can't use 'autom4te' tracing to extract macro arguments,
2650 # because it complains about things we want to ignore at bootstrap
2651 # time - like missing m4_include files; AC_PREREQ being newer than
2652 # the installed autoconf; and returns nothing when tracing
2653 # 'AM_INIT_AUTOMAKE' when aclocal hasn't been generated yet.
2655 # The following tries to emulate a less persnickety version of (and
2656 # due to not having to wait for Perl startup on every invocation,
2657 # it's probably faster too):
2659 # autom4te --language=Autoconf --trace=$my_macro:\$% "$@"
2661 # First we give a minimal set of macro declarations to M4 to prime
2662 # it for reading Autoconf macros, while still providing some of the
2663 # functionality generally used at m4-time to supply dynamic
2664 # arguments to Autocof functions, but without following
2665 # 'm4_s?include' files.
2669 m4_define([m4_copy], [m4_define([$2], m4_defn([$1]))])
2670 m4_define([m4_rename], [m4_copy([$1], [$2])m4_undefine([$1])])
2672 dnl Replace macros which may abort m4 with a no-op variant.
2673 m4_pushdef([m4_assert])
2674 m4_pushdef([m4_exit])
2675 m4_pushdef([m4_fatal])
2676 m4_pushdef([m4_m4exit])
2678 dnl Replace macros that might break stderr of m4.
2679 m4_pushdef([m4_errprint])
2680 m4_pushdef([m4_errprintn])
2681 m4_pushdef([m4_include])
2682 m4_pushdef([m4_warn])
2684 dnl Avoid side-effects of tracing by extract-trace.
2685 m4_pushdef([m4_maketemp])
2686 m4_pushdef([m4_mkstemp])
2688 dnl TODO: reasons for this
2689 m4_pushdef([m4_dnl])
2690 m4_pushdef([m4_m4wrap])
2692 dnl Copy and rename macros not handled by "m4 --prefix".
2693 m4_define([dnl], [m4_builtin([dnl])])
2694 m4_copy([m4_define], [m4_defun])
2695 m4_rename([m4_ifelse], [m4_if])
2696 m4_rename([m4_patsubst], [m4_bpatsubst])
2697 m4_rename([m4_regexp], [m4_bregexp])
2699 dnl "m4sugar.mini" - useful m4-time macros for dynamic arguments.
2700 dnl If we discover packages that need more m4 macros defined in
2701 dnl order to bootstrap correctly, add them here:
2702 m4_define([m4_bmatch],
2703 [m4_if([$#], 0, [], [$#], 1, [], [$#], 2, [$2],
2704 [m4_if(m4_bregexp([$1], [$2]), -1,
2705 [$0([$1], m4_shift3($@))], [$3])])])
2706 m4_define([m4_ifndef], [m4_ifdef([$1], [$3], [$2])])
2707 m4_define([m4_ifset],
2708 [m4_ifdef([$1], [m4_ifval(m4_defn([$1]), [$2], [$3])], [$3])])
2709 m4_define([m4_require], [$1])
2710 m4_define([m4_shift3], [m4_shift(m4shift(m4shift($@)))])
2712 dnl "autoconf.mini" - things from autoconf macros we care about.
2713 m4_copy([m4_defun], [AC_DEFUN])
2715 dnl Dummy definitions for the macros we want to trace.
2716 dnl AM_INIT_AUTOMAKE at least produces no trace without this.
2721 for _G_macro in $_G_macros; do
2723 func_append _G_mini "AC_DEFUN([$_G_macro])$nl"
2727 # We discard M4's stdout, but the M4 trace output from reading our
2728 # "autoconf.mini" followed by any other files passed to this
2729 # function is then scanned by sed to transform it into a colon
2730 # delimited argument list assigned to a shell variable.
2731 _G_transform='s|#.*$||; s|^dnl .*$||; s| dnl .*$||;'
2733 # Unfortunately, alternation in regexp addresses doesn't work in at
2734 # least BSD (and hence Mac OS X) sed, so we have to append a capture
2735 # and print block for each traced macro to the sed transform script.
2738 for _G_macro in $_G_macros; do
2740 func_append _G_transform '
2741 /^m4trace: -1- '"$_G_macro"'/ {
2742 s|^m4trace: -1- '"$_G_macro"'[([]*||
2751 # Save the command pipeline results for further use by callers of
2753 func_extract_trace_result=`$ECHO "$_G_mini" \
2754 |$M4 -daq --prefix $_G_m4_traces - "$@" 2>&1 1>/dev/null \
2755 |$SED -n -e "$_G_transform"`
2759 # func_extract_trace_first MACRO_NAMES [FILENAME]...
2760 # --------------------------------------------------
2761 # Exactly like func_extract_trace, except that only the first argument
2762 # to the first invocation of one of the comma separated MACRO_NAMES is
2763 # returned in '$func_extract_trace_first_result'.
2764 func_extract_trace_first ()
2768 func_extract_trace ${1+"$@"}
2769 func_extract_trace_first_result=`$ECHO "$func_extract_trace_result" \
2770 |$SED -e 's|:.*$||g' -e 1q`
2774 # func_main [ARG]...
2775 # ------------------
2781 usage='$progname MACRO_NAME FILE [...]'
2784 The first argument to this program is the name of an autotools macro
2785 whose arguments you want to extract by examining the files listed in the
2786 remaining arguments using the same tool that Autoconf and Automake use,
2789 The arguments are returned separated by colons, with each traced call
2790 on a separate line.'
2792 # Option processing.
2794 eval set dummy "$func_options_result"; shift
2796 # Validate remaining non-option arguments.
2798 || func_fatal_help "not enough arguments"
2800 # Pass non-option arguments to extraction function.
2801 func_extract_trace "$@"
2804 test -n "$func_extract_trace_result" \
2805 && $ECHO "$func_extract_trace_result"
2812 ## --------------------------- ##
2813 ## Actually perform the trace. ##
2814 ## --------------------------- ##
2816 # Only call 'func_main' if this script was called directly.
2817 test extract-trace = "$progname" && func_main "$@"
2820 # mode: shell-script
2822 # eval: (add-hook 'before-save-hook 'time-stamp)
2823 # time-stamp-pattern: "50/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2824 # time-stamp-time-zone: "UTC"
2827 # Set a version string for *this* script.
2828 scriptversion=2019-03-22.11; # UTC
2831 ## ------------------- ##
2832 ## Hookable functions. ##
2833 ## ------------------- ##
2835 # After 'bootstrap.conf' has been sourced, execution proceeds by calling
2836 # 'func_bootstrap'. Wherever a function is decorated with
2837 # 'func_hookable func_name', you will find a matching 'func_run_hooks
2838 # func_name', which executes all functions added with 'func_add_hook
2839 # func_name my_func'.
2841 # You might notice that many of these functions begin with a series of
2842 # '$require_foo' lines. See the docu-comments at the start of the
2843 # 'Resource management' section for a description of what these are.
2846 # func_bootstrap [ARG]...
2847 # -----------------------
2848 # All the functions called inside func_bootstrap are hookable. See the
2849 # the individual implementations for details.
2854 # Save the current positional parameters to prevent them being
2855 # corrupted by calls to 'set' in 'func_init'.
2856 func_quote eval ${1+"$@"}
2857 _G_saved_positional_parameters=$func_quote_result
2862 # Option processing.
2863 eval func_options "$_G_saved_positional_parameters"
2865 # Post-option preparation.
2868 # Reconfigure the package.
2871 # Ensure .version is up-to-date.
2872 func_update_dotversion
2881 # Any early initialisations can be hooked to this function. Consider
2882 # whether you can hook onto 'func_prep' instead, because if you hook
2883 # any slow to execute code in here, it will also add to the time before
2884 # './bootstrap --version' can respond.
2885 func_hookable func_init
2890 func_run_hooks func_init
2896 # Function to perform preparation for remaining bootstrap process. If
2897 # your hooked code relies on the outcome of 'func_options' hook it here
2898 # rather than to 'func_init'.
2900 # All the functions called inside func_prep are hookable. See the
2901 # individual implementations for details.
2902 func_hookable func_prep
2907 $require_buildtools_uptodate
2908 $require_checkout_only_file
2910 $require_gnulib_merge_changelog
2912 # Report the results of SED and GREP searches from funclib.sh.
2913 func_verbose "GREP='$GREP'"
2914 func_verbose "SED='$SED'"
2916 # fetch update files from the translation project
2917 func_update_translations
2919 func_run_hooks func_prep
2923 # func_update_translations
2924 # ------------------------
2925 # Update package po files and translations.
2926 func_hookable func_update_translations
2927 func_update_translations ()
2935 func_update_po_files po $package || exit $?
2938 func_run_hooks func_update_translations
2945 # Reconfigure the current package by running the appropriate autotools in a
2947 func_hookable func_reconfigure
2952 $require_automake_options
2954 # Automake (without 'foreign' option) requires that NEWS & README exist.
2955 case " $automake_options " in
2963 # Ensure ChangeLog presence.
2964 if test -n "$gnulib_modules"; then
2965 func_ifcontains "$gnulib_modules" gitlog-to-changelog \
2966 func_ensure_changelog
2968 $require_gnulib_cache
2969 if $SED -n '/^gl_MODULES(\[/,/^])$/p' $gnulib_cache 2>/dev/null |
2970 func_grep_q gitlog-to-changelog
2972 func_ensure_changelog
2976 # Released 'autopoint' has the tendency to install macros that have
2977 # been obsoleted in current 'gnulib', so run this before 'gnulib-tool'.
2980 # Autoreconf runs 'aclocal' before 'libtoolize', which causes spurious
2981 # warnings if the initial 'aclocal' is confused by the libtoolized
2982 # (or worse: out-of-date) macro directory.
2985 # If you need to do anything after 'gnulib-tool' is done, but before
2986 # 'autoreconf' runs, you don't need to override this whole function,
2987 # because 'func_gnulib_tool' is hookable.
2992 func_run_hooks func_reconfigure
2998 # Run 'gnulib-tool' to fetch gnulib modules into the current package.
3000 # It's assumed that since you are using gnulib's 'bootstrap' script,
3001 # you're also using gnulib elsewhere in your package. If not, then
3002 # you can replace this function in 'bootstrap.conf' with:
3004 # func_gnulib_tool () { :; }
3006 # (although the function returns immediately if $gnulib_tool is set to
3007 # true in any case).
3008 func_hookable func_gnulib_tool
3013 $require_gnulib_tool
3016 test true = "$gnulib_tool" || {
3017 $require_gnulib_git_submodules
3019 # bootstrap.conf written for gnulib bootstrap expects
3020 # gnulib_tool_option_extras to which --no-changelog is appended,
3021 # but libtool bootstrap expects you to append to gnulib_tool_options
3022 # so that you can override the --no-changelog default: make sure we
3023 # support both styles so users can migrate between them easily.
3024 gnulib_tool_all_options="$gnulib_tool_options $gnulib_tool_option_extras"
3026 if test -n "$gnulib_modules"; then
3027 $require_gnulib_cache
3028 $require_gnulib_tool_base_options
3030 gnulib_mode=--import
3032 # Try not to pick up any stale values from 'gnulib-cache.m4'.
3033 rm -f "$gnulib_cache"
3035 test -n "$gnulib_tool_base_options" \
3036 && func_append_uniq gnulib_tool_all_options " $gnulib_tool_base_options"
3037 test -n "$gnulib_mk" \
3038 && func_append_uniq gnulib_tool_all_options " --makefile-name=$gnulib_mk"
3039 test -n "$tests_base" && {
3040 func_append_uniq gnulib_tool_all_options " --tests-base=$tests_base"
3041 func_append_uniq gnulib_tool_all_options " --with-tests"
3045 # 'gnulib_modules' and others are cached in 'gnulib-cache.m4':
3046 # Use 'gnulib --update' to fetch gnulib modules.
3047 gnulib_mode=--update
3050 # Add a sensible default libtool option to gnulib_tool_options.
3051 # The embedded echo is to squash whitespace before globbing.
3052 case `echo " "$gnulib_tool_all_options" "` in
3053 *" --no-libtool "*|*" --libtool "*) ;;
3054 *) if test true = "$LIBTOOLIZE"; then
3055 func_append_uniq gnulib_tool_all_options " --no-libtool"
3057 func_append_uniq gnulib_tool_all_options " --libtool"
3062 $opt_copy || func_append_uniq gnulib_tool_all_options " --symlink"
3064 func_append_uniq gnulib_tool_all_options " $gnulib_mode"
3065 func_append gnulib_tool_all_options " $gnulib_modules"
3067 # The embedded echo is to squash whitespace before display.
3068 gnulib_cmd=`echo $gnulib_tool $gnulib_tool_all_options`
3070 func_show_eval "$gnulib_cmd" 'exit $?'
3072 # Use 'gnulib-tool --copy-file' to install non-module files.
3073 func_install_gnulib_non_module_files
3076 func_run_hooks func_gnulib_tool
3082 # Function to perform all finalisation for the bootstrap process.
3083 func_hookable func_fini
3088 func_gettext_configuration
3089 func_clean_dangling_symlinks
3090 func_clean_unused_macros
3091 func_skip_po_recommendation
3093 func_run_hooks func_fini
3095 $require_bootstrap_uptodate
3097 func_echo "Done. Now you can run './configure'."
3101 # func_gettext_configuration
3102 # --------------------------
3103 # Edit configuration values into po/Makevars.
3104 func_hookable func_gettext_configuration
3105 func_gettext_configuration ()
3111 test true = "$AUTOPOINT" || {
3112 $require_copyright_holder
3113 $require_extra_locale_categories
3114 $require_package_bugreport
3116 # Escape xgettext options for sed Makevars generation below.
3117 # We have to delete blank lines in a separate script so that we don't
3118 # append \\\ to the penultimate line, and then delete the last empty
3119 # line, which messes up the variable substitution later in this
3120 # function. Note that adding a literal \\\ requires double escaping
3121 # here, once for the execution subshell, and again for the assignment,
3122 # which is why there are actually 12 (!!) backslashes in the script.
3123 _G_xgettext_options=`echo "$xgettext_options$nl" |$SED '/^$/d' |$SED '
3125 s|$| \\\\\\\\\\\\|'`
3127 # Create gettext configuration.
3128 func_echo "Creating po/Makevars from po/Makevars.template ..."
3131 /^EXTRA_LOCALE_CATEGORIES *=/s|=.*|= '"$extra_locale_categories"'|
3132 /^COPYRIGHT_HOLDER *=/s|=.*|= '"$copyright_holder"'|
3133 /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$package_bugreport"'|
3134 /^XGETTEXT_OPTIONS *=/{
3137 '"$_G_xgettext_options"' \\\
3138 $${end_of_xgettext_options+}
3141 ' po/Makevars.template >po/Makevars || exit 1
3144 func_run_hooks func_gettext_configuration
3149 ## --------------- ##
3150 ## Core functions. ##
3151 ## --------------- ##
3153 # This section contains the main functions called from the 'Hookable
3154 # functions' (shown above), and are the ones you're most likely
3155 # to want to replace with your own implementations in 'bootstrap.conf'.
3160 # If this package uses gettext, then run 'autopoint'.
3167 test true = "$AUTOPOINT" \
3168 || func_show_eval "$AUTOPOINT --force" 'exit $?'
3174 # If this package uses libtool, then run 'libtoolize'.
3181 test true = "$LIBTOOLIZE" || {
3182 _G_libtoolize_options=
3183 $opt_copy && func_append _G_libtoolize_options " --copy"
3184 $opt_force && func_append _G_libtoolize_options " --force"
3185 $opt_verbose || func_append _G_libtoolize_options " --quiet"
3186 func_show_eval "$LIBTOOLIZE$_G_libtoolize_options" 'exit $?'
3191 # func_gnulib_tool_copy_file SRC DEST
3192 # -----------------------------------
3193 # Copy SRC, a path relative to the gnulib sub-tree, to DEST, a path
3194 # relative to the top-level source directory using gnulib-tool so that
3195 # any patches or replacements in $local_gl_path are applied.
3196 func_gnulib_tool_copy_file ()
3200 $require_gnulib_tool
3203 if test true = "$gnulib_tool"; then
3204 # If gnulib-tool is not available (e.g. bootstrapping in a
3205 # distribution tarball), make sure that at least we have some
3206 # version of the required file already in place.
3207 test -f "$2" || func_fatal_error "\
3208 Can't find, copy or download '$2', a required
3209 gnulib supplied file, please provide the location of a
3210 complete 'gnulib' tree by setting 'gnulib_path' in your
3211 'bootstrap.conf' or with the '--gnulib-srcdir' option -
3212 or else specify the location of your 'git' binary by
3213 setting 'GIT' in the environment so that a fresh
3214 'gnulib' submodule can be cloned."
3216 $require_gnulib_copy_cmd
3218 $gnulib_copy_cmd $1 $2 2>/dev/null || {
3219 $require_gnulib_path
3221 func_error "'$gnulib_path/$1' does not exist"
3228 # func_install_gnulib_non_module_files
3229 # ------------------------------------
3230 # Get additional non-module files from gnulib, overriding existing files.
3231 func_install_gnulib_non_module_files ()
3236 $require_gnulib_tool
3238 test -n "$gnulib_non_module_files" && {
3241 for file in $gnulib_non_module_files; do
3243 */COPYING*) dest=COPYING;;
3244 */INSTALL) dest=INSTALL;;
3245 build-aux/missing) dest=
3246 func_warning settings "\
3247 Please remove build-aux/missing from gnulib_module_files in
3248 'bootstrap.conf', as it may clash with Automake's version."
3250 build-aux/*) dest=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
3254 # Be sure to show all copying errors before bailing out
3256 || func_gnulib_tool_copy_file "$file" "$dest" \
3257 || maybe_exit_cmd="exit $EXIT_FAILURE"
3265 # func_ensure_changelog
3266 # ---------------------
3267 # Even with 'gitlog-to-changelog' generated ChangeLogs, automake
3268 # will not run to completion with no ChangeLog file.
3269 func_ensure_changelog ()
3273 test -f ChangeLog && mv -f ChangeLog ChangeLog~
3275 cat >ChangeLog <<'EOT'
3276 ## ---------------------- ##
3277 ## DO NOT EDIT THIS FILE! ##
3278 ## ---------------------- ##
3280 ChangeLog is generated by gitlog-to-changelog.
3283 _G_message="creating dummy 'ChangeLog'"
3284 test -f ChangeLog~ \
3285 && func_append _G_message ' (backup in ChangeLog~)'
3286 func_verbose "$_G_message"
3294 # Without AM_INIT_AUTOMAKE([foreign]), automake will not run to
3295 # completion with no NEWS file, even though NEWS.md or NEWS.txt
3296 # is often preferable.
3303 for _G_news in NEWS.txt NEWS.md NEWS.rst; do
3304 test -f "$_G_news" && break
3307 test -f "$_G_news" && $LN_S $_G_news NEWS
3308 func_verbose "$LN_S $_G_news NEWS"
3315 # func_ensure_README
3316 # ------------------
3317 # Without AM_INIT_AUTOMAKE([foreign]), automake will not run to
3318 # completion with no README file, even though README.md or README.txt
3319 # is often preferable.
3320 func_ensure_README ()
3326 for _G_readme in README.txt README.md README.rst; do
3327 test -f "$_G_readme" && break
3330 test -f "$_G_readme" && $LN_S $_G_readme README
3331 func_verbose "$LN_S $_G_readme README"
3338 # func_autoreconf [SUBDIR]
3339 # ------------------------
3340 # Being careful not to re-run 'autopoint' or 'libtoolize', and not to
3341 # try to run 'autopoint', 'libtoolize' or 'autoheader' on packages that
3342 # don't use them, defer to 'autoreconf' for execution of the remaining
3343 # autotools to bootstrap this package.
3345 # Projects with multiple trees to reconfigure can hook another call to
3346 # this function onto func_reconfigure:
3348 # my_autoreconf_foo ()
3350 # func_autoreconf foo
3352 # func_add_hook func_reconfigure my_autoreconf_foo
3358 $require_build_aux # automake and others put files in here
3359 $require_macro_dir # aclocal and others put files in here
3361 # We ran these manually already, and autoreconf won't exec ':'
3362 save_AUTOPOINT=$AUTOPOINT; AUTOPOINT=true
3363 save_LIBTOOLIZE=$LIBTOOLIZE; LIBTOOLIZE=true
3365 _G_autoreconf_options=
3366 $opt_copy || func_append _G_autoreconf_options " --symlink"
3367 $opt_force && func_append _G_autoreconf_options " --force"
3368 $opt_verbose && func_append _G_autoreconf_options " --verbose"
3369 func_show_eval "$AUTORECONF$_G_autoreconf_options --install${1+ $1}" 'exit $?'
3371 AUTOPOINT=$save_AUTOPOINT
3372 LIBTOOLIZE=$save_LIBTOOLIZE
3376 # func_check_configuration VARNAME [CONFIGURE_MACRO]
3377 # --------------------------------------------------
3378 # Exit with a suitable diagnostic for an important configuration change
3379 # that needs to be made before bootstrap can run correctly.
3380 func_check_configuration ()
3384 $require_configure_ac
3386 eval 'test -n "$'$1'"' || {
3387 _G_error_msg="please set '$1' in 'bootstrap.conf'"
3388 if test -n "$configure_ac" && test -n "$2"; then
3389 func_append _G_error_msg "
3390 or add the following (or similar) to your '$configure_ac':
3394 func_fatal_error "$_G_error_msg"
3399 # func_clean_dangling_symlinks
3400 # ----------------------------
3401 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
3402 # gnulib-populated directories. Such .m4 files would cause aclocal to
3403 # fail. The following requires GNU find 4.2.3 or newer. Considering
3404 # the usual portability constraints of this script, that may seem a very
3405 # demanding requirement, but it should be ok. Ignore any failure,
3406 # which is fine, since this is only a convenience to help developers
3407 # avoid the relatively unusual case where a symlinked-to .m4 file is
3408 # git-removed from gnulib between successive runs of this script.
3409 func_clean_dangling_symlinks ()
3414 $require_source_base
3416 func_verbose "cleaning dangling symlinks"
3418 find "$macro_dir" "$source_base" \
3419 -depth \( -name '*.m4' -o -name '*.[ch]' \) \
3420 -type l -xtype l -delete > /dev/null 2>&1
3424 # func_clean_unused_macros
3425 # ------------------------
3426 # Autopoint can result in over-zealously adding macros into $macro_dir
3427 # even though they are not actually used, for example tests to help
3428 # build the 'intl' directory even though you have specified
3429 # 'AM_GNU_GETTEXT([external])' in your configure.ac. This function
3430 # looks removes any macro files that can be found in gnulib, but
3431 # are not 'm4_include'd by 'aclocal.m4'.
3432 func_clean_unused_macros ()
3436 $require_gnulib_path
3439 test -n "$gnulib_path" && test -f aclocal.m4 && {
3440 aclocal_m4s=`find . -name aclocal.m4 -print`
3442 # We use 'ls|grep' instead of 'ls *.m4' to avoid exceeding
3443 # command line length limits in some shells.
3444 for file in `cd "$macro_dir" && ls -1 |$GREP '\.m4$'`; do
3446 # Remove a macro file when aclocal.m4 does not m4_include it...
3447 func_grep_q 'm4_include([[]'$macro_dir/$file'])' $aclocal_m4s \
3448 || test ! -f "$gnulib_path/m4/$file" || {
3450 # ...and there is an identical file in gnulib...
3451 if func_cmp_s "$gnulib_path/m4/$file" "$macro_dir/$file"; then
3453 # ...and it's not in the precious list ('echo' is needed
3454 # here to squash whitespace for the match expression).
3455 case " "`echo $gnulib_precious`" " in
3457 *) rm -f "$macro_dir/$file"
3459 "removing unused gnulib file '$macro_dir/$file'"
3468 # func_skip_po_recommendation
3469 # ---------------------------
3470 # If there is a po directory, and '--skip-po' wasn't passed, let the
3471 # user know that they can use '--skip-po' on subsequent invocations.
3472 func_skip_po_recommendation ()
3478 || func_warning recommend "\
3479 If your pofiles are up-to-date, you can rerun bootstrap
3480 as '$progname --skip-po' to avoid redownloading."
3484 # func_update_dotversion
3485 # ----------------------
3486 # Even with 'gitlog-to-changelog' generated ChangeLogs, automake
3487 # will not run to completion with no ChangeLog file.
3488 func_update_dotversion ()
3492 test -f "$build_aux/git-version-gen" && {
3493 _G_message="updating .version"
3494 test -f .version && {
3495 mv .version .version~
3496 func_append _G_message " (backup in .version~)"
3498 func_verbose "updating .version"
3500 $build_aux/git-version-gen dummy-arg > .version
3506 ## -------------------- ##
3507 ## Resource management. ##
3508 ## -------------------- ##
3510 # This section contains definitions for functions that each ensure a
3511 # particular resource (a file, or a non-empty configuration variable for
3512 # example) is available, and if appropriate to extract default values
3513 # from pertinent package files. Where a variable already has a non-
3514 # empty value (as set by the package's 'bootstrap.conf'), that value is
3515 # used in preference to deriving the default. Call them using their
3516 # associated 'require_*' variable to ensure that they are executed, at
3520 # require_gnulib_git_submodules
3521 # -----------------------------
3522 # Initialize all git modules from $gnulib_git_submodules before we
3523 # run 'gnulib-tool'.
3524 require_gnulib_git_submodules=func_require_gnulib_git_submodules
3525 func_require_gnulib_git_submodules ()
3527 test -n "$gnulib_git_submodules" && {
3528 for _G_submodule in $gnulib_git_submodules
3530 func_show_eval "git submodule init -- $_G_submodule" \
3531 && func_show_eval "git submodule update -- $_G_submodule" \
3532 || func_fatal_error "Unable to init git module '$_G_submodule'."
3536 require_gnulib_git_submodules=:
3540 # require_checkout_only_file
3541 # --------------------------
3542 # Bail out if this package only bootstraps properly from a repository
3544 require_checkout_only_file=func_require_checkout_only_file
3545 func_require_checkout_only_file ()
3550 test -n "$checkout_only_file" && test ! -f "$checkout_only_file" \
3551 && func_fatal_error "\
3552 Bootstrapping from a non-checked-out distribution is risky.
3553 If you wish to bootstrap anyway, use the '--force' option."
3556 require_checkout_only_file=:
3560 # require_aclocal_amflags
3561 # -----------------------
3562 # Ensure '$aclocal_amflags' has a sensible default, extracted from
3563 # 'Makefile.am' if necessary.
3564 require_aclocal_amflags=func_require_aclocal_amflags
3565 func_require_aclocal_amflags ()
3569 $require_makefile_am
3571 _G_sed_extract_aclocal_amflags='s|#.*$||
3572 /^[ ]*ACLOCAL_AMFLAGS[ ]*=/ {
3573 s|^.*=[ ]*\(.*\)|aclocal_amflags="\1"|
3577 _G_aclocal_flags_cmd=`$SED -n "$_G_sed_extract_aclocal_amflags" \
3579 eval "$_G_aclocal_flags_cmd"
3581 func_verbose "ACLOCAL_AMFLAGS='$aclocal_amflags'"
3583 require_aclocal_amflags=:
3587 # require_autoheader
3588 # ------------------
3589 # Skip autoheader if it's not needed.
3590 require_autoheader=func_require_autoheader
3591 func_require_autoheader ()
3595 test true = "$AUTOHEADER" || {
3596 func_extract_trace AC_CONFIG_HEADERS
3597 test -n "$func_extract_trace_result" \
3598 || func_extract_trace AC_CONFIG_HEADER
3600 test -n "$func_extract_trace_result" || {
3603 func_verbose "export AUTOHEADER='$AUTOHEADER'"
3605 # Make sure the search result is visible to subshells
3610 require_autoheader=:
3614 # require_automake_options
3615 # ------------------------
3616 # Extract options from AM_AUTOMAKE_INIT.
3617 require_automake_options=func_require_automake_options
3618 func_require_automake_options ()
3622 func_extract_trace AM_INIT_AUTOMAKE
3623 automake_options=$func_extract_trace_result
3625 require_automake_options=:
3631 # Skip autopoint if it's not needed.
3632 require_autopoint=func_require_autopoint
3633 func_require_autopoint ()
3637 test true = "$AUTOPOINT" || {
3638 func_extract_trace AM_GNU_GETTEXT_VERSION
3640 test -n "$func_extract_trace_result" || {
3643 func_verbose "export AUTOPOINT='$AUTOPOINT'"
3645 # Make sure the search result is visible to subshells
3654 # require_bootstrap_uptodate
3655 # --------------------------
3656 # Complain if the version of bootstrap in the gnulib directory differs
3657 # from the one we are running.
3658 require_bootstrap_uptodate=func_require_bootstrap_uptodate
3659 func_require_bootstrap_uptodate ()
3665 _G_bootstrap_sources="
3666 $build_aux/bootstrap.in
3667 $build_aux/extract-trace
3668 $build_aux/funclib.sh
3669 $build_aux/options-parser
3672 _G_missing_bootstrap_sources=false
3673 for _G_src in $_G_bootstrap_sources; do
3674 test -f "$_G_src" || _G_missing_bootstrap_sources=:
3677 if $_G_missing_bootstrap_sources; then
3678 func_warning upgrade "\
3679 Please add bootstrap to your gnulib_modules list in
3680 'bootstrap.conf', so that I can tell you when there are
3684 $build_aux/inline-source $build_aux/bootstrap.in > bootstrap.new
3686 if func_cmp_s "$progpath" bootstrap.new; then
3688 func_verbose "bootstrap script up to date"
3690 chmod 555 bootstrap.new
3691 func_warning upgrade "\
3692 An updated bootstrap script has been generated for you in
3693 'bootstrap.new'. After you've verified that you want
3694 the changes, you can update with:
3695 mv -f bootstrap.new $progname
3698 Or you can disable this check permanently by adding the
3699 following to 'bootstrap.conf':
3700 require_bootstrap_uptodate=:"
3704 require_bootstrap_uptodate=:
3710 # Ensure that '$build_aux' is set, and if it doesn't already point to an
3711 # existing directory, create one.
3712 require_build_aux=func_require_build_aux
3713 func_require_build_aux ()
3717 test -n "$build_aux" || {
3718 func_extract_trace_first AC_CONFIG_AUX_DIR
3719 build_aux=$func_extract_trace_first_result
3720 func_check_configuration build_aux \
3721 "AC_CONFIG_AUX_DIR([name of a directory for build scripts])"
3723 func_verbose "build_aux='$build_aux'"
3726 $require_vc_ignore_files
3728 # If the build_aux directory doesn't exist, create it now, and mark it
3729 # as ignored for the VCS.
3730 if test ! -d "$build_aux"; then
3731 func_show_eval "mkdir '$build_aux'"
3733 test -n "$vc_ignore_files" \
3734 || func_insert_if_absent "$build_aux" $vc_ignore_files
3741 # require_buildreq_autobuild
3742 # --------------------------
3743 # Try to find whether the bootstrap requires autobuild.
3744 require_buildreq_autobuild=func_require_buildreq_autobuild
3745 func_require_buildreq_autobuild ()
3751 test -f "$macro_dir/autobuild.m4" \
3752 || printf '%s\n' "$buildreq" |func_grep_q '^[ ]*autobuild' \
3754 func_extract_trace AB_INIT
3755 test -n "$func_extract_trace_result" && {
3756 func_append buildreq 'autobuild - http://josefsson.org/autobuild/
3758 func_verbose "auto-adding 'autobuild' to build requirements"
3762 require_buildreq_autobuild=:
3766 # require_buildreq_autoconf
3767 # require_buildreq_autopoint
3768 # require_buildreq_libtoolize
3769 # ---------------------------
3770 # Try to find the minimum compatible version of autoconf/libtool
3771 # required to bootstrap successfully, and add it to '$buildreq'.
3772 for tool in autoconf libtoolize autopoint; do
3774 v=require_buildreq_${tool}
3777 autoconf) m=AC_PREREQ ;;
3778 libtoolize) m=LT_PREREQ; b=libtool ;;
3779 autopoint) m=AM_GNU_GETTEXT_VERSION b=gettext ;;
3787 # The following is ignored if undefined, but might be necessary
3788 # in order for `func_find_tool` to run.
3789 ${require_'$tool'-:}
3791 printf '\''%s\n'\'' "$buildreq" |func_grep_q '\''^[ ]*'$tool\'' || {
3792 func_extract_trace '$m'
3793 _G_version=$func_extract_trace_result
3794 test -n "$_G_version" && {
3795 func_append buildreq "\
3796 '$tool' $_G_version http://www.gnu.org/s/'$b'
3799 "auto-adding '\'$tool'-$_G_version'\'' to build requirements"
3809 # require_buildreq_automake
3810 # -------------------------
3811 # Try to find the minimum compatible version of automake required to
3812 # bootstrap successfully, and add it to '$buildreq'.
3813 require_buildreq_automake=func_require_buildreq_automake
3814 func_require_buildreq_automake ()
3818 # if automake is not already listed in $buildreq...
3819 printf '%s\n' "$buildreq" |func_grep_q automake || {
3820 func_extract_trace AM_INIT_AUTOMAKE
3822 # ...and AM_INIT_AUTOMAKE is declared...
3823 test -n "$func_extract_trace_result" && {
3824 automake_version=`$ECHO "$func_extract_trace_result" \
3825 |$SED -e 's|[^0-9]*||' -e 's| .*$||'`
3826 test -n "$automake_version" || automake_version=-
3828 func_append buildreq "\
3829 automake $automake_version http://www.gnu.org/s/automake
3832 "auto-adding 'automake-$automake_version' to build requirements"
3836 require_buildreq_automake=:
3840 # require_buildreq_patch
3841 # ----------------------
3842 # Automatically add a patch build-requirement if there are diff files
3843 # in $local_gl_path.
3844 require_buildreq_patch=func_require_buildreq_patch
3845 func_require_buildreq_patch ()
3849 $require_local_gl_path
3851 # This ensures PATCH is set appropriately by the time
3852 # func_check_versions enforces $buildreq.
3855 # If patch is not already listed in $buildreq...
3856 printf '%s\n' "$buildreq" |func_grep_q '^[ ]*patch' || {
3857 eval "set dummy $local_gl_path_quoted" ; shift
3861 # The ugly find invocation is necessary to exit with non-zero
3862 # status for old find binaries that don't support -exec fully.
3863 if test ! -d "$_G_dir" \
3864 || find "$_G_dir" -name "*.diff" -exec false {} \; ; then :
3866 func_append buildreq "patch - http://www.gnu.org/s/patch$nl"
3872 require_buildreq_patch=:
3876 # require_buildtools_uptodate
3877 # ---------------------------
3878 # Ensure all the packages listed in BUILDREQS are available on the build
3879 # machine at the minimum versions or better.
3880 require_buildtools_uptodate=func_require_buildtools_uptodate
3881 func_require_buildtools_uptodate ()
3885 $require_buildreq_autobuild
3886 $require_buildreq_autoconf
3887 $require_buildreq_automake
3888 $require_buildreq_libtoolize
3889 $require_buildreq_autopoint
3890 $require_buildreq_patch
3892 test -n "$buildreq" && {
3895 func_check_versions $buildreq
3896 $func_check_versions_result || {
3897 test -n "$buildreq_readme" \
3898 && test -f "$buildreq_readme" \
3900 $buildreq_readme explains how to obtain these prerequisite programs:
3902 func_strtable 0 11 12 36 \
3903 "Program" "Min_version" "Homepage" $buildreq
3904 func_fatal_error "$_G_error_hdr$func_strtable_result"
3908 require_buildtools_uptodate=:
3912 # require_copyright_holder
3913 # ------------------------
3914 # Ensure there is a sensible non-empty default value in '$copyright_holder'.
3915 require_copyright_holder=func_require_copyright_holder
3916 func_require_copyright_holder ()
3920 test -n "$copyright_holder" || {
3921 copyright_holder='Free Software Foundation, Inc.'
3922 func_warning settings "\
3923 Please set copyright_holder explicitly in 'bootstrap.conf';
3924 defaulting to '$copyright_holder'."
3927 require_copyright_holder=:
3933 # Ensure doc_base has a sensible value, extracted from 'gnulib-cache.m4'
3934 # if possible, otherwise letting 'gnulib-tool' pick a default.
3935 require_doc_base=func_require_doc_base
3936 func_require_doc_base ()
3940 $require_gnulib_cache
3942 test -f "$gnulib_cache" && test -z "$doc_base" && {
3943 func_extract_trace_first "gl_DOC_BASE" "$gnulib_cache"
3944 doc_base=$func_extract_trace_first_result
3946 test -n "$doc_base" && func_verbose "doc_base='$doc_base'"
3953 # require_dotgitmodules
3954 # ---------------------
3955 # Ensure we have a '.gitmodules' file, with appropriate 'gnulib' settings.
3956 require_dotgitmodules=func_require_dotgitmodules
3957 func_require_dotgitmodules ()
3963 test true = "$GIT" || {
3964 # A gnulib entry in .gitmodules always takes precedence.
3965 _G_path=`$GIT config --file .gitmodules submodule.gnulib.path 2>/dev/null`
3967 test -n "$_G_path" || {
3968 $require_vc_ignore_files
3970 func_verbose "creating '.gitmodules'"
3972 # If the .gitmodules file doesn't exist, create it now, and mark
3973 # it as ignored for the VCS.
3974 test -n "$gnulib_path" || gnulib_path=gnulib
3975 test -n "$gnulib_url" || gnulib_url=git://git.sv.gnu.org/gnulib
3978 echo '[submodule "gnulib"]'
3979 echo " path = $gnulib_path"
3980 echo " url = $gnulib_url"
3983 test -n "$vc_ignore_files" \
3984 || func_insert_if_absent ".gitmodules" $vc_ignore_files
3988 require_dotgitmodules=:
3992 # require_extra_locale_categories
3993 # -------------------------------
3994 # Ensure there is a default value in '$extra_locale_categories'
3995 require_extra_locale_categories=func_require_extra_locale_categories
3996 func_require_extra_locale_categories ()
4000 # Defaults to empty, so run with whatever value may have been set in
4002 require_extra_locale_categories=:
4008 # Ignore git if it's not available, or we're not in a git checkout tree.
4009 require_git=func_require_git
4014 $opt_skip_git && GIT=true
4016 test true = "$GIT" || {
4017 if test -d .git/.; then
4018 ($GIT --version) >/dev/null 2>&1 || GIT=true
4022 func_verbose "GIT='$GIT'"
4028 # require_gnulib_cache
4029 # --------------------
4030 # Ensure there is a non-empty default for '$gnulib_cache', and that it
4031 # names an existing file.
4032 require_gnulib_cache=func_require_gnulib_cache
4033 func_require_gnulib_cache ()
4039 test -n "$gnulib_cache" \
4040 || gnulib_cache=$macro_dir/gnulib-cache.m4
4042 func_verbose "found '$gnulib_cache'"
4044 require_gnulib_cache=:
4048 # require_gnulib_copy_cmd
4049 # -----------------------
4050 # Only calculate the options for copying files with gnulib once.
4051 require_gnulib_copy_cmd=func_require_gnulib_copy_cmd
4052 func_require_gnulib_copy_cmd ()
4056 $require_gnulib_tool
4057 $require_gnulib_tool_base_options
4059 gnulib_copy_cmd="$gnulib_tool $gnulib_tool_base_options --copy-file"
4060 $opt_copy || func_append gnulib_copy_cmd " --symlink"
4061 $opt_quiet || func_append gnulib_copy_cmd " --verbose"
4063 require_gnulib_copy_cmd=:
4067 # require_gnulib_merge_changelog
4068 # ------------------------------
4069 # See if we can use gnulib's git-merge-changelog merge driver.
4070 require_gnulib_merge_changelog=func_require_gnulib_merge_changelog
4071 func_require_gnulib_merge_changelog ()
4075 test -f ChangeLog && {
4078 func_grep_q '^\(/\|\)ChangeLog$' .gitignore || test true = "$GIT" || {
4079 if $GIT config merge.merge-changelog.driver >/dev/null; then
4081 elif (git-merge-changelog --version) >/dev/null 2>&1; then
4082 func_echo "initializing git-merge-changelog driver"
4083 $GIT config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
4084 $GIT config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
4086 func_warning recommend \
4087 "Consider installing git-merge-changelog from gnulib."
4092 require_gnulib_merge_changelog=:
4098 # Ensure gnulib_mk has a sensible value, extracted from 'gnulib-cache.m4'
4099 # if possible, otherwise letting 'gnulib-tool' pick a default.
4100 require_gnulib_mk=func_require_gnulib_mk
4101 func_require_gnulib_mk ()
4105 $require_gnulib_cache
4107 test -f "$gnulib_cache" && test -z "$gnulib_mk" && {
4108 func_extract_trace_first "gl_MAKEFILE_NAME" "$gnulib_cache"
4109 gnulib_mk=$func_extract_trace_first_result
4111 test -n "$gnulib_mk" && func_verbose "gnulib_mk='$gnulib_mk'"
4118 # require_gnulib_name
4119 # -------------------
4120 # Ensure gnulib_name has a sensible value, extracted from 'gnulib-cache.m4'
4121 # if possible, otherwise letting 'gnulib-tool' pick a default.
4122 require_gnulib_name=func_require_gnulib_name
4123 func_require_gnulib_name ()
4127 $require_gnulib_cache
4129 test -f "$gnulib_cache" && test -z "$gnulib_name" && {
4130 func_extract_trace_first "gl_LIB" "$gnulib_cache"
4131 gnulib_name=$func_extract_trace_first_result
4133 test -n "$gnulib_name" && func_verbose "gnulib_name='$gnulib_name'"
4136 require_gnulib_name=:
4140 # require_gnulib_path
4141 # require_gnulib_url
4142 # -------------------
4143 # Ensure 'gnulib_path' and 'gnulib_url' are set.
4144 require_gnulib_path=func_require_dotgitmodules_parameters
4145 require_gnulib_url=func_require_dotgitmodules_parameters
4146 func_require_dotgitmodules_parameters ()
4152 test true = "$GIT" && {
4153 # If we can't find git (or if the user specified '--skip-git'),
4154 # then use an existing gnulib directory specified with
4155 # '--gnulib-srcdir' if possible.
4156 test -n "$gnulib_path" \
4157 || test ! -x "$opt_gnulib_srcdir/gnulib-tool" \
4158 || gnulib_path=$opt_gnulib_srcdir
4162 $require_dotgitmodules
4164 test -f .gitmodules && {
4165 # Extract the parameters with sed, since git may be missing
4166 test -n "$gnulib_path" \
4167 || gnulib_path=`$SED -e '/^.submodule "gnulib".$/,${
4169 s|[ ]*||g;s|^[^=]*=||;p
4172 d' .gitmodules |$SED 1q`
4173 test -n "$gnulib_url" \
4174 || gnulib_url=`$SED -e '/^.submodule "gnulib".$/,${
4176 s|[ ]*||g;s|^[^=]*=||;p
4179 d' .gitmodules |$SED 1q`
4181 func_verbose "gnulib_path='$gnulib_path'"
4182 func_verbose "gnulib_url='$gnulib_url'"
4185 require_gnulib_path=:
4186 require_gnulib_url=:
4190 # require_gnulib_submodule
4191 # ------------------------
4192 # Ensure that there is a current gnulib submodule at '$gnulib_path'.
4193 require_gnulib_submodule=func_require_gnulib_submodule
4194 func_require_gnulib_submodule ()
4200 if test true = "$GIT"; then
4201 func_warning recommend \
4202 "No 'git' found; imported gnulib modules may be outdated."
4204 $require_gnulib_path
4207 if test -f .gitmodules && test -f "$gnulib_path/gnulib-tool"; then
4208 : All present and correct.
4210 elif test -n "$opt_gnulib_srcdir"; then
4211 # Older git can't clone into an empty directory.
4212 rmdir "$gnulib_path" 2>/dev/null
4213 func_show_eval "$GIT clone --reference '$opt_gnulib_srcdir' \
4214 '$gnulib_url' '$gnulib_path'" \
4215 || func_fatal_error "Unable to fetch gnulib submodule."
4217 # Without --gnulib-srcdir, and no existing checked out submodule, we
4218 # create a new shallow clone of the remote gnulib repository.
4220 trap func_cleanup_gnulib 1 2 13 15
4223 test -n "$gnulib_clone_since" && \
4224 $GIT clone -h 2>&1 |func_grep_q -- --shallow-since \
4225 && shallow="--shallow-since=$gnulib_clone_since"
4227 func_show_eval "$GIT clone $shallow '$gnulib_url' '$gnulib_path'" \
4230 # FIXME: Solaris /bin/sh will try to execute '-' if any of
4231 # these signals are caught after this.
4235 # Make sure we've checked out the correct revision of gnulib.
4236 func_show_eval "$GIT submodule init -- $gnulib_path" \
4237 && func_show_eval "$GIT submodule update -- $gnulib_path" \
4238 || func_fatal_error "Unable to update gnulib submodule."
4241 require_gnulib_submodule=:
4245 # require_gnulib_tool
4246 # -------------------
4247 # Ensure that '$gnulib_tool' is set, and points to an executable file,
4248 # or else fall back to using the binary 'true' if the main gnulib
4249 # files appear to have been imported already.
4250 require_gnulib_tool=func_require_gnulib_tool
4251 func_require_gnulib_tool ()
4255 test true = "$gnulib_tool" || {
4256 $require_gnulib_submodule
4257 $require_gnulib_path
4259 test -n "$gnulib_tool" \
4260 || gnulib_tool=$gnulib_path/gnulib-tool
4262 test -x "$gnulib_tool" || {
4264 func_warning recommend \
4265 "No 'gnulib-tool' found; gnulib modules may be missing."
4268 test true = "$gnulib_tool" \
4269 || func_verbose "found '$gnulib_tool'"
4272 require_gnulib_tool=:
4276 # require_gnulib_tool_base_options
4277 # --------------------------------
4278 # Ensure that '$gnulib_tool_base_options' contains all the base options
4279 # required according to user configuration from bootstrap.conf.
4280 require_gnulib_tool_base_options=func_require_gnulib_tool_base_options
4281 func_require_gnulib_tool_base_options ()
4285 $require_gnulib_tool
4287 gnulib_tool_base_options=
4289 test true = "$gnulib_tool" || {
4290 # 'gnulib_modules' and others are maintained in 'bootstrap.conf':
4291 # Use 'gnulib --import' to fetch gnulib modules.
4293 test -n "$build_aux" \
4294 && func_append_uniq gnulib_tool_base_options " --aux-dir=$build_aux"
4296 test -n "$macro_dir" \
4297 && func_append_uniq gnulib_tool_base_options " --m4-base=$macro_dir"
4299 test -n "$doc_base" \
4300 && func_append_uniq gnulib_tool_base_options " --doc-base=$doc_base"
4301 $require_gnulib_name
4302 test -n "$gnulib_name" \
4303 && func_append_uniq gnulib_tool_base_options " --lib=$gnulib_name"
4304 $require_local_gl_path
4305 test -n "$local_gl_path" && {
4306 eval "set dummy $local_gl_path_quoted" ; shift
4309 func_append_uniq gnulib_tool_base_options " --local-dir=$_G_dir"
4312 $require_source_base
4313 test -n "$source_base" \
4314 && func_append_uniq gnulib_tool_base_options " --source-base=$source_base"
4317 require_gnulib_tool_base_options=:
4321 # require_libtoolize
4322 # ------------------
4323 # Skip libtoolize if it's not needed.
4324 require_libtoolize=func_require_libtoolize
4325 func_require_libtoolize ()
4329 # Unless we're not searching for libtool use by this package, set
4330 # LIBTOOLIZE to true if none of 'LT_INIT', 'AC_PROG_LIBTOOL' and
4331 # 'AM_PROG_LIBTOOL' are used in configure.
4332 test true = "$LIBTOOLIZE" || {
4333 func_extract_trace LT_INIT
4334 test -n "$func_extract_trace_result" || func_extract_trace AC_PROG_LIBTOOL
4335 test -n "$func_extract_trace_result" || func_extract_trace AM_PROG_LIBTOOL
4336 test -n "$func_extract_trace_result" || LIBTOOLIZE=true
4339 test -n "$LIBTOOLIZE" || {
4340 # Find libtoolize, named glibtoolize in Mac Ports, but prefer
4341 # user-installed libtoolize to ancient glibtoolize shipped by
4342 # Apple with Mac OS X when Mac Ports is not installed.
4343 func_find_tool LIBTOOLIZE libtoolize glibtoolize
4346 test -n "$LIBTOOLIZE" || func_fatal_error "\
4347 Please install GNU Libtool, or 'export LIBTOOLIZE=/path/to/libtoolize'."
4349 func_verbose "export LIBTOOLIZE='$LIBTOOLIZE'"
4351 # Make sure the search result is visible to subshells
4354 require_libtoolize=:
4358 # require_local_gl_path
4359 # ---------------------
4360 # Ensure local_gl_path has a sensible value, extracted from 'gnulib-cache.m4' if
4361 # possible, otherwise letting 'gnulib-tool' pick a default.
4362 require_local_gl_path=func_require_local_gl_path
4363 func_require_local_gl_path ()
4367 $require_gnulib_cache
4369 # Compat with older bootstrap versions.
4370 test -n "$local_gl_dir" && {
4371 func_warning settings "\
4372 Please use 'local_gl_path' instead of 'local_gl_dir' in your
4373 'bootstrap.conf' file."
4374 local_gl_path=$local_gl_dir
4378 test -f "$gnulib_cache" && test -z "$local_gl_path" && {
4379 func_extract_trace_first "gl_LOCAL_DIR" "$gnulib_cache"
4380 local_gl_path=$func_extract_trace_first_result
4381 test -n "$local_gl_path" && func_verbose "local_gl_path='$local_gl_path'"
4384 test -z "$local_gl_path_quoted" && test -n "$local_gl_path" && {
4387 # Don't use PATH_SEPARATOR here, gnulib must be fixed to store only ':' as
4388 # path separator into gnulib-cache.m4 (consistency reasons among systems).
4390 for _G_dir in $local_gl_path
4396 func_quote eval "$@"
4397 local_gl_path_quoted=$func_quote_result
4400 require_local_gl_path=:
4406 # Ensure that '$macro_dir' is set, and if it doesn't already point to an
4407 # existing directory, create one.
4408 require_macro_dir=func_require_macro_dir
4409 func_require_macro_dir ()
4413 # Sometimes this is stored in 'configure.ac'.
4414 test -n "$macro_dir" || {
4415 # AC_CONFIG_MACRO_DIRS takes a space delimited list of directories,
4416 # but we only care about the first one in bootstrap.
4417 func_extract_trace_first AC_CONFIG_MACRO_DIRS
4418 macro_dir=`expr "x$func_extract_trace_first_result" : 'x\([^ ]*\)'`
4420 test -n "$macro_dir" || {
4421 func_extract_trace_first AC_CONFIG_MACRO_DIR
4422 macro_dir=$func_extract_trace_first_result
4425 # Otherwise we might find it in 'Makefile.am'.
4426 test -n "$macro_dir" || {
4427 $require_aclocal_amflags
4429 # Take the argument following the first '-I', if any.
4430 _G_minus_I_seen=false
4431 for _G_arg in $aclocal_amflags; do
4432 case $_G_minus_I_seen,$_G_arg in
4433 :,*) macro_dir=$_G_arg; break ;;
4434 *,-I) _G_minus_I_seen=: ;;
4435 *,-I*) macro_dir=`expr x$_G_arg : 'x-I\(.*\)$'`; break ;;
4440 func_verbose "macro_dir='$macro_dir'"
4442 func_check_configuration macro_dir \
4443 "AC_CONFIG_MACRO_DIRS([name of a directory for configure m4 files])"
4445 $require_vc_ignore_files
4447 # If the macro_dir directory doesn't exist, create it now, and mark it
4448 # as ignored for the VCS.
4449 if test ! -d "$macro_dir"; then
4450 mkdir "$macro_dir" || func_permissions_error "$macro_dir"
4452 test -n "$vc_ignore_files" \
4453 || func_insert_if_absent "$macro_dir" $vc_ignore_files
4460 # require_makefile_am
4461 # -------------------
4462 # Ensure there is a 'Makefile.am' in the current directory.
4463 require_makefile_am=func_require_makefile_am
4464 func_require_makefile_am ()
4468 test -n "$makefile_am" \
4469 || makefile_am=Makefile.am
4473 func_verbose "found '$makefile_am'"
4475 require_makefile_am=:
4481 # Ensure that '$package' contains a sensible default value.
4482 require_package=func_require_package
4483 func_require_package ()
4487 test -n "$package" || {
4488 $require_package_name
4490 package=`echo "$package_name" \
4491 |$SED -e 's/GNU //' \
4492 -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
4495 func_verbose "package='$package'"
4501 # require_package_bugreport
4502 # -------------------------
4503 # Ensure that this has a sensible value, extracted from 'configure.ac'
4504 # if appropriate (and possible!).
4505 require_package_bugreport=func_require_package_bugreport
4506 func_require_package_bugreport ()
4510 func_extract_trace AC_INIT
4514 set dummy $func_extract_trace_result
4518 test -n "$package_bugreport" || package_bugreport=$3
4519 func_check_configuration package_bugreport \
4520 "AC_INIT([$package_name], [$package_version], [bug-$package@gnu.org])"
4521 func_verbose "package_bugreport='$package_bugreport'"
4523 require_package_bugreport=:
4527 # require_package_name
4528 # --------------------
4529 # Ensure that this has a sensible value, extracted from 'configure.ac'
4530 # if appropriate (and possible!).
4531 require_package_name=func_require_package_name
4532 func_require_package_name ()
4536 func_extract_trace AC_INIT
4540 set dummy $func_extract_trace_result
4544 test -n "$package_name" || package_name=$1
4545 func_check_configuration package_name \
4546 "AC_INIT([name of your package], [package version number])"
4547 func_verbose "package_name='$package_name'"
4549 require_package_name=:
4553 # require_package_version
4554 # -----------------------
4555 # Ensure that this has a sensible value, extracted from 'configure.ac'
4556 # if appropriate (and possible!). While we might have set all the
4557 # parameters extracted from AC_INIT at once, 'package_version' in
4558 # particular is not necessarily available as early as the others, since
4559 # 'git-version-gen' is often involved, and until then we can't rely on
4560 # getting a correct version number from an AC_INIT extraction.
4561 require_package_version=func_require_package_version
4562 func_require_package_version ()
4566 func_extract_trace AC_INIT
4570 set dummy $func_extract_trace_result
4574 test -n "$package_version" || package_version=$2
4575 test -n "$package_version" || {
4576 # The embedded echo is to squash whitespace before globbing.
4577 case " "`echo $gnulib_modules`" " in
4578 *" git-version-gen "*)
4580 cannot \$require_package_version in bootstrap.conf before
4581 func_gnulib_tool has installed the 'git-version-gen' script."
4584 func_check_configuration package_version \
4585 "AC_INIT([name of your package], [package version number])"
4589 func_verbose "package_version='$package_version'"
4591 require_package_version=:
4597 # Find patch, according to the PATCH environment variable, or else
4598 # searching the user's PATH.
4599 require_patch=func_require_patch
4600 func_require_patch ()
4604 test -n "$PATCH" || {
4605 # Find a patch program, preferring gpatch, which is usually better
4606 # than the vendor patch.
4607 func_find_tool PATCH gpatch patch
4610 test -n "$PATCH" || func_fatal_error "\
4611 Please install GNU Patch, or 'export PATCH=/path/to/gnu/patch'."
4613 func_verbose "export PATCH='$PATCH'"
4615 # Make sure the search result is visible to subshells
4622 # require_source_base
4623 # -------------------
4624 # Ensure that source_base has a sensible value, extracted from
4625 # 'gnulib-cache.m4' if possible.
4626 require_source_base=func_require_source_base
4627 func_require_source_base ()
4631 $require_gnulib_cache
4633 test -f "$gnulib_cache" && test -z "$source_base" && {
4634 func_extract_trace_first "gl_SOURCE_BASE" "$gnulib_cache"
4636 source_base=$func_extract_trace_first_result
4638 func_verbose "source_base='$source_base'"
4641 require_source_base=:
4645 # require_vc_ignore_files
4646 # -----------------------
4647 # Ensure that '$vc_ignore' has been processed to list VCS ignore files
4648 # in '$vc_ignore_files'
4649 require_vc_ignore_files=func_require_vc_ignore_files
4650 func_require_vc_ignore_files ()
4654 test -n "$vc_ignore" || vc_ignore=auto
4656 if test auto = "$vc_ignore" && test -z "$vc_ignore_files"; then
4658 test -d .git && vc_ignore_files=.gitignore
4659 test -d CVS && vc_ignore_files="$vc_ignore_files .cvsignore"
4661 vc_ignore_files=$vc_ignore
4664 func_verbose "vc_ignore_files='$vc_ignore_files'"
4666 require_vc_ignore_files=:
4670 ## ----------------- ##
4671 ## Helper functions. ##
4672 ## ----------------- ##
4674 # This section contains the helper functions used by the rest of 'bootstrap'.
4678 # STRING may not start with a hyphen.
4679 if (eval 'x=123; test x${#x} = "x3"') 2>/dev/null
4681 # This is an XSI compatible shell, allowing a faster implementation...
4686 func_len_result=${#1}
4689 # ...otherwise fall back to using expr, which is often a shell builtin.
4694 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo 0`
4699 # func_cmp_s FILE1 FILE2
4700 # ----------------------
4701 # Return non-zero exit status unless FILE1 and FILE2 are identical, without
4702 # any output at all, even error messages.
4707 # This function relies on non-zero exit status, which will cause the
4708 # program to exit when running in 'set -e' mode.
4709 $CMP "$@" >/dev/null 2>&1
4713 # func_grep_q EXPRESSION [FILENAME..]
4714 # -----------------------------------
4715 # Check whether EXPRESSION matches any line of any listed FILENAME,
4716 # without any output at all, even error messages.
4721 # This function relies on non-zero exit status, which will cause the
4722 # program to exit when running in 'set -e' mode.
4723 $GREP "$@" >/dev/null 2>&1
4727 # func_ifcontains LIST MEMBER YES-CMD [NO-CMD]
4728 # --------------------------------------------
4729 # If whitespace-separated LIST contains MEMBER then execute YES-CMD,
4730 # otherwise if NO-CMD was given, execute that.
4741 for _G_item in $_G_wslist; do
4742 test "x$_G_item" = "x$_G_member" && {
4755 test 0 -eq "$_G_status" || exit $_G_status
4759 # func_strpad STR WIDTH CHAR
4760 # --------------------------
4761 # Trim STR, or pad with CHAR to force a total length of WIDTH.
4766 _G_width=`expr "$2" - 1`
4767 func_strpad_result=`$ECHO "$1" |$SED '
4769 s|^.\{0,'"$_G_width"'\}$|&'"$3"'|
4775 # func_strrpad STR WIDTH CHAR
4776 # ---------------------------
4777 # Trim STR, or right-justify-pad with CHAR to force a total length of
4783 _G_width=`expr "$2" - 1`
4784 func_strrpad_result=`$ECHO "$1" |$SED '
4786 s|^.\{0,'"$_G_width"'\}$|'"$3"'&|
4792 # func_strrow INDENT FIELD WIDTH [FIELDn WIDTHn]...
4793 # -------------------------------------------------
4794 # Return a string containing each FIELD left justified to WIDTH, with
4795 # the whole thing indented by INDENT spaces. This function is used to
4796 # render one row of aligned columns for a table by func_strtable().
4801 func_strrow_linelen=$1; shift
4804 while test $# -gt 0; do
4805 func_strrow_linelen=`expr $func_strrow_linelen + $2`
4806 func_strpad "$1" $2 " "
4807 func_append _G_row "$func_strpad_result"
4811 func_strrpad "$_G_row" $func_strrow_linelen " "
4812 func_strrow_result=$func_strrpad_result
4816 # func_strtable INDENT WIDTH1...WIDTHn HEADER1...HEADERn FIELD1...FIELDn
4817 # ----------------------------------------------------------------------
4818 # Generate a string of newline-separated rows arranged in lined-up
4819 # columns of the given WIDTHs, with the entire table indented by INDENT
4820 # spaces. The number of columns is determined by the number of integer
4821 # valued WIDTH arguments following INDENT. The next set (i.e. a number
4822 # of arguments equal to the number of WIDTH arguments) of fields are
4823 # treated as the table's column HEADERs, and are separated from the
4824 # remainder of the table by an indented row of '-' characters. Remaining
4825 # arguments are each aligned below the next available header, wrapping
4826 # to a new row as necessary. Finally another row of '-' characters is
4827 # added to mark the end of the table.
4829 # For example an unindented 3 column table with 2 rows of data would be
4830 # generated by this call:
4832 # func_strtable 3 20 10 25 \
4833 # Header1 Header2 Header3 \
4834 # Row1Col1 Row1Col2 Row1Col3 \
4835 # Row2Col1 Row2Col2 Row2Col3
4837 # returning the following string:
4839 # " Header1 Header2 Header3
4840 # -------------------------------------------------------
4841 # Row1Col1 Row1Col2 Row1Col3
4842 # Row2Col1 Row2Col2 Row2Col3
4843 # -------------------------------------------------------"
4848 # Save the indent value, we'll need it for each row we render.
4851 # Collect remaining numeric args into a list for reuse between
4852 # members of each row when we call func_strrow later.
4854 while test 0 -lt `expr "$1" : '[1-9][0-9]*$'`; do
4855 func_append _G_widths " $1"; shift
4858 # Extract the same number of positional parameters as there are
4859 # width elements - we'll do the header rows separately so that
4860 # we can insert a divider line.
4861 _G_header=$_G_indent
4862 for _G_width in $_G_widths; do
4863 func_append _G_header " $1 $_G_width"; shift
4865 func_strrow $_G_header
4867 # Strip off the indent, and make a divider with '-' chars, then
4869 _G_divider=`$ECHO "$func_strrow_result" \
4876 # Append the header and divider to the running result.
4877 func_append func_strtable_result "\
4882 # The remaining rows are zipped between the width values we
4883 # unwound earlier just like the header row above.
4884 while test $# -gt 0; do
4886 for _G_width in $_G_widths; do
4887 func_append _G_row " $1 $_G_width"; shift
4890 func_append func_strtable_result "\
4895 # Mark the end of the table with a final divider line.
4896 func_append func_strtable_result "$_G_divider"
4900 # func_internal_error ARG...
4901 # --------------------------
4902 # Echo program name prefixed message to standard error, and exit.
4903 func_internal_error ()
4906 INTERNAL: " ${1+"$@"} "
4907 Please report this bug to 'bug-gnulib@gnu.org'
4908 in as much detail as possible."
4912 # func_permissions_error FILE-OR-DIRECTORY
4913 # ----------------------------------------
4914 # Echo program name prefixed permissions error message to standard
4916 func_permissions_error ()
4920 func_fatal_error "Failed to create '$1', check permissions."
4924 # func_show_eval CMD [FAIL_EXP]
4925 # -----------------------------
4926 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
4927 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
4928 # is given, then evaluate it.
4933 $require_term_colors
4936 _G_fail_exp=${2-':'}
4938 ${opt_silent-'false'} || {
4939 func_quote eval $_G_cmd
4940 eval func_truncate_cmd $func_quote_result
4941 func_echo "running: $tc_bold$func_truncate_cmd_result$tc_reset"
4944 ${opt_dry_run-'false'} || {
4947 test 0 -eq "$_G_status" || eval "(exit $_G_status); $_G_fail_exp"
4952 # func_truncate_cmd CMD [ARG]...
4953 # ------------------------------
4954 # For unreasonably long commands (such as a gnulib-tool invocation with
4955 # the full module list for import), truncate CMD after the second non-
4957 func_truncate_cmd ()
4961 _G_last_arg_opt_p=false
4962 func_truncate_cmd_result=
4964 set dummy "$@"; shift
4966 while test $# -gt 0; do
4969 test -n "$func_truncate_cmd_result" \
4970 && func_append func_truncate_cmd_result ' '
4971 func_append func_truncate_cmd_result "$_G_opt"
4973 func_len "x$func_truncate_cmd_result"
4976 -*) _G_last_arg_opt_p=: ;;
4977 *) $_G_last_arg_opt_p \
4978 || test "$min_cmd_len" -gt "$func_len_result" \
4980 _G_last_arg_opt_p=false
4985 test $# -gt 0 && func_append func_truncate_cmd_result "..."
4989 # func_gitignore_entries FILE...
4990 # ------------------------------
4991 # Strip blank and comment lines to leave significant entries.
4992 func_gitignore_entries ()
4996 $SED -e '/^#/d' -e '/^$/d' "$@"
5000 # func_insert_if_absent STR FILE...
5001 # ---------------------------------
5002 # If $STR is not already on a line by itself in $FILE, insert it, at the
5003 # start. Entries are inserted at the start of the ignore list to ensure
5004 # existing entries starting with ! are not overridden. Such entries
5005 # support whilelisting exceptions after a more generic blacklist pattern.
5006 # sorting the new contents of the file and replacing $FILE with the result.
5007 func_insert_if_absent ()
5016 test -f "$file" || touch "$file"
5018 duplicate_entries=`func_gitignore_entries "$file" |sort |uniq -d`
5019 test -n "$duplicate_entries" \
5020 && func_error "duplicate entries in $file: " $duplicate_entries
5022 func_grep_q "^$str\$" "$file" \
5023 || func_verbose "inserting '$str' into '$file'"
5025 linesold=`func_gitignore_entries "$file" |wc -l`
5026 linesnew=`{ $ECHO "$str"; cat "$file"; } \
5027 |func_gitignore_entries |sort -u |wc -l`
5028 test "$linesold" -eq "$linesnew" \
5029 || { $SED "1i\\$nl$str$nl" "$file" >"$file"T && mv "$file"T "$file"; } \
5030 || func_permissions_error "$file"
5035 # func_get_version APP
5036 # --------------------
5037 # echo the version number (if any) of APP, which is looked up along your
5045 # Rather than uncomment the sed script in-situ, strip the comments
5046 # programatically before passing the result to $SED for evaluation.
5047 sed_get_version=`$ECHO '# extract version within line
5048 s|.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1|
5051 # extract version at start of line
5052 s|^\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1|
5058 # the following essentially does s|5.005|5.5|
5059 s|\.0*\([1-9]\)|.\1|g
5062 |$SED '/^[ ]*#.*$/d'`
5064 func_tool_version_output $_G_app >/dev/null
5067 test 0 -ne "$_G_status" \
5068 || $_G_app --version 2>&1 |$SED -n "$sed_get_version"
5074 # func_check_tool APP
5075 # -------------------
5076 # Search PATH for an executable at APP.
5081 func_check_tool_result=
5085 test -x "$1" && func_check_tool_result=$1
5089 IFS=${PATH_SEPARATOR-:}
5090 for _G_check_tool_path in $PATH; do
5092 if test -x "$_G_check_tool_path/$1"; then
5093 func_check_tool_result=$_G_check_tool_path/$1
5103 # func_check_versions APP1 VER1 URL1 ...[APPN VERN URLN]
5104 # ------------------------------------------------------
5105 func_check_versions ()
5109 func_check_versions_result=:
5111 while test $# -gt 0; do
5116 # Diagnose bad buildreq formatting.
5118 [a-z]*://*) ;; # looks like a url
5119 *) func_fatal_error "\
5120 '$_G_url' from the buildreq table in
5121 'bootstrap.conf' does not look like the URL for downloading
5122 $_G_app. Please ensure that buildreq is a strict newline
5123 delimited list of triples; 'program min-version url'."
5127 # Honor $APP variables ($TAR, $AUTOCONF, etc.)
5128 _G_appvar=`echo $_G_app |tr '[a-z]' '[A-Z]'`
5129 test TAR = "$_G_appvar" && _G_appvar=AMTAR
5130 eval "_G_app=\${$_G_appvar-$_G_app}"
5132 # Fail if no version specified, but the program can't be found.
5133 if test x- = "x$_G_reqver"; then
5134 func_check_tool $_G_app
5135 if test -z "$func_check_tool_result"; then
5136 func_error "Prerequisite '$_G_app' not not found. Please install it, or
5137 'export $_G_appvar=/path/to/$_G_app'."
5138 func_check_versions_result=false
5140 func_verbose "found '$func_check_tool_result' for $_G_appvar."
5143 _G_instver=`func_get_version $_G_app`
5145 # Fail if --version didn't work.
5146 if test -z "$_G_instver"; then
5147 func_error "Prerequisite '$_G_app' not found. Please install it, or
5148 'export $_G_appvar=/path/to/$_G_app'."
5149 func_check_versions_result=false
5151 # Fail if a newer version than what we have is required.
5153 func_verbose "found '$_G_app' version $_G_instver."
5157 # If $buildreq version starts with '=', version must
5158 # match the installed program exactly.
5159 test "x$_G_reqver" = "x=$_G_instver" || {
5161 '$_G_app' version == $_G_instver is too old
5162 'exactly $_G_app-$_G_reqver is required"
5163 func_check_versions_result=false
5167 # Otherwise, anything that is not older is a match.
5168 func_lt_ver "$_G_reqver" "$_G_instver" || {
5170 '$_G_app' version == $_G_instver is too old
5171 '$_G_app' version >= $_G_reqver is required"
5172 func_check_versions_result=false
5182 # func_cleanup_gnulib
5183 # -------------------
5184 # Recursively delete everything below the path in the global variable
5186 func_cleanup_gnulib ()
5191 $RM -fr "$gnulib_path"
5196 # func_download_po_files SUBDIR DOMAIN
5197 # ------------------------------------
5198 func_download_po_files ()
5202 func_echo "getting translations into $1 for $2..."
5203 _G_cmd=`printf "$po_download_command_format" "$2" "$1"`
5208 # func_update_po_files PO_DIR DOMAIN
5209 # ----------------------------------
5210 # Mirror .po files to $po_dir/.reference and copy only the new
5211 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
5212 # Note po files that exist locally only are left in $po_dir but will
5213 # not be included in LINGUAS and hence will not be distributed.
5214 func_update_po_files ()
5218 # Directory containing primary .po files.
5219 # Overwrite them only when we're sure a .po file is new.
5223 # Mirror *.po files into this dir.
5224 # Usually contains *.s1 checksum files.
5225 _G_ref_po_dir=$_G_po_dir/.reference
5227 test -d "$_G_ref_po_dir" || mkdir $_G_ref_po_dir || return
5228 func_download_po_files $_G_ref_po_dir $_G_domain \
5229 && ls "$_G_ref_po_dir"/*.po 2>/dev/null \
5230 |$SED -e 's|.*/||' -e 's|\.po$||' > "$_G_po_dir/LINGUAS" || return
5232 # Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6+.
5233 func_find_tool SHA1SUM sha1sum gsha1sum shasum sha1
5235 test -n "$SHA1SUM" || func_fatal_error "\
5236 Please install GNU Coreutils, or 'export SHA1SUM=/path/to/sha1sum'."
5238 _G_langs=`cd $_G_ref_po_dir && echo *.po|$SED 's|\.po||g'`
5239 test '*' = "$_G_langs" && _G_langs=x
5240 for _G_po in $_G_langs; do
5241 case $_G_po in x) continue;; esac
5242 _G_new_po=$_G_ref_po_dir/$_G_po.po
5243 _G_cksum_file=$_G_ref_po_dir/$_G_po.s1
5244 if ! test -f "$_G_cksum_file" ||
5245 ! test -f "$_G_po_dir/$_G_po.po" ||
5246 ! $SHA1SUM -c "$_G_cksum_file" \
5247 < "$_G_new_po" > /dev/null; then
5248 echo "updated $_G_po_dir/$_G_po.po..."
5249 cp "$_G_new_po" "$_G_po_dir/$_G_po.po" \
5250 && $SHA1SUM < "$_G_new_po" > "$_G_cksum_file" || return
5257 ## --------------- ##
5258 ## Option parsing. ##
5259 ## --------------- ##
5261 # Hook in the functions to make sure our own options are parsed during
5262 # the option parsing loop.
5264 usage='$progpath [OPTION]...'
5266 # Short help message in response to '-h'. Add to this in 'bootstrap.conf'
5267 # if you accept any additional options.
5268 usage_message="Common Bootstrap Options:
5269 -c, --copy copy files instead of creating symbolic links.
5270 --debug enable verbose shell tracing
5271 -n, --dry-run print commands rather than running them
5272 -f, --force attempt to bootstrap even if the sources seem not
5273 to have been checked out.
5274 --gnulib-srcdir=DIRNAME
5275 specify a local directory where gnulib sources
5276 reside. Use this if you already have the gnulib
5277 sources on your machine, and don't want to waste
5278 your bandwidth downloading them again. Defaults to
5280 --no-warnings equivalent to '-Wnone'
5281 --skip-git do not fetch files from remote repositories
5282 --skip-po do not download po files.
5283 -v, --verbose verbosely report processing
5284 --version print version information and exit
5285 -W, --warnings=CATEGORY
5286 report the warnings falling in CATEGORY [all]
5287 -h, --help print short or long help message and exit
5290 # Additional text appended to 'usage_message' in response to '--help'.
5291 long_help_message=$long_help_message"
5292 'recommend' show warnings about missing recommended packages
5293 'settings' show warnings about missing '$progname.conf' settings
5294 'upgrade' show warnings about out-dated files
5296 If the file '$progname.conf' exists in the same directory as this
5297 script, its contents are read as shell variables to configure the
5300 For build prerequisites, environment variables like \$AUTOCONF and
5301 \$AMTAR are honored.
5303 Running without arguments will suffice in most cases.
5306 # Warning categories used by 'bootstrap', append others if you use them
5307 # in your 'bootstrap.conf'.
5308 warning_categories='recommend settings upgrade'
5311 # bootstrap_options_prep [ARG]...
5312 # -------------------------------
5313 # Preparation for options parsed by Bootstrap.
5314 bootstrap_options_prep ()
5319 opt_copy=${copy-'false'}
5322 opt_gnulib_srcdir=$GNULIB_SRCDIR
5326 # Pass back the list of options we consumed.
5327 func_quote eval ${1+"$@"}
5328 bootstrap_options_prep_result=$func_quote_result
5330 func_add_hook func_options_prep bootstrap_options_prep
5333 # bootstrap_parse_options [ARG]...
5334 # --------------------------------
5335 # Provide handling for Bootstrap specific options.
5336 bootstrap_parse_options ()
5340 # Perform our own loop to consume as many options as possible in
5342 while test $# -gt 0; do
5346 --dry-run|--dryrun|-n)
5348 --copy|-c) opt_copy=: ;;
5349 --force|-f) opt_force=: ;;
5352 test $# = 0 && func_missing_arg $_G_opt && break
5353 opt_gnulib_srcdir=$1
5357 --skip-git|--no-git)
5365 # Separate non-argument short options:
5367 func_split_short_opt "$_G_opt"
5368 set dummy "$func_split_short_opt_name" \
5369 "-$func_split_short_opt_arg" ${1+"$@"}
5373 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
5377 # save modified positional parameters for caller
5378 func_quote eval ${1+"$@"}
5379 bootstrap_parse_options_result=$func_quote_result
5381 func_add_hook func_parse_options bootstrap_parse_options
5384 # bootstrap_validate_options [ARG]...
5385 # -----------------------------------
5386 # Perform any sanity checks on option settings and/or unconsumed
5388 bootstrap_validate_options ()
5394 && func_fatal_help "too many arguments"
5396 # Pass back the (empty) list of unconsumed options.
5397 func_quote eval ${1+"$@"}
5398 bootstrap_validate_options_result=$func_quote_result
5400 func_add_hook func_validate_options bootstrap_validate_options
5403 ## -------------------------------------------------- ##
5404 ## Source package customisations in 'bootstrap.conf'. ##
5405 ## -------------------------------------------------- ##
5407 # Override the default configuration, if necessary.
5408 # Make sure that bootstrap.conf is sourced from the current directory
5409 # if we were invoked as "sh bootstrap".
5411 */*) test -r "$0.conf" && . "$0.conf" ;;
5412 *) test -r "$0.conf" && . ./"$0.conf" ;;
5416 ## ------------------------------- ##
5417 ## Actually perform the bootstrap. ##
5418 ## ------------------------------- ##
5420 func_bootstrap ${1+"$@"}
5423 exit ${exit_status-$EXIT_SUCCESS}
5426 # mode: shell-script
5428 # eval: (add-hook 'before-save-hook 'time-stamp)
5429 # time-stamp-pattern: "500/scriptversion=%:y-%02m-%02d.%02H; # UTC"
5430 # time-stamp-time-zone: "UTC"