ltmain.in: Use func_warning for all warnings
[libtool.git] / bootstrap
blobe57ec940db688efafc9dced1dcace2b180feaa1e
1 #! /bin/sh
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, 2021, 2023 Bootstrap Authors
14 # This file is dual licensed under the terms of the MIT license
15 # <https://opensource.org/licenses/MIT>, and GPL version 2 or later
16 # <https://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>
30 ## ------ ##
31 ## Usage. ##
32 ## ------ ##
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
46 # script with:
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 your 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
56 # idiosyncracies.
59 ## ================================================================== ##
60 ## ##
61 ## DO NOT EDIT THIS FILE, CUSTOMIZE IT USING A BOOTSTRAP.CONF ##
62 ## ##
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',
73 # for example).
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
78 # section.
80 : ${ACLOCAL="aclocal"}
81 : ${AUTOCONF="autoconf"}
82 : ${AUTOHEADER="autoheader"}
83 : ${AUTOM4TE="autom4te"}
84 : ${AUTOHEADER="autoheader"}
85 : ${AUTOMAKE="automake"}
86 : ${AUTOPOINT="autopoint"}
87 : ${AUTORECONF="autoreconf"}
88 : ${CMP="cmp"}
89 : ${CONFIG_SHELL="/bin/sh"}
90 : ${DIFF="diff"}
91 : ${GIT="git"}
92 : ${LN_S="ln -s"}
93 : ${RM="rm"}
95 export ACLOCAL
96 export AUTOCONF
97 export AUTOHEADER
98 export AUTOM4TE
99 export AUTOHEADER
100 export AUTOMAKE
101 export AUTOPOINT
102 export AUTORECONF
103 export CONFIG_SHELL
106 ## -------------- ##
107 ## Configuration. ##
108 ## -------------- ##
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.
114 buildreq=
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.
122 build_aux=
123 macro_dir=
124 package=
125 package_name=
126 package_version=
127 package_bugreport=
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'.
132 doc_base=
133 gnulib_mk=
134 gnulib_name=
135 local_gl_path=
136 source_base=
137 tests_base=
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.
142 gnulib_modules=
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="
147 build-aux/compile
148 build-aux/install-sh
149 build-aux/mdate-sh
150 build-aux/texinfo.tex
151 build-aux/depcomp
152 build-aux/config.guess
153 build-aux/config.sub
154 doc/INSTALL
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.
160 gnulib_path=
161 gnulib_url=
163 # Date from which to clone github, to avoid a full clone.
164 gnulib_clone_since=
166 # Additional gnulib-tool options to use.
167 gnulib_tool_options="
168 --no-changelog
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.
173 gnulib_precious="
174 gnulib-tool.m4
177 # When truncating long commands for display, always allow at least this
178 # many characters before truncating.
179 min_cmd_len=160
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
185 # all symlinks.
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])
199 xgettext_options="
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.
205 copyright_holder=
207 # File that should exist in the top directory of a checked out hierarchy,
208 # but not in a distribution tarball.
209 checkout_only_file=
211 # Whether to use copies instead of symlinks by default (if set to true,
212 # the --copy option has no effect).
213 copy=false
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
220 # "auto".
221 vc_ignore=
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, 2021, 2023 Bootstrap Authors
240 # This file is dual licensed under the terms of the MIT license
241 # <https://opensource.org/licenses/MIT>, and GPL version 2 or later
242 # <https://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>
251 ## ------ ##
252 ## Usage. ##
253 ## ------ ##
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 :
273 emulate sh
274 NULLCMD=:
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+"$@"}'='"$@"'
278 setopt NO_GLOB_SUBST
279 else
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.
284 _G_user_locale=
285 _G_safe_locale=
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
290 $_G_var=C
291 export $_G_var
292 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
293 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
295 done
296 # These NLS vars are set unconditionally (bootstrap issue #24). Unset those
297 # in case the environment reset is needed later and the $save_* variant is not
298 # defined (see the code above).
299 LC_ALL=C
300 LANGUAGE=C
301 export LANGUAGE LC_ALL
303 # Make sure IFS has a sensible default
304 sp=' '
305 nl='
307 IFS="$sp $nl"
309 # There are apparently some systems that use ';' as a PATH separator!
310 if test "${PATH_SEPARATOR+set}" != set; then
311 PATH_SEPARATOR=:
312 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
313 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
314 PATH_SEPARATOR=';'
319 # func_unset VAR
320 # --------------
321 # Portably unset VAR.
322 # In some shells, an 'unset VAR' statement leaves a non-zero return
323 # status if VAR is already unset, which might be problematic if the
324 # statement is used at the end of a function (thus poisoning its return
325 # value) or when 'set -e' is active (causing even a spurious abort of
326 # the script in this case).
327 func_unset ()
329 { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }
333 # Make sure CDPATH doesn't cause `cd` commands to output the target dir.
334 func_unset CDPATH
336 # Make sure ${,E,F}GREP behave sanely.
337 func_unset GREP_OPTIONS
340 ## ------------------------- ##
341 ## Locate command utilities. ##
342 ## ------------------------- ##
345 # func_executable_p FILE
346 # ----------------------
347 # Check that FILE is an executable regular file.
348 func_executable_p ()
350 test -f "$1" && test -x "$1"
354 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
355 # --------------------------------------------
356 # Search for either a program that responds to --version with output
357 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
358 # trying all the directories in PATH with each of the elements of
359 # PROGS_LIST.
361 # CHECK_FUNC should accept the path to a candidate program, and
362 # set $func_check_prog_result if it truncates its output less than
363 # $_G_path_prog_max characters.
364 func_path_progs ()
366 _G_progs_list=$1
367 _G_check_func=$2
368 _G_PATH=${3-"$PATH"}
370 _G_path_prog_max=0
371 _G_path_prog_found=false
372 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
373 for _G_dir in $_G_PATH; do
374 IFS=$_G_save_IFS
375 test -z "$_G_dir" && _G_dir=.
376 for _G_prog_name in $_G_progs_list; do
377 for _exeext in '' .EXE; do
378 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
379 func_executable_p "$_G_path_prog" || continue
380 case `"$_G_path_prog" --version 2>&1` in
381 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
382 *) $_G_check_func $_G_path_prog
383 func_path_progs_result=$func_check_prog_result
385 esac
386 $_G_path_prog_found && break 3
387 done
388 done
389 done
390 IFS=$_G_save_IFS
391 test -z "$func_path_progs_result" && {
392 echo "no acceptable sed could be found in \$PATH" >&2
393 exit 1
398 # We want to be able to use the functions in this file before configure
399 # has figured out where the best binaries are kept, which means we have
400 # to search for them ourselves - except when the results are already set
401 # where we skip the searches.
403 # Unless the user overrides by setting SED, search the path for either GNU
404 # sed, or the sed that truncates its output the least.
405 test -z "$SED" && {
406 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
407 for _G_i in 1 2 3 4 5 6 7; do
408 _G_sed_script=$_G_sed_script$nl$_G_sed_script
409 done
410 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
411 _G_sed_script=
413 func_check_prog_sed ()
415 _G_path_prog=$1
417 _G_count=0
418 printf 0123456789 >conftest.in
419 while :
421 cat conftest.in conftest.in >conftest.tmp
422 mv conftest.tmp conftest.in
423 cp conftest.in conftest.nl
424 echo '' >> conftest.nl
425 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
426 diff conftest.out conftest.nl >/dev/null 2>&1 || break
427 _G_count=`expr $_G_count + 1`
428 if test "$_G_count" -gt "$_G_path_prog_max"; then
429 # Best one so far, save it but keep looking for a better one
430 func_check_prog_result=$_G_path_prog
431 _G_path_prog_max=$_G_count
433 # 10*(2^10) chars as input seems more than enough
434 test 10 -lt "$_G_count" && break
435 done
436 rm -f conftest.in conftest.tmp conftest.nl conftest.out
439 func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"
440 rm -f conftest.sed
441 SED=$func_path_progs_result
445 # Unless the user overrides by setting GREP, search the path for either GNU
446 # grep, or the grep that truncates its output the least.
447 test -z "$GREP" && {
448 func_check_prog_grep ()
450 _G_path_prog=$1
452 _G_count=0
453 _G_path_prog_max=0
454 printf 0123456789 >conftest.in
455 while :
457 cat conftest.in conftest.in >conftest.tmp
458 mv conftest.tmp conftest.in
459 cp conftest.in conftest.nl
460 echo 'GREP' >> conftest.nl
461 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
462 diff conftest.out conftest.nl >/dev/null 2>&1 || break
463 _G_count=`expr $_G_count + 1`
464 if test "$_G_count" -gt "$_G_path_prog_max"; then
465 # Best one so far, save it but keep looking for a better one
466 func_check_prog_result=$_G_path_prog
467 _G_path_prog_max=$_G_count
469 # 10*(2^10) chars as input seems more than enough
470 test 10 -lt "$_G_count" && break
471 done
472 rm -f conftest.in conftest.tmp conftest.nl conftest.out
475 func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"
476 GREP=$func_path_progs_result
480 ## ------------------------------- ##
481 ## User overridable command paths. ##
482 ## ------------------------------- ##
484 # All uppercase variable names are used for environment variables. These
485 # variables can be overridden by the user before calling a script that
486 # uses them if a suitable command of that name is not already available
487 # in the command search PATH.
489 : ${CP="cp -f"}
490 : ${ECHO="printf %s\n"}
491 : ${EGREP="$GREP -E"}
492 : ${FGREP="$GREP -F"}
493 : ${LN_S="ln -s"}
494 : ${MAKE="make"}
495 : ${MKDIR="mkdir"}
496 : ${MV="mv -f"}
497 : ${RM="rm -f"}
498 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
501 ## -------------------- ##
502 ## Useful sed snippets. ##
503 ## -------------------- ##
505 sed_dirname='s|/[^/]*$||'
506 sed_basename='s|^.*/||'
508 # Sed substitution that helps us do robust quoting. It backslashifies
509 # metacharacters that are still active within double-quoted strings.
510 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
512 # Same as above, but do not quote variable references.
513 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
515 # Sed substitution that turns a string into a regex matching for the
516 # string literally.
517 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
519 # Sed substitution that converts a w32 file name or path
520 # that contains forward slashes, into one that contains
521 # (escaped) backslashes. A very naive implementation.
522 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
524 # Re-'\' parameter expansions in output of sed_double_quote_subst that
525 # were '\'-ed in input to the same. If an odd number of '\' preceded a
526 # '$' in input to sed_double_quote_subst, that '$' was protected from
527 # expansion. Since each input '\' is now two '\'s, look for any number
528 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
529 _G_bs='\\'
530 _G_bs2='\\\\'
531 _G_bs4='\\\\\\\\'
532 _G_dollar='\$'
533 sed_double_backslash="\
534 s/$_G_bs4/&\\
536 s/^$_G_bs2$_G_dollar/$_G_bs&/
537 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
538 s/\n//g"
540 # require_check_ifs_backslash
541 # ---------------------------
542 # Check if we can use backslash as IFS='\' separator, and set
543 # $check_ifs_backshlash_broken to ':' or 'false'.
544 require_check_ifs_backslash=func_require_check_ifs_backslash
545 func_require_check_ifs_backslash ()
547 _G_save_IFS=$IFS
548 IFS='\'
549 _G_check_ifs_backshlash='a\\b'
550 for _G_i in $_G_check_ifs_backshlash
552 case $_G_i in
554 check_ifs_backshlash_broken=false
557 break
560 check_ifs_backshlash_broken=:
561 break
563 esac
564 done
565 IFS=$_G_save_IFS
566 require_check_ifs_backslash=:
570 ## ----------------- ##
571 ## Global variables. ##
572 ## ----------------- ##
574 # Except for the global variables explicitly listed below, the following
575 # functions in the '^func_' namespace, and the '^require_' namespace
576 # variables initialised in the 'Resource management' section, sourcing
577 # this file will not pollute your global namespace with anything
578 # else. There's no portable way to scope variables in Bourne shell
579 # though, so actually running these functions will sometimes place
580 # results into a variable named after the function, and often use
581 # temporary variables in the '^_G_' namespace. If you are careful to
582 # avoid using those namespaces casually in your sourcing script, things
583 # should continue to work as you expect. And, of course, you can freely
584 # overwrite any of the functions or variables defined here before
585 # calling anything to customize them.
587 EXIT_SUCCESS=0
588 EXIT_FAILURE=1
589 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
590 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
592 # Allow overriding, eg assuming that you follow the convention of
593 # putting '$debug_cmd' at the start of all your functions, you can get
594 # bash to show function call trace with:
596 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
597 debug_cmd=${debug_cmd-":"}
598 exit_cmd=:
600 # By convention, finish your script with:
602 # exit $exit_status
604 # so that you can set exit_status to non-zero if you want to indicate
605 # something went wrong during execution without actually bailing out at
606 # the point of failure.
607 exit_status=$EXIT_SUCCESS
609 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
610 # is ksh but when the shell is invoked as "sh" and the current value of
611 # the _XPG environment variable is not equal to 1 (one), the special
612 # positional parameter $0, within a function call, is the name of the
613 # function.
614 progpath=$0
616 # The name of this program.
617 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
619 # Make sure we have an absolute progpath for reexecution:
620 case $progpath in
621 [\\/]*|[A-Za-z]:\\*) ;;
622 *[\\/]*)
623 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
624 progdir=`cd "$progdir" && pwd`
625 progpath=$progdir/$progname
628 _G_IFS=$IFS
629 IFS=${PATH_SEPARATOR-:}
630 for progdir in $PATH; do
631 IFS=$_G_IFS
632 test -x "$progdir/$progname" && break
633 done
634 IFS=$_G_IFS
635 test -n "$progdir" || progdir=`pwd`
636 progpath=$progdir/$progname
638 esac
641 ## ----------------- ##
642 ## Standard options. ##
643 ## ----------------- ##
645 # The following options affect the operation of the functions defined
646 # below, and should be set appropriately depending on run-time para-
647 # meters passed on the command line.
649 opt_dry_run=false
650 opt_quiet=false
651 opt_verbose=false
653 # Categories 'all' and 'none' are always available. Append any others
654 # you will pass as the first argument to func_warning from your own
655 # code.
656 warning_categories=
658 # By default, display warnings according to 'opt_warning_types'. Set
659 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
660 # treat the next displayed warning as a fatal error.
661 warning_func=func_warn_and_continue
663 # Set to 'all' to display all warnings, 'none' to suppress all
664 # warnings, or a space delimited list of some subset of
665 # 'warning_categories' to display only the listed warnings.
666 opt_warning_types=all
669 ## -------------------- ##
670 ## Resource management. ##
671 ## -------------------- ##
673 # This section contains definitions for functions that each ensure a
674 # particular resource (a file, or a non-empty configuration variable for
675 # example) is available, and if appropriate to extract default values
676 # from pertinent package files. Call them using their associated
677 # 'require_*' variable to ensure that they are executed, at most, once.
679 # It's entirely deliberate that calling these functions can set
680 # variables that don't obey the namespace limitations obeyed by the rest
681 # of this file, in order that that they be as useful as possible to
682 # callers.
685 # require_term_colors
686 # -------------------
687 # Allow display of bold text on terminals that support it.
688 require_term_colors=func_require_term_colors
689 func_require_term_colors ()
691 $debug_cmd
693 test -t 1 && {
694 # COLORTERM and USE_ANSI_COLORS environment variables take
695 # precedence, because most terminfo databases neglect to describe
696 # whether color sequences are supported.
697 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
699 if test 1 = "$USE_ANSI_COLORS"; then
700 # Standard ANSI escape sequences
701 tc_reset='\e[0m'
702 tc_bold='\e[1m'; tc_standout='\e[7m'
703 tc_red='\e[31m'; tc_green='\e[32m'
704 tc_blue='\e[34m'; tc_cyan='\e[36m'
705 else
706 # Otherwise trust the terminfo database after all.
707 test -n "`tput sgr0 2>/dev/null`" && {
708 tc_reset=`tput sgr0`
709 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
710 tc_standout=$tc_bold
711 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
712 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
713 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
714 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
715 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
720 require_term_colors=:
724 ## ----------------- ##
725 ## Function library. ##
726 ## ----------------- ##
728 # This section contains a variety of useful functions to call in your
729 # scripts. Take note of the portable wrappers for features provided by
730 # some modern shells, which will fall back to slower equivalents on
731 # less featureful shells.
734 # func_append VAR VALUE
735 # ---------------------
736 # Append VALUE onto the existing contents of VAR.
738 # We should try to minimise forks, especially on Windows where they are
739 # unreasonably slow, so skip the feature probes when bash or zsh are
740 # being used:
741 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
742 : ${_G_HAVE_ARITH_OP="yes"}
743 : ${_G_HAVE_XSI_OPS="yes"}
744 # The += operator was introduced in bash 3.1
745 case $BASH_VERSION in
746 [12].* | 3.0 | 3.0*) ;;
748 : ${_G_HAVE_PLUSEQ_OP="yes"}
750 esac
753 # _G_HAVE_PLUSEQ_OP
754 # Can be empty, in which case the shell is probed, "yes" if += is
755 # useable or anything else if it does not work.
756 test -z "$_G_HAVE_PLUSEQ_OP" \
757 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
758 && _G_HAVE_PLUSEQ_OP=yes
760 if test yes = "$_G_HAVE_PLUSEQ_OP"
761 then
762 # This is an XSI compatible shell, allowing a faster implementation...
763 eval 'func_append ()
765 $debug_cmd
767 eval "$1+=\$2"
769 else
770 # ...otherwise fall back to using expr, which is often a shell builtin.
771 func_append ()
773 $debug_cmd
775 eval "$1=\$$1\$2"
780 # func_append_quoted VAR VALUE
781 # ----------------------------
782 # Quote VALUE and append to the end of shell variable VAR, separated
783 # by a space.
784 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
785 eval 'func_append_quoted ()
787 $debug_cmd
789 func_quote_arg pretty "$2"
790 eval "$1+=\\ \$func_quote_arg_result"
792 else
793 func_append_quoted ()
795 $debug_cmd
797 func_quote_arg pretty "$2"
798 eval "$1=\$$1\\ \$func_quote_arg_result"
803 # func_append_uniq VAR VALUE
804 # --------------------------
805 # Append unique VALUE onto the existing contents of VAR, assuming
806 # entries are delimited by the first character of VALUE. For example:
808 # func_append_uniq options " --another-option option-argument"
810 # will only append to $options if " --another-option option-argument "
811 # is not already present somewhere in $options already (note spaces at
812 # each end implied by leading space in second argument).
813 func_append_uniq ()
815 $debug_cmd
817 eval _G_current_value='`$ECHO $'$1'`'
818 _G_delim=`expr "$2" : '\(.\)'`
820 case $_G_delim$_G_current_value$_G_delim in
821 *"$2$_G_delim"*) ;;
822 *) func_append "$@" ;;
823 esac
827 # func_arith TERM...
828 # ------------------
829 # Set func_arith_result to the result of evaluating TERMs.
830 test -z "$_G_HAVE_ARITH_OP" \
831 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
832 && _G_HAVE_ARITH_OP=yes
834 if test yes = "$_G_HAVE_ARITH_OP"; then
835 eval 'func_arith ()
837 $debug_cmd
839 func_arith_result=$(( $* ))
841 else
842 func_arith ()
844 $debug_cmd
846 func_arith_result=`expr "$@"`
851 # func_basename FILE
852 # ------------------
853 # Set func_basename_result to FILE with everything up to and including
854 # the last / stripped.
855 if test yes = "$_G_HAVE_XSI_OPS"; then
856 # If this shell supports suffix pattern removal, then use it to avoid
857 # forking. Hide the definitions single quotes in case the shell chokes
858 # on unsupported syntax...
859 _b='func_basename_result=${1##*/}'
860 _d='case $1 in
861 */*) func_dirname_result=${1%/*}$2 ;;
862 * ) func_dirname_result=$3 ;;
863 esac'
865 else
866 # ...otherwise fall back to using sed.
867 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
868 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
869 if test "X$func_dirname_result" = "X$1"; then
870 func_dirname_result=$3
871 else
872 func_append func_dirname_result "$2"
876 eval 'func_basename ()
878 $debug_cmd
880 '"$_b"'
884 # func_dirname FILE APPEND NONDIR_REPLACEMENT
885 # -------------------------------------------
886 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
887 # otherwise set result to NONDIR_REPLACEMENT.
888 eval 'func_dirname ()
890 $debug_cmd
892 '"$_d"'
896 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
897 # --------------------------------------------------------
898 # Perform func_basename and func_dirname in a single function
899 # call:
900 # dirname: Compute the dirname of FILE. If nonempty,
901 # add APPEND to the result, otherwise set result
902 # to NONDIR_REPLACEMENT.
903 # value returned in "$func_dirname_result"
904 # basename: Compute filename of FILE.
905 # value retuned in "$func_basename_result"
906 # For efficiency, we do not delegate to the functions above but instead
907 # duplicate the functionality here.
908 eval 'func_dirname_and_basename ()
910 $debug_cmd
912 '"$_b"'
913 '"$_d"'
917 # func_echo ARG...
918 # ----------------
919 # Echo program name prefixed message.
920 func_echo ()
922 $debug_cmd
924 _G_message=$*
926 func_echo_IFS=$IFS
927 IFS=$nl
928 for _G_line in $_G_message; do
929 IFS=$func_echo_IFS
930 $ECHO "$progname: $_G_line"
931 done
932 IFS=$func_echo_IFS
936 # func_echo_all ARG...
937 # --------------------
938 # Invoke $ECHO with all args, space-separated.
939 func_echo_all ()
941 $ECHO "$*"
945 # func_echo_infix_1 INFIX ARG...
946 # ------------------------------
947 # Echo program name, followed by INFIX on the first line, with any
948 # additional lines not showing INFIX.
949 func_echo_infix_1 ()
951 $debug_cmd
953 $require_term_colors
955 _G_infix=$1; shift
956 _G_indent=$_G_infix
957 _G_prefix="$progname: $_G_infix: "
958 _G_message=$*
960 # Strip color escape sequences before counting printable length
961 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
963 test -n "$_G_tc" && {
964 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
965 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
967 done
968 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
970 func_echo_infix_1_IFS=$IFS
971 IFS=$nl
972 for _G_line in $_G_message; do
973 IFS=$func_echo_infix_1_IFS
974 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
975 _G_prefix=$_G_indent
976 done
977 IFS=$func_echo_infix_1_IFS
981 # func_error ARG...
982 # -----------------
983 # Echo program name prefixed message to standard error.
984 func_error ()
986 $debug_cmd
988 $require_term_colors
990 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
994 # func_fatal_error ARG...
995 # -----------------------
996 # Echo program name prefixed message to standard error, and exit.
997 func_fatal_error ()
999 $debug_cmd
1001 func_error "$*"
1002 exit $EXIT_FAILURE
1006 # func_grep EXPRESSION FILENAME
1007 # -----------------------------
1008 # Check whether EXPRESSION matches any line of FILENAME, without output.
1009 func_grep ()
1011 $debug_cmd
1013 $GREP "$1" "$2" >/dev/null 2>&1
1017 # func_len STRING
1018 # ---------------
1019 # Set func_len_result to the length of STRING. STRING may not
1020 # start with a hyphen.
1021 test -z "$_G_HAVE_XSI_OPS" \
1022 && (eval 'x=a/b/c;
1023 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1024 && _G_HAVE_XSI_OPS=yes
1026 if test yes = "$_G_HAVE_XSI_OPS"; then
1027 eval 'func_len ()
1029 $debug_cmd
1031 func_len_result=${#1}
1033 else
1034 func_len ()
1036 $debug_cmd
1038 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
1043 # func_mkdir_p DIRECTORY-PATH
1044 # ---------------------------
1045 # Make sure the entire path to DIRECTORY-PATH is available.
1046 func_mkdir_p ()
1048 $debug_cmd
1050 _G_directory_path=$1
1051 _G_dir_list=
1053 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
1055 # Protect directory names starting with '-'
1056 case $_G_directory_path in
1057 -*) _G_directory_path=./$_G_directory_path ;;
1058 esac
1060 # While some portion of DIR does not yet exist...
1061 while test ! -d "$_G_directory_path"; do
1062 # ...make a list in topmost first order. Use a colon delimited
1063 # list incase some portion of path contains whitespace.
1064 _G_dir_list=$_G_directory_path:$_G_dir_list
1066 # If the last portion added has no slash in it, the list is done
1067 case $_G_directory_path in */*) ;; *) break ;; esac
1069 # ...otherwise throw away the child directory and loop
1070 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
1071 done
1072 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
1074 func_mkdir_p_IFS=$IFS; IFS=:
1075 for _G_dir in $_G_dir_list; do
1076 IFS=$func_mkdir_p_IFS
1077 # mkdir can fail with a 'File exist' error if two processes
1078 # try to create one of the directories concurrently. Don't
1079 # stop in that case!
1080 $MKDIR "$_G_dir" 2>/dev/null || :
1081 done
1082 IFS=$func_mkdir_p_IFS
1084 # Bail out if we (or some other process) failed to create a directory.
1085 test -d "$_G_directory_path" || \
1086 func_fatal_error "Failed to create '$1'"
1091 # func_mktempdir [BASENAME]
1092 # -------------------------
1093 # Make a temporary directory that won't clash with other running
1094 # libtool processes, and avoids race conditions if possible. If
1095 # given, BASENAME is the basename for that directory.
1096 func_mktempdir ()
1098 $debug_cmd
1100 _G_template=${TMPDIR-/tmp}/${1-$progname}
1102 if test : = "$opt_dry_run"; then
1103 # Return a directory name, but don't create it in dry-run mode
1104 _G_tmpdir=$_G_template-$$
1105 else
1107 # If mktemp works, use that first and foremost
1108 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
1110 if test ! -d "$_G_tmpdir"; then
1111 # Failing that, at least try and use $RANDOM to avoid a race
1112 _G_tmpdir=$_G_template-${RANDOM-0}$$
1114 func_mktempdir_umask=`umask`
1115 umask 0077
1116 $MKDIR "$_G_tmpdir"
1117 umask $func_mktempdir_umask
1120 # If we're not in dry-run mode, bomb out on failure
1121 test -d "$_G_tmpdir" || \
1122 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
1125 $ECHO "$_G_tmpdir"
1129 # func_normal_abspath PATH
1130 # ------------------------
1131 # Remove doubled-up and trailing slashes, "." path components,
1132 # and cancel out any ".." path components in PATH after making
1133 # it an absolute path.
1134 func_normal_abspath ()
1136 $debug_cmd
1138 # These SED scripts presuppose an absolute path with a trailing slash.
1139 _G_pathcar='s|^/\([^/]*\).*$|\1|'
1140 _G_pathcdr='s|^/[^/]*||'
1141 _G_removedotparts=':dotsl
1142 s|/\./|/|g
1143 t dotsl
1144 s|/\.$|/|'
1145 _G_collapseslashes='s|/\{1,\}|/|g'
1146 _G_finalslash='s|/*$|/|'
1148 # Start from root dir and reassemble the path.
1149 func_normal_abspath_result=
1150 func_normal_abspath_tpath=$1
1151 func_normal_abspath_altnamespace=
1152 case $func_normal_abspath_tpath in
1154 # Empty path, that just means $cwd.
1155 func_stripname '' '/' "`pwd`"
1156 func_normal_abspath_result=$func_stripname_result
1157 return
1159 # The next three entries are used to spot a run of precisely
1160 # two leading slashes without using negated character classes;
1161 # we take advantage of case's first-match behaviour.
1162 ///*)
1163 # Unusual form of absolute path, do nothing.
1165 //*)
1166 # Not necessarily an ordinary path; POSIX reserves leading '//'
1167 # and for example Cygwin uses it to access remote file shares
1168 # over CIFS/SMB, so we conserve a leading double slash if found.
1169 func_normal_abspath_altnamespace=/
1172 # Absolute path, do nothing.
1175 # Relative path, prepend $cwd.
1176 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
1178 esac
1180 # Cancel out all the simple stuff to save iterations. We also want
1181 # the path to end with a slash for ease of parsing, so make sure
1182 # there is one (and only one) here.
1183 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1184 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
1185 while :; do
1186 # Processed it all yet?
1187 if test / = "$func_normal_abspath_tpath"; then
1188 # If we ascended to the root using ".." the result may be empty now.
1189 if test -z "$func_normal_abspath_result"; then
1190 func_normal_abspath_result=/
1192 break
1194 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
1195 -e "$_G_pathcar"`
1196 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1197 -e "$_G_pathcdr"`
1198 # Figure out what to do with it
1199 case $func_normal_abspath_tcomponent in
1201 # Trailing empty path component, ignore it.
1204 # Parent dir; strip last assembled component from result.
1205 func_dirname "$func_normal_abspath_result"
1206 func_normal_abspath_result=$func_dirname_result
1209 # Actual path component, append it.
1210 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1212 esac
1213 done
1214 # Restore leading double-slash if one was found on entry.
1215 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1219 # func_notquiet ARG...
1220 # --------------------
1221 # Echo program name prefixed message only when not in quiet mode.
1222 func_notquiet ()
1224 $debug_cmd
1226 $opt_quiet || func_echo ${1+"$@"}
1228 # A bug in bash halts the script if the last line of a function
1229 # fails when set -e is in force, so we need another command to
1230 # work around that:
1235 # func_relative_path SRCDIR DSTDIR
1236 # --------------------------------
1237 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1238 func_relative_path ()
1240 $debug_cmd
1242 func_relative_path_result=
1243 func_normal_abspath "$1"
1244 func_relative_path_tlibdir=$func_normal_abspath_result
1245 func_normal_abspath "$2"
1246 func_relative_path_tbindir=$func_normal_abspath_result
1248 # Ascend the tree starting from libdir
1249 while :; do
1250 # check if we have found a prefix of bindir
1251 case $func_relative_path_tbindir in
1252 $func_relative_path_tlibdir)
1253 # found an exact match
1254 func_relative_path_tcancelled=
1255 break
1257 $func_relative_path_tlibdir*)
1258 # found a matching prefix
1259 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1260 func_relative_path_tcancelled=$func_stripname_result
1261 if test -z "$func_relative_path_result"; then
1262 func_relative_path_result=.
1264 break
1267 func_dirname $func_relative_path_tlibdir
1268 func_relative_path_tlibdir=$func_dirname_result
1269 if test -z "$func_relative_path_tlibdir"; then
1270 # Have to descend all the way to the root!
1271 func_relative_path_result=../$func_relative_path_result
1272 func_relative_path_tcancelled=$func_relative_path_tbindir
1273 break
1275 func_relative_path_result=../$func_relative_path_result
1277 esac
1278 done
1280 # Now calculate path; take care to avoid doubling-up slashes.
1281 func_stripname '' '/' "$func_relative_path_result"
1282 func_relative_path_result=$func_stripname_result
1283 func_stripname '/' '/' "$func_relative_path_tcancelled"
1284 if test -n "$func_stripname_result"; then
1285 func_append func_relative_path_result "/$func_stripname_result"
1288 # Normalisation. If bindir is libdir, return '.' else relative path.
1289 if test -n "$func_relative_path_result"; then
1290 func_stripname './' '' "$func_relative_path_result"
1291 func_relative_path_result=$func_stripname_result
1294 test -n "$func_relative_path_result" || func_relative_path_result=.
1300 # func_quote_portable EVAL ARG
1301 # ----------------------------
1302 # Internal function to portably implement func_quote_arg. Note that we still
1303 # keep attention to performance here so we as much as possible try to avoid
1304 # calling sed binary (so far O(N) complexity as long as func_append is O(1)).
1305 func_quote_portable ()
1307 $debug_cmd
1309 $require_check_ifs_backslash
1311 func_quote_portable_result=$2
1313 # one-time-loop (easy break)
1314 while true
1316 if $1; then
1317 func_quote_portable_result=`$ECHO "$2" | $SED \
1318 -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
1319 break
1322 # Quote for eval.
1323 case $func_quote_portable_result in
1324 *[\\\`\"\$]*)
1325 # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string
1326 # contains the shell wildcard characters.
1327 case $check_ifs_backshlash_broken$func_quote_portable_result in
1328 :*|*[\[\*\?]*)
1329 func_quote_portable_result=`$ECHO "$func_quote_portable_result" \
1330 | $SED "$sed_quote_subst"`
1331 break
1333 esac
1335 func_quote_portable_old_IFS=$IFS
1336 for _G_char in '\' '`' '"' '$'
1338 # STATE($1) PREV($2) SEPARATOR($3)
1339 set start "" ""
1340 func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
1341 IFS=$_G_char
1342 for _G_part in $func_quote_portable_result
1344 case $1 in
1345 quote)
1346 func_append func_quote_portable_result "$3$2"
1347 set quote "$_G_part" "\\$_G_char"
1349 start)
1350 set first "" ""
1351 func_quote_portable_result=
1353 first)
1354 set quote "$_G_part" ""
1356 esac
1357 done
1358 done
1359 IFS=$func_quote_portable_old_IFS
1361 *) ;;
1362 esac
1363 break
1364 done
1366 func_quote_portable_unquoted_result=$func_quote_portable_result
1367 case $func_quote_portable_result in
1368 # double-quote args containing shell metacharacters to delay
1369 # word splitting, command substitution and variable expansion
1370 # for a subsequent eval.
1371 # many bourne shells cannot handle close brackets correctly
1372 # in scan sets, so we specify it separately.
1373 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1374 func_quote_portable_result=\"$func_quote_portable_result\"
1376 esac
1380 # func_quotefast_eval ARG
1381 # -----------------------
1382 # Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG',
1383 # but optimized for speed. Result is stored in $func_quotefast_eval.
1384 if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
1385 printf -v _GL_test_printf_tilde %q '~'
1386 if test '\~' = "$_GL_test_printf_tilde"; then
1387 func_quotefast_eval ()
1389 printf -v func_quotefast_eval_result %q "$1"
1391 else
1392 # Broken older Bash implementations. Make those faster too if possible.
1393 func_quotefast_eval ()
1395 case $1 in
1396 '~'*)
1397 func_quote_portable false "$1"
1398 func_quotefast_eval_result=$func_quote_portable_result
1401 printf -v func_quotefast_eval_result %q "$1"
1403 esac
1406 else
1407 func_quotefast_eval ()
1409 func_quote_portable false "$1"
1410 func_quotefast_eval_result=$func_quote_portable_result
1415 # func_quote_arg MODEs ARG
1416 # ------------------------
1417 # Quote one ARG to be evaled later. MODEs argument may contain zero or more
1418 # specifiers listed below separated by ',' character. This function returns two
1419 # values:
1420 # i) func_quote_arg_result
1421 # double-quoted (when needed), suitable for a subsequent eval
1422 # ii) func_quote_arg_unquoted_result
1423 # has all characters that are still active within double
1424 # quotes backslashified. Available only if 'unquoted' is specified.
1426 # Available modes:
1427 # ----------------
1428 # 'eval' (default)
1429 # - escape shell special characters
1430 # 'expand'
1431 # - the same as 'eval'; but do not quote variable references
1432 # 'pretty'
1433 # - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might
1434 # be used later in func_quote to get output like: 'echo "a b"' instead
1435 # of 'echo a\ b'. This is slower than default on some shells.
1436 # 'unquoted'
1437 # - produce also $func_quote_arg_unquoted_result which does not contain
1438 # wrapping double-quotes.
1440 # Examples for 'func_quote_arg pretty,unquoted string':
1442 # string | *_result | *_unquoted_result
1443 # ------------+-----------------------+-------------------
1444 # " | \" | \"
1445 # a b | "a b" | a b
1446 # "a b" | "\"a b\"" | \"a b\"
1447 # * | "*" | *
1448 # z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\"
1450 # Examples for 'func_quote_arg pretty,unquoted,expand string':
1452 # string | *_result | *_unquoted_result
1453 # --------------+---------------------+--------------------
1454 # z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\"
1455 func_quote_arg ()
1457 _G_quote_expand=false
1458 case ,$1, in
1459 *,expand,*)
1460 _G_quote_expand=:
1462 esac
1464 case ,$1, in
1465 *,pretty,*|*,expand,*|*,unquoted,*)
1466 func_quote_portable $_G_quote_expand "$2"
1467 func_quote_arg_result=$func_quote_portable_result
1468 func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
1471 # Faster quote-for-eval for some shells.
1472 func_quotefast_eval "$2"
1473 func_quote_arg_result=$func_quotefast_eval_result
1475 esac
1479 # func_quote MODEs ARGs...
1480 # ------------------------
1481 # Quote all ARGs to be evaled later and join them into single command. See
1482 # func_quote_arg's description for more info.
1483 func_quote ()
1485 $debug_cmd
1486 _G_func_quote_mode=$1 ; shift
1487 func_quote_result=
1488 while test 0 -lt $#; do
1489 func_quote_arg "$_G_func_quote_mode" "$1"
1490 if test -n "$func_quote_result"; then
1491 func_append func_quote_result " $func_quote_arg_result"
1492 else
1493 func_append func_quote_result "$func_quote_arg_result"
1495 shift
1496 done
1500 # func_stripname PREFIX SUFFIX NAME
1501 # ---------------------------------
1502 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1503 # PREFIX and SUFFIX must not contain globbing or regex special
1504 # characters, hashes, percent signs, but SUFFIX may contain a leading
1505 # dot (in which case that matches only a dot).
1506 if test yes = "$_G_HAVE_XSI_OPS"; then
1507 eval 'func_stripname ()
1509 $debug_cmd
1511 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1512 # positional parameters, so assign one to ordinary variable first.
1513 func_stripname_result=$3
1514 func_stripname_result=${func_stripname_result#"$1"}
1515 func_stripname_result=${func_stripname_result%"$2"}
1517 else
1518 func_stripname ()
1520 $debug_cmd
1522 case $2 in
1523 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1524 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1525 esac
1530 # func_show_eval CMD [FAIL_EXP]
1531 # -----------------------------
1532 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1533 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1534 # is given, then evaluate it.
1535 func_show_eval ()
1537 $debug_cmd
1539 _G_cmd=$1
1540 _G_fail_exp=${2-':'}
1542 func_quote_arg pretty,expand "$_G_cmd"
1543 eval "func_notquiet $func_quote_arg_result"
1545 $opt_dry_run || {
1546 eval "$_G_cmd"
1547 _G_status=$?
1548 if test 0 -ne "$_G_status"; then
1549 eval "(exit $_G_status); $_G_fail_exp"
1555 # func_show_eval_locale CMD [FAIL_EXP]
1556 # ------------------------------------
1557 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1558 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1559 # is given, then evaluate it. Use the saved locale for evaluation.
1560 func_show_eval_locale ()
1562 $debug_cmd
1564 _G_cmd=$1
1565 _G_fail_exp=${2-':'}
1567 $opt_quiet || {
1568 func_quote_arg expand,pretty "$_G_cmd"
1569 eval "func_echo $func_quote_arg_result"
1572 $opt_dry_run || {
1573 eval "$_G_user_locale
1574 $_G_cmd"
1575 _G_status=$?
1576 eval "$_G_safe_locale"
1577 if test 0 -ne "$_G_status"; then
1578 eval "(exit $_G_status); $_G_fail_exp"
1584 # func_tr_sh
1585 # ----------
1586 # Turn $1 into a string suitable for a shell variable name.
1587 # Result is stored in $func_tr_sh_result. All characters
1588 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1589 # if $1 begins with a digit, a '_' is prepended as well.
1590 func_tr_sh ()
1592 $debug_cmd
1594 case $1 in
1595 [0-9]* | *[!a-zA-Z0-9_]*)
1596 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1599 func_tr_sh_result=$1
1601 esac
1605 # func_verbose ARG...
1606 # -------------------
1607 # Echo program name prefixed message in verbose mode only.
1608 func_verbose ()
1610 $debug_cmd
1612 $opt_verbose && func_echo "$*"
1618 # func_warn_and_continue ARG...
1619 # -----------------------------
1620 # Echo program name prefixed warning message to standard error.
1621 func_warn_and_continue ()
1623 $debug_cmd
1625 $require_term_colors
1627 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1631 # func_warning CATEGORY ARG...
1632 # ----------------------------
1633 # Echo program name prefixed warning message to standard error. Warning
1634 # messages can be filtered according to CATEGORY, where this function
1635 # elides messages where CATEGORY is not listed in the global variable
1636 # 'opt_warning_types'.
1637 func_warning ()
1639 $debug_cmd
1641 # CATEGORY must be in the warning_categories list!
1642 case " $warning_categories " in
1643 *" $1 "*) ;;
1644 *) func_internal_error "invalid warning category '$1'" ;;
1645 esac
1647 _G_category=$1
1648 shift
1650 case " $opt_warning_types " in
1651 *" $_G_category "*) $warning_func ${1+"$@"} ;;
1652 esac
1656 # func_sort_ver VER1 VER2
1657 # -----------------------
1658 # 'sort -V' is not generally available.
1659 # Note this deviates from the version comparison in automake
1660 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1661 # but this should suffice as we won't be specifying old
1662 # version formats or redundant trailing .0 in bootstrap.conf.
1663 # If we did want full compatibility then we should probably
1664 # use m4_version_compare from autoconf.
1665 func_sort_ver ()
1667 $debug_cmd
1669 printf '%s\n%s\n' "$1" "$2" \
1670 | 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
1673 # func_lt_ver PREV CURR
1674 # ---------------------
1675 # Return true if PREV and CURR are in the correct order according to
1676 # func_sort_ver, otherwise false. Use it like this:
1678 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1679 func_lt_ver ()
1681 $debug_cmd
1683 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1687 # Local variables:
1688 # mode: shell-script
1689 # sh-indentation: 2
1690 # eval: (add-hook 'before-save-hook 'time-stamp)
1691 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1692 # time-stamp-time-zone: "UTC"
1693 # End:
1694 #! /bin/sh
1696 # A portable, pluggable option parser for Bourne shell.
1697 # Written by Gary V. Vaughan, 2010
1699 # This is free software. There is NO warranty; not even for
1700 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1702 # Copyright (C) 2010-2019, 2021, 2023 Bootstrap Authors
1704 # This file is dual licensed under the terms of the MIT license
1705 # <https://opensource.org/licenses/MIT>, and GPL version 2 or later
1706 # <https://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of
1707 # these licenses when using or redistributing this software or any of
1708 # the files within it. See the URLs above, or the file `LICENSE`
1709 # included in the Bootstrap distribution for the full license texts.
1711 # Please report bugs or propose patches to:
1712 # <https://github.com/gnulib-modules/bootstrap/issues>
1714 # Set a version string for this script.
1715 scriptversion=2019-02-19.15; # UTC
1718 ## ------ ##
1719 ## Usage. ##
1720 ## ------ ##
1722 # This file is a library for parsing options in your shell scripts along
1723 # with assorted other useful supporting features that you can make use
1724 # of too.
1726 # For the simplest scripts you might need only:
1728 # #!/bin/sh
1729 # . relative/path/to/funclib.sh
1730 # . relative/path/to/options-parser
1731 # scriptversion=1.0
1732 # func_options ${1+"$@"}
1733 # eval set dummy "$func_options_result"; shift
1734 # ...rest of your script...
1736 # In order for the '--version' option to work, you will need to have a
1737 # suitably formatted comment like the one at the top of this file
1738 # starting with '# Written by ' and ending with '# Copyright'.
1740 # For '-h' and '--help' to work, you will also need a one line
1741 # description of your script's purpose in a comment directly above the
1742 # '# Written by ' line, like the one at the top of this file.
1744 # The default options also support '--debug', which will turn on shell
1745 # execution tracing (see the comment above debug_cmd below for another
1746 # use), and '--verbose' and the func_verbose function to allow your script
1747 # to display verbose messages only when your user has specified
1748 # '--verbose'.
1750 # After sourcing this file, you can plug in processing for additional
1751 # options by amending the variables from the 'Configuration' section
1752 # below, and following the instructions in the 'Option parsing'
1753 # section further down.
1755 ## -------------- ##
1756 ## Configuration. ##
1757 ## -------------- ##
1759 # You should override these variables in your script after sourcing this
1760 # file so that they reflect the customisations you have added to the
1761 # option parser.
1763 # The usage line for option parsing errors and the start of '-h' and
1764 # '--help' output messages. You can embed shell variables for delayed
1765 # expansion at the time the message is displayed, but you will need to
1766 # quote other shell meta-characters carefully to prevent them being
1767 # expanded when the contents are evaled.
1768 usage='$progpath [OPTION]...'
1770 # Short help message in response to '-h' and '--help'. Add to this or
1771 # override it after sourcing this library to reflect the full set of
1772 # options your script accepts.
1773 usage_message="\
1774 --debug enable verbose shell tracing
1775 -W, --warnings=CATEGORY
1776 report the warnings falling in CATEGORY [all]
1777 -v, --verbose verbosely report processing
1778 --version print version information and exit
1779 -h, --help print short or long help message and exit
1782 # Additional text appended to 'usage_message' in response to '--help'.
1783 long_help_message="
1784 Warning categories include:
1785 'all' show all warnings
1786 'none' turn off all the warnings
1787 'error' warnings are treated as fatal errors"
1789 # Help message printed before fatal option parsing errors.
1790 fatal_help="Try '\$progname --help' for more information."
1794 ## ------------------------- ##
1795 ## Hook function management. ##
1796 ## ------------------------- ##
1798 # This section contains functions for adding, removing, and running hooks
1799 # in the main code. A hook is just a list of function names that can be
1800 # run in order later on.
1802 # func_hookable FUNC_NAME
1803 # -----------------------
1804 # Declare that FUNC_NAME will run hooks added with
1805 # 'func_add_hook FUNC_NAME ...'.
1806 func_hookable ()
1808 $debug_cmd
1810 func_append hookable_fns " $1"
1814 # func_add_hook FUNC_NAME HOOK_FUNC
1815 # ---------------------------------
1816 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
1817 # first have been declared "hookable" by a call to 'func_hookable'.
1818 func_add_hook ()
1820 $debug_cmd
1822 case " $hookable_fns " in
1823 *" $1 "*) ;;
1824 *) func_fatal_error "'$1' does not accept hook functions." ;;
1825 esac
1827 eval func_append ${1}_hooks '" $2"'
1831 # func_remove_hook FUNC_NAME HOOK_FUNC
1832 # ------------------------------------
1833 # Remove HOOK_FUNC from the list of hook functions to be called by
1834 # FUNC_NAME.
1835 func_remove_hook ()
1837 $debug_cmd
1839 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1843 # func_propagate_result FUNC_NAME_A FUNC_NAME_B
1844 # ---------------------------------------------
1845 # If the *_result variable of FUNC_NAME_A _is set_, assign its value to
1846 # *_result variable of FUNC_NAME_B.
1847 func_propagate_result ()
1849 $debug_cmd
1851 func_propagate_result_result=:
1852 if eval "test \"\${${1}_result+set}\" = set"
1853 then
1854 eval "${2}_result=\$${1}_result"
1855 else
1856 func_propagate_result_result=false
1861 # func_run_hooks FUNC_NAME [ARG]...
1862 # ---------------------------------
1863 # Run all hook functions registered to FUNC_NAME.
1864 # It's assumed that the list of hook functions contains nothing more
1865 # than a whitespace-delimited list of legal shell function names, and
1866 # no effort is wasted trying to catch shell meta-characters or preserve
1867 # whitespace.
1868 func_run_hooks ()
1870 $debug_cmd
1872 case " $hookable_fns " in
1873 *" $1 "*) ;;
1874 *) func_fatal_error "'$1' does not support hook functions." ;;
1875 esac
1877 eval _G_hook_fns=\$$1_hooks; shift
1879 for _G_hook in $_G_hook_fns; do
1880 func_unset "${_G_hook}_result"
1881 eval $_G_hook '${1+"$@"}'
1882 func_propagate_result $_G_hook func_run_hooks
1883 if $func_propagate_result_result; then
1884 eval set dummy "$func_run_hooks_result"; shift
1886 done
1891 ## --------------- ##
1892 ## Option parsing. ##
1893 ## --------------- ##
1895 # In order to add your own option parsing hooks, you must accept the
1896 # full positional parameter list from your hook function. You may remove
1897 # or edit any options that you action, and then pass back the remaining
1898 # unprocessed options in '<hooked_function_name>_result', escaped
1899 # suitably for 'eval'.
1901 # The '<hooked_function_name>_result' variable is automatically unset
1902 # before your hook gets called; for best performance, only set the
1903 # *_result variable when necessary (i.e. don't call the 'func_quote'
1904 # function unnecessarily because it can be an expensive operation on some
1905 # machines).
1907 # Like this:
1909 # my_options_prep ()
1911 # $debug_cmd
1913 # # Extend the existing usage message.
1914 # usage_message=$usage_message'
1915 # -s, --silent don'\''t print informational messages
1917 # # No change in '$@' (ignored completely by this hook). Leave
1918 # # my_options_prep_result variable intact.
1920 # func_add_hook func_options_prep my_options_prep
1923 # my_silent_option ()
1925 # $debug_cmd
1927 # args_changed=false
1929 # # Note that, for efficiency, we parse as many options as we can
1930 # # recognise in a loop before passing the remainder back to the
1931 # # caller on the first unrecognised argument we encounter.
1932 # while test $# -gt 0; do
1933 # opt=$1; shift
1934 # case $opt in
1935 # --silent|-s) opt_silent=:
1936 # args_changed=:
1937 # ;;
1938 # # Separate non-argument short options:
1939 # -s*) func_split_short_opt "$_G_opt"
1940 # set dummy "$func_split_short_opt_name" \
1941 # "-$func_split_short_opt_arg" ${1+"$@"}
1942 # shift
1943 # args_changed=:
1944 # ;;
1945 # *) # Make sure the first unrecognised option "$_G_opt"
1946 # # is added back to "$@" in case we need it later,
1947 # # if $args_changed was set to 'true'.
1948 # set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1949 # esac
1950 # done
1952 # # Only call 'func_quote' here if we processed at least one argument.
1953 # if $args_changed; then
1954 # func_quote eval ${1+"$@"}
1955 # my_silent_option_result=$func_quote_result
1956 # fi
1958 # func_add_hook func_parse_options my_silent_option
1961 # my_option_validation ()
1963 # $debug_cmd
1965 # $opt_silent && $opt_verbose && func_fatal_help "\
1966 # '--silent' and '--verbose' options are mutually exclusive."
1968 # func_add_hook func_validate_options my_option_validation
1970 # You'll also need to manually amend $usage_message to reflect the extra
1971 # options you parse. It's preferable to append if you can, so that
1972 # multiple option parsing hooks can be added safely.
1975 # func_options_finish [ARG]...
1976 # ----------------------------
1977 # Finishing the option parse loop (call 'func_options' hooks ATM).
1978 func_options_finish ()
1980 $debug_cmd
1982 func_run_hooks func_options ${1+"$@"}
1983 func_propagate_result func_run_hooks func_options_finish
1987 # func_options [ARG]...
1988 # ---------------------
1989 # All the functions called inside func_options are hookable. See the
1990 # individual implementations for details.
1991 func_hookable func_options
1992 func_options ()
1994 $debug_cmd
1996 _G_options_quoted=false
1998 for my_func in options_prep parse_options validate_options options_finish
2000 func_unset func_${my_func}_result
2001 func_unset func_run_hooks_result
2002 eval func_$my_func '${1+"$@"}'
2003 func_propagate_result func_$my_func func_options
2004 if $func_propagate_result_result; then
2005 eval set dummy "$func_options_result"; shift
2006 _G_options_quoted=:
2008 done
2010 $_G_options_quoted || {
2011 # As we (func_options) are top-level options-parser function and
2012 # nobody quoted "$@" for us yet, we need to do it explicitly for
2013 # caller.
2014 func_quote eval ${1+"$@"}
2015 func_options_result=$func_quote_result
2020 # func_options_prep [ARG]...
2021 # --------------------------
2022 # All initialisations required before starting the option parse loop.
2023 # Note that when calling hook functions, we pass through the list of
2024 # positional parameters. If a hook function modifies that list, and
2025 # needs to propagate that back to rest of this script, then the complete
2026 # modified list must be put in 'func_run_hooks_result' before returning.
2027 func_hookable func_options_prep
2028 func_options_prep ()
2030 $debug_cmd
2032 # Option defaults:
2033 opt_verbose=false
2034 opt_warning_types=
2036 func_run_hooks func_options_prep ${1+"$@"}
2037 func_propagate_result func_run_hooks func_options_prep
2041 # func_parse_options [ARG]...
2042 # ---------------------------
2043 # The main option parsing loop.
2044 func_hookable func_parse_options
2045 func_parse_options ()
2047 $debug_cmd
2049 _G_parse_options_requote=false
2050 # this just eases exit handling
2051 while test $# -gt 0; do
2052 # Defer to hook functions for initial option parsing, so they
2053 # get priority in the event of reusing an option name.
2054 func_run_hooks func_parse_options ${1+"$@"}
2055 func_propagate_result func_run_hooks func_parse_options
2056 if $func_propagate_result_result; then
2057 eval set dummy "$func_parse_options_result"; shift
2058 # Even though we may have changed "$@", we passed the "$@" array
2059 # down into the hook and it quoted it for us (because we are in
2060 # this if-branch). No need to quote it again.
2061 _G_parse_options_requote=false
2064 # Break out of the loop if we already parsed every option.
2065 test $# -gt 0 || break
2067 # We expect that one of the options parsed in this function matches
2068 # and thus we remove _G_opt from "$@" and need to re-quote.
2069 _G_match_parse_options=:
2070 _G_opt=$1
2071 shift
2072 case $_G_opt in
2073 --debug|-x) debug_cmd='set -x'
2074 func_echo "enabling shell trace mode" >&2
2075 $debug_cmd
2078 --no-warnings|--no-warning|--no-warn)
2079 set dummy --warnings none ${1+"$@"}
2080 shift
2083 --warnings|--warning|-W)
2084 if test $# = 0 && func_missing_arg $_G_opt; then
2085 _G_parse_options_requote=:
2086 break
2088 case " $warning_categories $1" in
2089 *" $1 "*)
2090 # trailing space prevents matching last $1 above
2091 func_append_uniq opt_warning_types " $1"
2093 *all)
2094 opt_warning_types=$warning_categories
2096 *none)
2097 opt_warning_types=none
2098 warning_func=:
2100 *error)
2101 opt_warning_types=$warning_categories
2102 warning_func=func_fatal_error
2105 func_fatal_error \
2106 "unsupported warning category: '$1'"
2108 esac
2109 shift
2112 --verbose|-v) opt_verbose=: ;;
2113 --version) func_version ;;
2114 -\?|-h) func_usage ;;
2115 --help) func_help ;;
2117 # Separate optargs to long options (plugins may need this):
2118 --*=*) func_split_equals "$_G_opt"
2119 set dummy "$func_split_equals_lhs" \
2120 "$func_split_equals_rhs" ${1+"$@"}
2121 shift
2124 # Separate optargs to short options:
2125 -W*)
2126 func_split_short_opt "$_G_opt"
2127 set dummy "$func_split_short_opt_name" \
2128 "$func_split_short_opt_arg" ${1+"$@"}
2129 shift
2132 # Separate non-argument short options:
2133 -\?*|-h*|-v*|-x*)
2134 func_split_short_opt "$_G_opt"
2135 set dummy "$func_split_short_opt_name" \
2136 "-$func_split_short_opt_arg" ${1+"$@"}
2137 shift
2140 --) _G_parse_options_requote=: ; break ;;
2141 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
2142 *) set dummy "$_G_opt" ${1+"$@"}; shift
2143 _G_match_parse_options=false
2144 break
2146 esac
2148 if $_G_match_parse_options; then
2149 _G_parse_options_requote=:
2151 done
2153 if $_G_parse_options_requote; then
2154 # save modified positional parameters for caller
2155 func_quote eval ${1+"$@"}
2156 func_parse_options_result=$func_quote_result
2161 # func_validate_options [ARG]...
2162 # ------------------------------
2163 # Perform any sanity checks on option settings and/or unconsumed
2164 # arguments.
2165 func_hookable func_validate_options
2166 func_validate_options ()
2168 $debug_cmd
2170 # Display all warnings if -W was not given.
2171 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
2173 func_run_hooks func_validate_options ${1+"$@"}
2174 func_propagate_result func_run_hooks func_validate_options
2176 # Bail if the options were screwed!
2177 $exit_cmd $EXIT_FAILURE
2182 ## ----------------- ##
2183 ## Helper functions. ##
2184 ## ----------------- ##
2186 # This section contains the helper functions used by the rest of the
2187 # hookable option parser framework in ascii-betical order.
2190 # func_fatal_help ARG...
2191 # ----------------------
2192 # Echo program name prefixed message to standard error, followed by
2193 # a help hint, and exit.
2194 func_fatal_help ()
2196 $debug_cmd
2198 eval \$ECHO \""Usage: $usage"\"
2199 eval \$ECHO \""$fatal_help"\"
2200 func_error ${1+"$@"}
2201 exit $EXIT_FAILURE
2205 # func_help
2206 # ---------
2207 # Echo long help message to standard output and exit.
2208 func_help ()
2210 $debug_cmd
2212 func_usage_message
2213 $ECHO "$long_help_message"
2214 exit 0
2218 # func_missing_arg ARGNAME
2219 # ------------------------
2220 # Echo program name prefixed message to standard error and set global
2221 # exit_cmd.
2222 func_missing_arg ()
2224 $debug_cmd
2226 func_error "Missing argument for '$1'."
2227 exit_cmd=exit
2231 # func_split_equals STRING
2232 # ------------------------
2233 # Set func_split_equals_lhs and func_split_equals_rhs shell variables
2234 # after splitting STRING at the '=' sign.
2235 test -z "$_G_HAVE_XSI_OPS" \
2236 && (eval 'x=a/b/c;
2237 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
2238 && _G_HAVE_XSI_OPS=yes
2240 if test yes = "$_G_HAVE_XSI_OPS"
2241 then
2242 # This is an XSI compatible shell, allowing a faster implementation...
2243 eval 'func_split_equals ()
2245 $debug_cmd
2247 func_split_equals_lhs=${1%%=*}
2248 func_split_equals_rhs=${1#*=}
2249 if test "x$func_split_equals_lhs" = "x$1"; then
2250 func_split_equals_rhs=
2253 else
2254 # ...otherwise fall back to using expr, which is often a shell builtin.
2255 func_split_equals ()
2257 $debug_cmd
2259 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
2260 func_split_equals_rhs=
2261 test "x$func_split_equals_lhs=" = "x$1" \
2262 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
2264 fi #func_split_equals
2267 # func_split_short_opt SHORTOPT
2268 # -----------------------------
2269 # Set func_split_short_opt_name and func_split_short_opt_arg shell
2270 # variables after splitting SHORTOPT after the 2nd character.
2271 if test yes = "$_G_HAVE_XSI_OPS"
2272 then
2273 # This is an XSI compatible shell, allowing a faster implementation...
2274 eval 'func_split_short_opt ()
2276 $debug_cmd
2278 func_split_short_opt_arg=${1#??}
2279 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
2281 else
2282 # ...otherwise fall back to using expr, which is often a shell builtin.
2283 func_split_short_opt ()
2285 $debug_cmd
2287 func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'`
2288 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
2290 fi #func_split_short_opt
2293 # func_usage
2294 # ----------
2295 # Echo short help message to standard output and exit.
2296 func_usage ()
2298 $debug_cmd
2300 func_usage_message
2301 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
2302 exit 0
2306 # func_usage_message
2307 # ------------------
2308 # Echo short help message to standard output.
2309 func_usage_message ()
2311 $debug_cmd
2313 eval \$ECHO \""Usage: $usage"\"
2314 echo
2315 $SED -n 's|^# ||
2316 /^Written by/{
2317 x;p;x
2320 /^Written by/q' < "$progpath"
2321 echo
2322 eval \$ECHO \""$usage_message"\"
2326 # func_version
2327 # ------------
2328 # Echo version message to standard output and exit.
2329 # The version message is extracted from the calling file's header
2330 # comments, with leading '# ' stripped:
2331 # 1. First display the progname and version
2332 # 2. Followed by the header comment line matching /^# Written by /
2333 # 3. Then a blank line followed by the first following line matching
2334 # /^# Copyright /
2335 # 4. Immediately followed by any lines between the previous matches,
2336 # except lines preceding the intervening completely blank line.
2337 # For example, see the header comments of this file.
2338 func_version ()
2340 $debug_cmd
2342 printf '%s\n' "$progname $scriptversion"
2343 $SED -n '
2344 /^# Written by /!b
2345 s|^# ||; p; n
2347 :fwd2blnk
2348 /./ {
2350 b fwd2blnk
2352 p; n
2354 :holdwrnt
2355 s|^# ||
2356 s|^# *$||
2357 /^Copyright /!{
2358 /./H
2360 b holdwrnt
2363 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
2365 s|\(\n\)\n*|\1|g
2366 p; q' < "$progpath"
2368 exit $?
2372 # Local variables:
2373 # mode: shell-script
2374 # sh-indentation: 2
2375 # eval: (add-hook 'before-save-hook 'time-stamp)
2376 # time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2377 # time-stamp-time-zone: "UTC"
2378 # End:
2379 #! /bin/sh
2381 # Extract macro arguments from autotools input with GNU M4.
2382 # Written by Gary V. Vaughan, 2010
2384 # This is free software. There is NO warranty; not even for
2385 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2387 # Copyright (C) 2010-2019, 2021, 2023 Bootstrap Authors
2389 # This file is dual licensed under the terms of the MIT license
2390 # <https://opensource.org/licenses/MIT>, and GPL version 2 or later
2391 # <https://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of
2392 # these licenses when using or redistributing this software or any of
2393 # the files within it. See the URLs above, or the file `LICENSE`
2394 # included in the Bootstrap distribution for the full license texts.
2396 # Please report bugs or propose patches to:
2397 # <https://github.com/gnulib-modules/bootstrap/issues>
2399 # Make sure we've evaluated scripts we depend on.
2400 test -z "$progpath" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/funclib.sh
2401 test extract-trace = "$progname" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/options-parser
2403 # Set a version string.
2404 scriptversion=2019-02-19.15; # UTC
2407 ## ------ ##
2408 ## Usage. ##
2409 ## ------ ##
2411 # Run './extract-trace --help' for help with using this script from the
2412 # command line.
2414 # Or source first 'options-parser' and then this file into your own
2415 # scripts in order to make use of the function and variable framework
2416 # they define, and also to avoid the overhead of forking to run this
2417 # script in its own process on every call.
2421 ## ----------------- ##
2422 ## Helper functions. ##
2423 ## ----------------- ##
2425 # This section contains the helper functions used by the rest of
2426 # 'extract-trace'.
2429 # func_autoconf_configure MAYBE-CONFIGURE-FILE
2430 # --------------------------------------------
2431 # Ensure that MAYBE-CONFIGURE-FILE is the name of a file in the current
2432 # directory that contains an uncommented call to AC_INIT.
2433 func_autoconf_configure ()
2435 $debug_cmd
2437 _G_sed_no_comment='
2438 s|#.*$||
2439 s|^dnl .*$||
2440 s| dnl .*$||'
2441 _G_ac_init=
2443 # If we were passed a genuine file, make sure it calls AC_INIT.
2444 test -f "$1" \
2445 && _G_ac_init=`$SED "$_G_sed_no_comment" "$1" |$GREP AC_INIT`
2447 # Otherwise it is not a genuine Autoconf input file.
2448 test -n "$_G_ac_init"
2449 _G_status=$?
2451 test 0 -ne "$_G_status" \
2452 && func_verbose "'$1' not using Autoconf"
2454 (exit $_G_status)
2458 # func_tool_version_output CMD [FATAL-ERROR-MSG]
2459 # ----------------------------------------------
2460 # Attempt to run 'CMD --version', discarding errors. The output can be
2461 # ignored by redirecting stdout, and this function used simply to test
2462 # whether the command exists and exits normally when passed a
2463 # '--version' argument.
2464 # When FATAL-ERROR-MSG is given, then this function will display the
2465 # message and exit if running 'CMD --version' returns a non-zero exit
2466 # status.
2467 func_tool_version_output ()
2469 $debug_cmd
2471 _G_cmd=$1
2472 _G_fatal_error_msg=$2
2474 # Some tools, like 'git2cl' produce thousands of lines of output
2475 # unless stdin is /dev/null - in that case we want to return
2476 # successfully without saving all of that output. Other tools,
2477 # such as 'help2man' exit with a non-zero status when stdin comes
2478 # from /dev/null, so we re-execute without /dev/null if that
2479 # happens. This means that occasionally, the output from both calls
2480 # ends up in the result, but the alternative would be to discard the
2481 # output from one call, and hope the other produces something useful.
2482 { $_G_cmd --version </dev/null || $_G_cmd --version; } 2>/dev/null
2483 _G_status=$?
2485 test 0 -ne "$_G_status" && test -n "$_G_fatal_error_msg" \
2486 && func_fatal_error "$_G_fatal_error_msg"
2488 (exit $_G_status)
2492 # func_tool_version_number CMD [FATAL-ERROR-MSG]
2493 # ----------------------------------------------
2494 # Pass arguments to func_tool_version_output, but set
2495 # $func_tool_version_number_result to the last dot delimited digit string
2496 # on the first line of output.
2497 func_tool_version_number ()
2499 $debug_cmd
2501 _G_verout=`func_tool_version_output "$@"`
2502 _G_status=$?
2504 # A version number starts with a digit following a space on the first
2505 # line of output from `--version`.
2506 _G_verout=`echo "$_G_verout" |sed 1q`
2507 if test -n "$_G_verout"; then
2508 _G_vernum=`expr "$_G_verout" : '.* \([0-9][^ ]*\)'`
2511 if test -n "$_G_vernum"; then
2512 printf '%s\n' "$_G_vernum"
2513 else
2514 printf '%s\n' "$_G_verout"
2517 (exit $_G_status)
2521 # func_find_tool ENVVAR NAMES...
2522 # ------------------------------
2523 # Search for a required program. Use the value of ENVVAR, if set,
2524 # otherwise find the first of the NAMES that can be run (i.e.,
2525 # supports --version). If found, set ENVVAR to the program name,
2526 # die otherwise.
2527 func_find_tool ()
2529 $debug_cmd
2531 _G_find_tool_envvar=$1
2532 shift
2533 _G_find_tool_names=$@
2534 eval "_G_find_tool_res=\$$_G_find_tool_envvar"
2535 if test -n "$_G_find_tool_res"; then
2536 _G_find_tool_error_prefix="\$$find_tool_envvar: "
2537 else
2538 _G_find_tool_res=
2539 _G_bestver=
2540 for _G_prog
2542 _G_find_tool_save_IFS=$IFS
2543 IFS=${PATH_SEPARATOR-:}
2544 for _G_dir in $PATH; do
2545 IFS=$_G_find_tool_save_IFS
2546 _G_progpath=$_G_dir/$_G_prog
2547 test -r "$_G_progpath" && {
2548 _G_curver=`func_tool_version_number $_G_progpath`
2549 case $_G_bestver,$_G_curver in
2551 # first non--version responsive prog sticks!
2552 test -n "$_G_progpath" || _G_find_tool_res=$_G_progpath
2555 # first --version responsive prog beats non--version responsive!
2556 _G_find_tool_res=$_G_progpath
2557 _G_bestver=$_G_curver
2559 *,*)
2560 # another --version responsive prog must be newer to beat previous one!
2561 test "x$_G_curver" = "x$_G_bestver" \
2562 || func_lt_ver "$_G_curver" "$_G_bestver" \
2563 || {
2564 _G_find_tool_res=$_G_progpath
2565 _G_bestver=$_G_curver
2568 esac
2570 done
2571 IFS=$_G_find_tool_save_IFS
2572 done
2574 if test -n "$_G_find_tool_res"; then
2575 func_tool_version_number >/dev/null $_G_find_tool_res "\
2576 ${_G_find_tool_error_prefix}Cannot run '$_G_find_tool_res --version'"
2578 # Make sure the result is exported to the environment for children
2579 # to use.
2580 eval "$_G_find_tool_envvar=\$_G_find_tool_res"
2581 eval "export $_G_find_tool_envvar"
2582 else
2583 func_error "\
2584 One of these is required:
2585 $_G_find_tool_names"
2591 ## -------------------- ##
2592 ## Resource management. ##
2593 ## -------------------- ##
2595 # This section contains definitions for functions that each ensure a
2596 # particular resource (a file, or a non-empty configuration variable for
2597 # example) is available, and if appropriate to extract default values
2598 # from pertinent package files. Where a variable already has a non-
2599 # empty value (as set by the package's 'bootstrap.conf'), that value is
2600 # used in preference to deriving the default. Call them using their
2601 # associated 'require_*' variable to ensure that they are executed, at
2602 # most, once.
2604 # It's entirely deliberate that calling these functions can set
2605 # variables that don't obey the namespace limitations obeyed by the rest
2606 # of this file, in order that that they be as useful as possible to
2607 # callers.
2610 # require_configure_ac
2611 # --------------------
2612 # Ensure that there is a 'configure.ac' or 'configure.in' file in the
2613 # current directory that contains an uncommented call to AC_INIT, and
2614 # that '$configure_ac' contains its name.
2615 require_configure_ac=func_require_configure_ac
2616 func_require_configure_ac ()
2618 $debug_cmd
2620 test -z "$configure_ac" \
2621 && func_autoconf_configure configure.ac && configure_ac=configure.ac
2622 test -z "$configure_ac" \
2623 && func_autoconf_configure configure.in && configure_ac=configure.in
2624 test -z "$configure_ac" \
2625 || func_verbose "found '$configure_ac'"
2627 require_configure_ac=:
2631 # require_gnu_m4
2632 # --------------
2633 # Search for GNU M4, and export it in $M4.
2634 require_gnu_m4=func_require_gnu_m4
2635 func_require_gnu_m4 ()
2637 $debug_cmd
2639 test -n "$M4" || {
2640 # Find the first m4 binary that responds to --version.
2641 func_find_tool M4 gm4 gnum4 m4
2644 test -n "$M4" || func_fatal_error "\
2645 Please install GNU M4, or 'export M4=/path/to/gnu/m4'."
2647 func_verbose "export M4='$M4'"
2649 # Make sure the search result is visible to subshells
2650 export M4
2652 require_gnu_m4=:
2656 ## --------------- ##
2657 ## Core functions. ##
2658 ## --------------- ##
2660 # This section contains the high level functions used when calling this
2661 # file as a script. 'func_extract_trace' is probably the only one that you
2662 # won't want to replace if you source this file into your own script.
2665 # func_extract_trace MACRO_NAMES [FILENAME]...
2666 # --------------------------------------------
2667 # set '$func_extract_trace_result' to a colon delimited list of arguments
2668 # to any of the comma separated list of MACRO_NAMES in FILENAME. If no
2669 # FILENAME is given, then '$configure_ac' is assumed.
2670 func_extract_trace ()
2672 $debug_cmd
2674 $require_configure_ac
2675 $require_gnu_m4
2677 _G_m4_traces=`$ECHO "--trace=$1" |$SED 's%,% --trace=%g'`
2678 _G_re_macros=`$ECHO "($1)" |$SED 's%,%|%g'`
2679 _G_macros="$1"; shift
2680 test $# -gt 0 || {
2681 set dummy $configure_ac
2682 shift
2685 # Generate an error if the first file is missing
2686 <"$1"
2688 # Sadly, we can't use 'autom4te' tracing to extract macro arguments,
2689 # because it complains about things we want to ignore at bootstrap
2690 # time - like missing m4_include files; AC_PREREQ being newer than
2691 # the installed autoconf; and returns nothing when tracing
2692 # 'AM_INIT_AUTOMAKE' when aclocal hasn't been generated yet.
2694 # The following tries to emulate a less persnickety version of (and
2695 # due to not having to wait for Perl startup on every invocation,
2696 # it's probably faster too):
2698 # autom4te --language=Autoconf --trace=$my_macro:\$% "$@"
2700 # First we give a minimal set of macro declarations to M4 to prime
2701 # it for reading Autoconf macros, while still providing some of the
2702 # functionality generally used at m4-time to supply dynamic
2703 # arguments to Autocof functions, but without following
2704 # 'm4_s?include' files.
2705 _G_mini='
2706 dnl Initialisation.
2707 m4_changequote([,])
2708 m4_define([m4_copy], [m4_define([$2], m4_defn([$1]))])
2709 m4_define([m4_rename], [m4_copy([$1], [$2])m4_undefine([$1])])
2711 dnl Replace macros which may abort m4 with a no-op variant.
2712 m4_pushdef([m4_assert])
2713 m4_pushdef([m4_exit])
2714 m4_pushdef([m4_fatal])
2715 m4_pushdef([m4_m4exit])
2717 dnl Replace macros that might break stderr of m4.
2718 m4_pushdef([m4_errprint])
2719 m4_pushdef([m4_errprintn])
2720 m4_pushdef([m4_include])
2721 m4_pushdef([m4_warn])
2723 dnl Avoid side-effects of tracing by extract-trace.
2724 m4_pushdef([m4_maketemp])
2725 m4_pushdef([m4_mkstemp])
2727 dnl TODO: reasons for this
2728 m4_pushdef([m4_dnl])
2729 m4_pushdef([m4_m4wrap])
2731 dnl Copy and rename macros not handled by "m4 --prefix".
2732 m4_define([dnl], [m4_builtin([dnl])])
2733 m4_copy([m4_define], [m4_defun])
2734 m4_rename([m4_ifelse], [m4_if])
2735 m4_rename([m4_patsubst], [m4_bpatsubst])
2736 m4_rename([m4_regexp], [m4_bregexp])
2738 dnl "m4sugar.mini" - useful m4-time macros for dynamic arguments.
2739 dnl If we discover packages that need more m4 macros defined in
2740 dnl order to bootstrap correctly, add them here:
2741 m4_define([m4_bmatch],
2742 [m4_if([$#], 0, [], [$#], 1, [], [$#], 2, [$2],
2743 [m4_if(m4_bregexp([$1], [$2]), -1,
2744 [$0([$1], m4_shift3($@))], [$3])])])
2745 m4_define([m4_ifndef], [m4_ifdef([$1], [$3], [$2])])
2746 m4_define([m4_ifset],
2747 [m4_ifdef([$1], [m4_ifval(m4_defn([$1]), [$2], [$3])], [$3])])
2748 m4_define([m4_require], [$1])
2749 m4_define([m4_shift3], [m4_shift(m4shift(m4shift($@)))])
2751 dnl "autoconf.mini" - things from autoconf macros we care about.
2752 m4_copy([m4_defun], [AC_DEFUN])
2754 dnl Dummy definitions for the macros we want to trace.
2755 dnl AM_INIT_AUTOMAKE at least produces no trace without this.
2758 _G_save=$IFS
2759 IFS=,
2760 for _G_macro in $_G_macros; do
2761 IFS=$_G_save
2762 func_append _G_mini "AC_DEFUN([$_G_macro])$nl"
2763 done
2764 IFS=$_G_save
2766 # We discard M4's stdout, but the M4 trace output from reading our
2767 # "autoconf.mini" followed by any other files passed to this
2768 # function is then scanned by sed to transform it into a colon
2769 # delimited argument list assigned to a shell variable.
2770 _G_transform='s|#.*$||; s|^dnl .*$||; s| dnl .*$||;'
2772 # Unfortunately, alternation in regexp addresses doesn't work in at
2773 # least BSD (and hence Mac OS X) sed, so we have to append a capture
2774 # and print block for each traced macro to the sed transform script.
2775 _G_save=$IFS
2776 IFS=,
2777 for _G_macro in $_G_macros; do
2778 IFS=$_G_save
2779 func_append _G_transform '
2780 /^m4trace: -1- '"$_G_macro"'/ {
2781 s|^m4trace: -1- '"$_G_macro"'[([]*||
2782 s|], [[]|:|g
2783 s|[])]*$|:|
2784 s|\(.\):$|\1|
2787 done
2788 IFS=$_G_save
2790 # Save the command pipeline results for further use by callers of
2791 # this function.
2792 func_extract_trace_result=`$ECHO "$_G_mini" \
2793 |$M4 -daq --prefix $_G_m4_traces - "$@" 2>&1 1>/dev/null \
2794 |$SED -n -e "$_G_transform"`
2798 # func_extract_trace_first MACRO_NAMES [FILENAME]...
2799 # --------------------------------------------------
2800 # Exactly like func_extract_trace, except that only the first argument
2801 # to the first invocation of one of the comma separated MACRO_NAMES is
2802 # returned in '$func_extract_trace_first_result'.
2803 func_extract_trace_first ()
2805 $debug_cmd
2807 func_extract_trace ${1+"$@"}
2808 func_extract_trace_first_result=`$ECHO "$func_extract_trace_result" \
2809 |$SED -e 's|:.*$||g' -e 1q`
2813 # func_main [ARG]...
2814 # ------------------
2815 func_main ()
2817 $debug_cmd
2819 # Configuration.
2820 usage='$progname MACRO_NAME FILE [...]'
2822 long_help_message='
2823 The first argument to this program is the name of an autotools macro
2824 whose arguments you want to extract by examining the files listed in the
2825 remaining arguments using the same tool that Autoconf and Automake use,
2826 GNU M4.
2828 The arguments are returned separated by colons, with each traced call
2829 on a separate line.'
2831 # Option processing.
2832 func_options "$@"
2833 eval set dummy "$func_options_result"; shift
2835 # Validate remaining non-option arguments.
2836 test $# -gt 1 \
2837 || func_fatal_help "not enough arguments"
2839 # Pass non-option arguments to extraction function.
2840 func_extract_trace "$@"
2842 # Display results.
2843 test -n "$func_extract_trace_result" \
2844 && $ECHO "$func_extract_trace_result"
2846 # The End.
2847 exit $EXIT_SUCCESS
2851 ## --------------------------- ##
2852 ## Actually perform the trace. ##
2853 ## --------------------------- ##
2855 # Only call 'func_main' if this script was called directly.
2856 test extract-trace = "$progname" && func_main "$@"
2858 # Local variables:
2859 # mode: shell-script
2860 # sh-indentation: 2
2861 # eval: (add-hook 'before-save-hook 'time-stamp)
2862 # time-stamp-pattern: "50/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2863 # time-stamp-time-zone: "UTC"
2864 # End:
2866 # Set a version string for *this* script.
2867 scriptversion=2019-03-22.11; # UTC
2870 ## ------------------- ##
2871 ## Hookable functions. ##
2872 ## ------------------- ##
2874 # After 'bootstrap.conf' has been sourced, execution proceeds by calling
2875 # 'func_bootstrap'. Wherever a function is decorated with
2876 # 'func_hookable func_name', you will find a matching 'func_run_hooks
2877 # func_name', which executes all functions added with 'func_add_hook
2878 # func_name my_func'.
2880 # You might notice that many of these functions begin with a series of
2881 # '$require_foo' lines. See the docu-comments at the start of the
2882 # 'Resource management' section for a description of what these are.
2885 # func_bootstrap [ARG]...
2886 # -----------------------
2887 # All the functions called inside func_bootstrap are hookable. See the
2888 # the individual implementations for details.
2889 func_bootstrap ()
2891 $debug_cmd
2893 # Save the current positional parameters to prevent them being
2894 # corrupted by calls to 'set' in 'func_init'.
2895 func_quote eval ${1+"$@"}
2896 _G_saved_positional_parameters=$func_quote_result
2898 # Initialisation.
2899 func_init
2901 # Option processing.
2902 eval func_options "$_G_saved_positional_parameters"
2904 # Post-option preparation.
2905 func_prep
2907 # Reconfigure the package.
2908 func_reconfigure
2910 # Ensure .version is up-to-date.
2911 func_update_dotversion
2913 # Finalisation.
2914 func_fini
2918 # func_init
2919 # ---------
2920 # Any early initialisations can be hooked to this function. Consider
2921 # whether you can hook onto 'func_prep' instead, because if you hook
2922 # any slow to execute code in here, it will also add to the time before
2923 # './bootstrap --version' can respond.
2924 func_hookable func_init
2925 func_init ()
2927 $debug_cmd
2929 func_run_hooks func_init
2933 # func_prep
2934 # ---------
2935 # Function to perform preparation for remaining bootstrap process. If
2936 # your hooked code relies on the outcome of 'func_options' hook it here
2937 # rather than to 'func_init'.
2939 # All the functions called inside func_prep are hookable. See the
2940 # individual implementations for details.
2941 func_hookable func_prep
2942 func_prep ()
2944 $debug_cmd
2946 $require_buildtools_uptodate
2947 $require_checkout_only_file
2949 $require_gnulib_merge_changelog
2951 # Report the results of SED and GREP searches from funclib.sh.
2952 func_verbose "GREP='$GREP'"
2953 func_verbose "SED='$SED'"
2955 # fetch update files from the translation project
2956 func_update_translations
2958 func_run_hooks func_prep
2962 # func_update_translations
2963 # ------------------------
2964 # Update package po files and translations.
2965 func_hookable func_update_translations
2966 func_update_translations ()
2968 $debug_cmd
2970 $opt_skip_po || {
2971 test -d po && {
2972 $require_package
2974 func_update_po_files po $package || exit $?
2977 func_run_hooks func_update_translations
2982 # func_reconfigure
2983 # ----------------
2984 # Reconfigure the current package by running the appropriate autotools in a
2985 # suitable order.
2986 func_hookable func_reconfigure
2987 func_reconfigure ()
2989 $debug_cmd
2991 $require_automake_options
2993 # Automake (without 'foreign' option) requires that NEWS & README exist.
2994 case " $automake_options " in
2995 " foreign ") ;;
2997 func_ensure_NEWS
2998 func_ensure_README
3000 esac
3002 # Ensure ChangeLog presence.
3003 if test -n "$gnulib_modules"; then
3004 func_ifcontains "$gnulib_modules" gitlog-to-changelog \
3005 func_ensure_changelog
3006 else
3007 $require_gnulib_cache
3008 if $SED -n '/^gl_MODULES(\[/,/^])$/p' $gnulib_cache 2>/dev/null |
3009 func_grep_q gitlog-to-changelog
3010 then
3011 func_ensure_changelog
3015 # Released 'autopoint' has the tendency to install macros that have
3016 # been obsoleted in current 'gnulib', so run this before 'gnulib-tool'.
3017 func_autopoint
3019 # Autoreconf runs 'aclocal' before 'libtoolize', which causes spurious
3020 # warnings if the initial 'aclocal' is confused by the libtoolized
3021 # (or worse: out-of-date) macro directory.
3022 func_libtoolize
3024 # If you need to do anything after 'gnulib-tool' is done, but before
3025 # 'autoreconf' runs, you don't need to override this whole function,
3026 # because 'func_gnulib_tool' is hookable.
3027 func_gnulib_tool
3029 func_autoreconf
3031 func_run_hooks func_reconfigure
3035 # func_gnulib_tool
3036 # ----------------
3037 # Run 'gnulib-tool' to fetch gnulib modules into the current package.
3039 # It's assumed that since you are using gnulib's 'bootstrap' script,
3040 # you're also using gnulib elsewhere in your package. If not, then
3041 # you can replace this function in 'bootstrap.conf' with:
3043 # func_gnulib_tool () { :; }
3045 # (although the function returns immediately if $gnulib_tool is set to
3046 # true in any case).
3047 func_hookable func_gnulib_tool
3048 func_gnulib_tool ()
3050 $debug_cmd
3052 $require_gnulib_tool
3053 $require_libtoolize
3055 test true = "$gnulib_tool" || {
3056 $require_gnulib_git_submodules
3058 # bootstrap.conf written for gnulib bootstrap expects
3059 # gnulib_tool_option_extras to which --no-changelog is appended,
3060 # but libtool bootstrap expects you to append to gnulib_tool_options
3061 # so that you can override the --no-changelog default: make sure we
3062 # support both styles so users can migrate between them easily.
3063 gnulib_tool_all_options="$gnulib_tool_options $gnulib_tool_option_extras"
3065 if test -n "$gnulib_modules"; then
3066 $require_gnulib_cache
3067 $require_gnulib_tool_base_options
3069 gnulib_mode=--import
3071 # Try not to pick up any stale values from 'gnulib-cache.m4'.
3072 rm -f "$gnulib_cache"
3074 test -n "$gnulib_tool_base_options" \
3075 && func_append_uniq gnulib_tool_all_options " $gnulib_tool_base_options"
3076 test -n "$gnulib_mk" \
3077 && func_append_uniq gnulib_tool_all_options " --makefile-name=$gnulib_mk"
3078 test -n "$tests_base" && {
3079 func_append_uniq gnulib_tool_all_options " --tests-base=$tests_base"
3080 func_append_uniq gnulib_tool_all_options " --with-tests"
3082 else
3084 # 'gnulib_modules' and others are cached in 'gnulib-cache.m4':
3085 # Use 'gnulib --update' to fetch gnulib modules.
3086 gnulib_mode=--update
3089 # Add a sensible default libtool option to gnulib_tool_options.
3090 # The embedded echo is to squash whitespace before globbing.
3091 case `echo " "$gnulib_tool_all_options" "` in
3092 *" --no-libtool "*|*" --libtool "*) ;;
3093 *) if test true = "$LIBTOOLIZE"; then
3094 func_append_uniq gnulib_tool_all_options " --no-libtool"
3095 else
3096 func_append_uniq gnulib_tool_all_options " --libtool"
3099 esac
3101 $opt_copy || func_append_uniq gnulib_tool_all_options " --symlink"
3103 func_append_uniq gnulib_tool_all_options " $gnulib_mode"
3104 func_append gnulib_tool_all_options " $gnulib_modules"
3106 # The embedded echo is to squash whitespace before display.
3107 gnulib_cmd=`echo $gnulib_tool $gnulib_tool_all_options`
3109 func_show_eval "$gnulib_cmd" 'exit $?'
3111 # Use 'gnulib-tool --copy-file' to install non-module files.
3112 func_install_gnulib_non_module_files
3115 func_run_hooks func_gnulib_tool
3119 # func_fini
3120 # ---------
3121 # Function to perform all finalisation for the bootstrap process.
3122 func_hookable func_fini
3123 func_fini ()
3125 $debug_cmd
3127 func_gettext_configuration
3128 func_clean_dangling_symlinks
3129 func_clean_unused_macros
3130 func_skip_po_recommendation
3132 func_run_hooks func_fini
3134 $require_bootstrap_uptodate
3136 func_echo "Done. Now you can run './configure'."
3140 # func_gettext_configuration
3141 # --------------------------
3142 # Edit configuration values into po/Makevars.
3143 func_hookable func_gettext_configuration
3144 func_gettext_configuration ()
3146 $debug_cmd
3148 $require_autopoint
3150 test true = "$AUTOPOINT" || {
3151 $require_copyright_holder
3152 $require_extra_locale_categories
3153 $require_package_bugreport
3155 # Escape xgettext options for sed Makevars generation below.
3156 # We have to delete blank lines in a separate script so that we don't
3157 # append \\\ to the penultimate line, and then delete the last empty
3158 # line, which messes up the variable substitution later in this
3159 # function. Note that adding a literal \\\ requires double escaping
3160 # here, once for the execution subshell, and again for the assignment,
3161 # which is why there are actually 12 (!!) backslashes in the script.
3162 _G_xgettext_options=`echo "$xgettext_options$nl" |$SED '/^$/d' |$SED '
3164 s|$| \\\\\\\\\\\\|'`
3166 # Create gettext configuration.
3167 func_echo "Creating po/Makevars from po/Makevars.template ..."
3168 $RM -f po/Makevars
3169 $SED '
3170 /^EXTRA_LOCALE_CATEGORIES *=/s|=.*|= '"$extra_locale_categories"'|
3171 /^COPYRIGHT_HOLDER *=/s|=.*|= '"$copyright_holder"'|
3172 /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$package_bugreport"'|
3173 /^XGETTEXT_OPTIONS *=/{
3174 s|$| \\|
3176 '"$_G_xgettext_options"' \\\
3177 $${end_of_xgettext_options+}
3179 s/ *$//
3180 ' po/Makevars.template >po/Makevars || exit 1
3183 func_run_hooks func_gettext_configuration
3188 ## --------------- ##
3189 ## Core functions. ##
3190 ## --------------- ##
3192 # This section contains the main functions called from the 'Hookable
3193 # functions' (shown above), and are the ones you're most likely
3194 # to want to replace with your own implementations in 'bootstrap.conf'.
3197 # func_autopoint
3198 # --------------
3199 # If this package uses gettext, then run 'autopoint'.
3200 func_autopoint ()
3202 $debug_cmd
3204 $require_autopoint
3206 test true = "$AUTOPOINT" \
3207 || func_show_eval "$AUTOPOINT --force" 'exit $?'
3211 # func_libtoolize
3212 # ---------------
3213 # If this package uses libtool, then run 'libtoolize'.
3214 func_libtoolize ()
3216 $debug_cmd
3218 $require_libtoolize
3220 test true = "$LIBTOOLIZE" || {
3221 _G_libtoolize_options=
3222 $opt_copy && func_append _G_libtoolize_options " --copy"
3223 $opt_force && func_append _G_libtoolize_options " --force"
3224 $opt_verbose || func_append _G_libtoolize_options " --quiet"
3225 func_show_eval "$LIBTOOLIZE$_G_libtoolize_options" 'exit $?'
3230 # func_gnulib_tool_copy_file SRC DEST
3231 # -----------------------------------
3232 # Copy SRC, a path relative to the gnulib sub-tree, to DEST, a path
3233 # relative to the top-level source directory using gnulib-tool so that
3234 # any patches or replacements in $local_gl_path are applied.
3235 func_gnulib_tool_copy_file ()
3237 $debug_cmd
3239 $require_gnulib_tool
3240 $require_patch
3242 if test true = "$gnulib_tool"; then
3243 # If gnulib-tool is not available (e.g. bootstrapping in a
3244 # distribution tarball), make sure that at least we have some
3245 # version of the required file already in place.
3246 test -f "$2" || func_fatal_error "\
3247 Can't find, copy or download '$2', a required
3248 gnulib supplied file, please provide the location of a
3249 complete 'gnulib' tree by setting 'gnulib_path' in your
3250 'bootstrap.conf' or with the '--gnulib-srcdir' option -
3251 or else specify the location of your 'git' binary by
3252 setting 'GIT' in the environment so that a fresh
3253 'gnulib' submodule can be cloned."
3254 else
3255 $require_gnulib_copy_cmd
3257 $gnulib_copy_cmd $1 $2 2>/dev/null || {
3258 $require_gnulib_path
3260 func_error "'$gnulib_path/$1' does not exist"
3261 return 1
3267 # func_install_gnulib_non_module_files
3268 # ------------------------------------
3269 # Get additional non-module files from gnulib, overriding existing files.
3270 func_install_gnulib_non_module_files ()
3272 $debug_cmd
3274 $require_build_aux
3275 $require_gnulib_tool
3277 test -n "$gnulib_non_module_files" && {
3278 maybe_exit_cmd=:
3280 for file in $gnulib_non_module_files; do
3281 case $file in
3282 */COPYING*) dest=COPYING;;
3283 */INSTALL) dest=INSTALL;;
3284 build-aux/missing) dest=
3285 func_warning settings "\
3286 Please remove build-aux/missing from gnulib_module_files in
3287 'bootstrap.conf', as it may clash with Automake's version."
3289 build-aux/*) dest=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
3290 *) dest=$file;;
3291 esac
3293 # Be sure to show all copying errors before bailing out
3294 test -z "$dest" \
3295 || func_gnulib_tool_copy_file "$file" "$dest" \
3296 || maybe_exit_cmd="exit $EXIT_FAILURE"
3297 done
3299 $maybe_exit_cmd
3304 # func_ensure_changelog
3305 # ---------------------
3306 # Even with 'gitlog-to-changelog' generated ChangeLogs, automake
3307 # will not run to completion with no ChangeLog file.
3308 func_ensure_changelog ()
3310 $debug_cmd
3312 test -f ChangeLog && mv -f ChangeLog ChangeLog~
3314 cat >ChangeLog <<'EOT'
3315 ## ---------------------- ##
3316 ## DO NOT EDIT THIS FILE! ##
3317 ## ---------------------- ##
3319 ChangeLog is generated by gitlog-to-changelog.
3322 _G_message="creating dummy 'ChangeLog'"
3323 test -f ChangeLog~ \
3324 && func_append _G_message ' (backup in ChangeLog~)'
3325 func_verbose "$_G_message"
3327 return 0
3331 # func_ensure_NEWS
3332 # ----------------
3333 # Without AM_INIT_AUTOMAKE([foreign]), automake will not run to
3334 # completion with no NEWS file, even though NEWS.md or NEWS.txt
3335 # is often preferable.
3336 func_ensure_NEWS ()
3338 $debug_cmd
3340 test -f NEWS || {
3341 _G_NEWS=
3342 for _G_news in NEWS.txt NEWS.md NEWS.rst; do
3343 test -f "$_G_news" && break
3344 done
3346 test -f "$_G_news" && $LN_S $_G_news NEWS
3347 func_verbose "$LN_S $_G_news NEWS"
3350 return 0
3354 # func_ensure_README
3355 # ------------------
3356 # Without AM_INIT_AUTOMAKE([foreign]), automake will not run to
3357 # completion with no README file, even though README.md or README.txt
3358 # is often preferable.
3359 func_ensure_README ()
3361 $debug_cmd
3363 test -f README || {
3364 _G_README=
3365 for _G_readme in README.txt README.md README.rst; do
3366 test -f "$_G_readme" && break
3367 done
3369 test -f "$_G_readme" && $LN_S $_G_readme README
3370 func_verbose "$LN_S $_G_readme README"
3373 return 0
3377 # func_autoreconf [SUBDIR]
3378 # ------------------------
3379 # Being careful not to re-run 'autopoint' or 'libtoolize', and not to
3380 # try to run 'autopoint', 'libtoolize' or 'autoheader' on packages that
3381 # don't use them, defer to 'autoreconf' for execution of the remaining
3382 # autotools to bootstrap this package.
3384 # Projects with multiple trees to reconfigure can hook another call to
3385 # this function onto func_reconfigure:
3387 # my_autoreconf_foo ()
3389 # func_autoreconf foo
3391 # func_add_hook func_reconfigure my_autoreconf_foo
3392 func_autoreconf ()
3394 $debug_cmd
3396 $require_autoheader
3397 $require_build_aux # automake and others put files in here
3398 $require_macro_dir # aclocal and others put files in here
3400 # We ran these manually already, and autoreconf won't exec ':'
3401 save_AUTOPOINT=$AUTOPOINT; AUTOPOINT=true
3402 save_LIBTOOLIZE=$LIBTOOLIZE; LIBTOOLIZE=true
3404 _G_autoreconf_options=
3405 $opt_copy || func_append _G_autoreconf_options " --symlink"
3406 $opt_force && func_append _G_autoreconf_options " --force"
3407 $opt_verbose && func_append _G_autoreconf_options " --verbose"
3408 func_show_eval "$AUTORECONF$_G_autoreconf_options --install${1+ $1}" 'exit $?'
3410 AUTOPOINT=$save_AUTOPOINT
3411 LIBTOOLIZE=$save_LIBTOOLIZE
3415 # func_check_configuration VARNAME [CONFIGURE_MACRO]
3416 # --------------------------------------------------
3417 # Exit with a suitable diagnostic for an important configuration change
3418 # that needs to be made before bootstrap can run correctly.
3419 func_check_configuration ()
3421 $debug_cmd
3423 $require_configure_ac
3425 eval 'test -n "$'$1'"' || {
3426 _G_error_msg="please set '$1' in 'bootstrap.conf'"
3427 if test -n "$configure_ac" && test -n "$2"; then
3428 func_append _G_error_msg "
3429 or add the following (or similar) to your '$configure_ac':
3433 func_fatal_error "$_G_error_msg"
3438 # func_clean_dangling_symlinks
3439 # ----------------------------
3440 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
3441 # gnulib-populated directories. Such .m4 files would cause aclocal to
3442 # fail. The following requires GNU find 4.2.3 or newer. Considering
3443 # the usual portability constraints of this script, that may seem a very
3444 # demanding requirement, but it should be ok. Ignore any failure,
3445 # which is fine, since this is only a convenience to help developers
3446 # avoid the relatively unusual case where a symlinked-to .m4 file is
3447 # git-removed from gnulib between successive runs of this script.
3448 func_clean_dangling_symlinks ()
3450 $debug_cmd
3452 $require_macro_dir
3453 $require_source_base
3455 func_verbose "cleaning dangling symlinks"
3457 find "$macro_dir" "$source_base" \
3458 -depth \( -name '*.m4' -o -name '*.[ch]' \) \
3459 -type l -xtype l -delete > /dev/null 2>&1
3463 # func_clean_unused_macros
3464 # ------------------------
3465 # Autopoint can result in over-zealously adding macros into $macro_dir
3466 # even though they are not actually used, for example tests to help
3467 # build the 'intl' directory even though you have specified
3468 # 'AM_GNU_GETTEXT([external])' in your configure.ac. This function
3469 # looks removes any macro files that can be found in gnulib, but
3470 # are not 'm4_include'd by 'aclocal.m4'.
3471 func_clean_unused_macros ()
3473 $debug_cmd
3475 $require_gnulib_path
3476 $require_macro_dir
3478 test -n "$gnulib_path" && test -f aclocal.m4 && {
3479 aclocal_m4s=`find . -name aclocal.m4 -print`
3481 # We use 'ls|grep' instead of 'ls *.m4' to avoid exceeding
3482 # command line length limits in some shells.
3483 for file in `cd "$macro_dir" && ls -1 |$GREP '\.m4$'`; do
3485 # Remove a macro file when aclocal.m4 does not m4_include it...
3486 func_grep_q 'm4_include([[]'$macro_dir/$file'])' $aclocal_m4s \
3487 || test ! -f "$gnulib_path/m4/$file" || {
3489 # ...and there is an identical file in gnulib...
3490 if func_cmp_s "$gnulib_path/m4/$file" "$macro_dir/$file"; then
3492 # ...and it's not in the precious list ('echo' is needed
3493 # here to squash whitespace for the match expression).
3494 case " "`echo $gnulib_precious`" " in
3495 *" $file "*) ;;
3496 *) rm -f "$macro_dir/$file"
3497 func_verbose \
3498 "removing unused gnulib file '$macro_dir/$file'"
3499 esac
3502 done
3507 # func_skip_po_recommendation
3508 # ---------------------------
3509 # If there is a po directory, and '--skip-po' wasn't passed, let the
3510 # user know that they can use '--skip-po' on subsequent invocations.
3511 func_skip_po_recommendation ()
3513 $debug_cmd
3515 test ! -d po \
3516 || $opt_skip_po \
3517 || func_warning recommend "\
3518 If your pofiles are up-to-date, you can rerun bootstrap
3519 as '$progname --skip-po' to avoid redownloading."
3523 # func_update_dotversion
3524 # ----------------------
3525 # Even with 'gitlog-to-changelog' generated ChangeLogs, automake
3526 # will not run to completion with no ChangeLog file.
3527 func_update_dotversion ()
3529 $debug_cmd
3531 test -f "$build_aux/git-version-gen" && {
3532 _G_message="updating .version"
3533 test -f .version && {
3534 mv .version .version~
3535 func_append _G_message " (backup in .version~)"
3537 func_verbose "updating .version"
3539 $build_aux/git-version-gen dummy-arg > .version
3545 ## -------------------- ##
3546 ## Resource management. ##
3547 ## -------------------- ##
3549 # This section contains definitions for functions that each ensure a
3550 # particular resource (a file, or a non-empty configuration variable for
3551 # example) is available, and if appropriate to extract default values
3552 # from pertinent package files. Where a variable already has a non-
3553 # empty value (as set by the package's 'bootstrap.conf'), that value is
3554 # used in preference to deriving the default. Call them using their
3555 # associated 'require_*' variable to ensure that they are executed, at
3556 # most, once.
3559 # require_gnulib_git_submodules
3560 # -----------------------------
3561 # Initialize all git modules from $gnulib_git_submodules before we
3562 # run 'gnulib-tool'.
3563 require_gnulib_git_submodules=func_require_gnulib_git_submodules
3564 func_require_gnulib_git_submodules ()
3566 test -n "$gnulib_git_submodules" && {
3567 for _G_submodule in $gnulib_git_submodules
3569 func_show_eval "git submodule init -- $_G_submodule" \
3570 && func_show_eval "git submodule update -- $_G_submodule" \
3571 || func_fatal_error "Unable to init git module '$_G_submodule'."
3572 done
3575 require_gnulib_git_submodules=:
3579 # require_checkout_only_file
3580 # --------------------------
3581 # Bail out if this package only bootstraps properly from a repository
3582 # checkout.
3583 require_checkout_only_file=func_require_checkout_only_file
3584 func_require_checkout_only_file ()
3586 $debug_cmd
3588 $opt_force || {
3589 test -n "$checkout_only_file" && test ! -f "$checkout_only_file" \
3590 && func_fatal_error "\
3591 Bootstrapping from a non-checked-out distribution is risky.
3592 If you wish to bootstrap anyway, use the '--force' option."
3595 require_checkout_only_file=:
3599 # require_aclocal_amflags
3600 # -----------------------
3601 # Ensure '$aclocal_amflags' has a sensible default, extracted from
3602 # 'Makefile.am' if necessary.
3603 require_aclocal_amflags=func_require_aclocal_amflags
3604 func_require_aclocal_amflags ()
3606 $debug_cmd
3608 $require_makefile_am
3610 _G_sed_extract_aclocal_amflags='s|#.*$||
3611 /^[ ]*ACLOCAL_AMFLAGS[ ]*=/ {
3612 s|^.*=[ ]*\(.*\)|aclocal_amflags="\1"|
3616 _G_aclocal_flags_cmd=`$SED -n "$_G_sed_extract_aclocal_amflags" \
3617 "$makefile_am"`
3618 eval "$_G_aclocal_flags_cmd"
3620 func_verbose "ACLOCAL_AMFLAGS='$aclocal_amflags'"
3622 require_aclocal_amflags=:
3626 # require_autoheader
3627 # ------------------
3628 # Skip autoheader if it's not needed.
3629 require_autoheader=func_require_autoheader
3630 func_require_autoheader ()
3632 $debug_cmd
3634 test true = "$AUTOHEADER" || {
3635 func_extract_trace AC_CONFIG_HEADERS
3636 test -n "$func_extract_trace_result" \
3637 || func_extract_trace AC_CONFIG_HEADER
3639 test -n "$func_extract_trace_result" || {
3640 AUTOHEADER=true
3642 func_verbose "export AUTOHEADER='$AUTOHEADER'"
3644 # Make sure the search result is visible to subshells
3645 export AUTOHEADER
3649 require_autoheader=:
3653 # require_automake_options
3654 # ------------------------
3655 # Extract options from AM_AUTOMAKE_INIT.
3656 require_automake_options=func_require_automake_options
3657 func_require_automake_options ()
3659 $debug_cmd
3661 func_extract_trace AM_INIT_AUTOMAKE
3662 automake_options=$func_extract_trace_result
3664 require_automake_options=:
3668 # require_autopoint
3669 # -----------------
3670 # Skip autopoint if it's not needed.
3671 require_autopoint=func_require_autopoint
3672 func_require_autopoint ()
3674 $debug_cmd
3676 test true = "$AUTOPOINT" || {
3677 func_extract_trace AM_GNU_GETTEXT_VERSION
3679 test -n "$func_extract_trace_result" || {
3680 AUTOPOINT=true
3682 func_verbose "export AUTOPOINT='$AUTOPOINT'"
3684 # Make sure the search result is visible to subshells
3685 export AUTOPOINT
3689 require_autopoint=:
3693 # require_bootstrap_uptodate
3694 # --------------------------
3695 # Complain if the version of bootstrap in the gnulib directory differs
3696 # from the one we are running.
3697 require_bootstrap_uptodate=func_require_bootstrap_uptodate
3698 func_require_bootstrap_uptodate ()
3700 $debug_cmd
3702 $require_build_aux
3704 _G_bootstrap_sources="
3705 $build_aux/bootstrap.in
3706 $build_aux/extract-trace
3707 $build_aux/funclib.sh
3708 $build_aux/options-parser
3711 _G_missing_bootstrap_sources=false
3712 for _G_src in $_G_bootstrap_sources; do
3713 test -f "$_G_src" || _G_missing_bootstrap_sources=:
3714 done
3716 if $_G_missing_bootstrap_sources; then
3717 func_warning upgrade "\
3718 Please add bootstrap to your gnulib_modules list in
3719 'bootstrap.conf', so that I can tell you when there are
3720 updates available."
3721 else
3722 rm -f bootstrap.new
3723 $build_aux/inline-source $build_aux/bootstrap.in > bootstrap.new
3725 if func_cmp_s "$progpath" bootstrap.new; then
3726 rm -f bootstrap.new
3727 func_verbose "bootstrap script up to date"
3728 else
3729 chmod 555 bootstrap.new
3730 func_warning upgrade "\
3731 An updated bootstrap script has been generated for you in
3732 'bootstrap.new'. After you've verified that you want
3733 the changes, you can update with:
3734 mv -f bootstrap.new $progname
3735 ./$progname
3737 Or you can disable this check permanently by adding the
3738 following to 'bootstrap.conf':
3739 require_bootstrap_uptodate=:"
3743 require_bootstrap_uptodate=:
3747 # require_build_aux
3748 # -----------------
3749 # Ensure that '$build_aux' is set, and if it doesn't already point to an
3750 # existing directory, create one.
3751 require_build_aux=func_require_build_aux
3752 func_require_build_aux ()
3754 $debug_cmd
3756 test -n "$build_aux" || {
3757 func_extract_trace_first AC_CONFIG_AUX_DIR
3758 build_aux=$func_extract_trace_first_result
3759 func_check_configuration build_aux \
3760 "AC_CONFIG_AUX_DIR([name of a directory for build scripts])"
3762 func_verbose "build_aux='$build_aux'"
3765 $require_vc_ignore_files
3767 # If the build_aux directory doesn't exist, create it now, and mark it
3768 # as ignored for the VCS.
3769 if test ! -d "$build_aux"; then
3770 func_show_eval "mkdir '$build_aux'"
3772 test -n "$vc_ignore_files" \
3773 || func_insert_if_absent "$build_aux" $vc_ignore_files
3776 require_build_aux=:
3780 # require_buildreq_autobuild
3781 # --------------------------
3782 # Try to find whether the bootstrap requires autobuild.
3783 require_buildreq_autobuild=func_require_buildreq_autobuild
3784 func_require_buildreq_autobuild ()
3786 $debug_cmd
3788 $require_macro_dir
3790 test -f "$macro_dir/autobuild.m4" \
3791 || printf '%s\n' "$buildreq" |func_grep_q '^[ ]*autobuild' \
3792 || {
3793 func_extract_trace AB_INIT
3794 test -n "$func_extract_trace_result" && {
3795 func_append buildreq 'autobuild - http://josefsson.org/autobuild/
3797 func_verbose "auto-adding 'autobuild' to build requirements"
3801 require_buildreq_autobuild=:
3805 # require_buildreq_autoconf
3806 # require_buildreq_autopoint
3807 # require_buildreq_libtoolize
3808 # ---------------------------
3809 # Try to find the minimum compatible version of autoconf/libtool
3810 # required to bootstrap successfully, and add it to '$buildreq'.
3811 for tool in autoconf libtoolize autopoint; do
3812 b=$tool
3813 v=require_buildreq_${tool}
3814 f=func_$v
3815 case $tool in
3816 autoconf) m=AC_PREREQ ;;
3817 libtoolize) m=LT_PREREQ; b=libtool ;;
3818 autopoint) m=AM_GNU_GETTEXT_VERSION b=gettext ;;
3819 esac
3821 eval $v'='$f'
3822 '$f' ()
3824 $debug_cmd
3826 # The following is ignored if undefined, but might be necessary
3827 # in order for `func_find_tool` to run.
3828 ${require_'$tool'-:}
3830 printf '\''%s\n'\'' "$buildreq" |func_grep_q '\''^[ ]*'$tool\'' || {
3831 func_extract_trace '$m'
3832 _G_version=$func_extract_trace_result
3833 test -n "$_G_version" && {
3834 func_append buildreq "\
3835 '$tool' $_G_version https://www.gnu.org/s/'$b'
3837 func_verbose \
3838 "auto-adding '\'$tool'-$_G_version'\'' to build requirements"
3842 '$v'=:
3845 done
3848 # require_buildreq_automake
3849 # -------------------------
3850 # Try to find the minimum compatible version of automake required to
3851 # bootstrap successfully, and add it to '$buildreq'.
3852 require_buildreq_automake=func_require_buildreq_automake
3853 func_require_buildreq_automake ()
3855 $debug_cmd
3857 # if automake is not already listed in $buildreq...
3858 printf '%s\n' "$buildreq" |func_grep_q automake || {
3859 func_extract_trace AM_INIT_AUTOMAKE
3861 # ...and AM_INIT_AUTOMAKE is declared...
3862 test -n "$func_extract_trace_result" && {
3863 automake_version=`$ECHO "$func_extract_trace_result" \
3864 |$SED -e 's|[^0-9]*||' -e 's| .*$||'`
3865 test -n "$automake_version" || automake_version=-
3867 func_append buildreq "\
3868 automake $automake_version https://www.gnu.org/s/automake
3870 func_verbose \
3871 "auto-adding 'automake-$automake_version' to build requirements"
3875 require_buildreq_automake=:
3879 # require_buildreq_patch
3880 # ----------------------
3881 # Automatically add a patch build-requirement if there are diff files
3882 # in $local_gl_path.
3883 require_buildreq_patch=func_require_buildreq_patch
3884 func_require_buildreq_patch ()
3886 $debug_cmd
3888 $require_local_gl_path
3890 # This ensures PATCH is set appropriately by the time
3891 # func_check_versions enforces $buildreq.
3892 $require_patch
3894 # If patch is not already listed in $buildreq...
3895 printf '%s\n' "$buildreq" |func_grep_q '^[ ]*patch' || {
3896 eval "set dummy $local_gl_path_quoted" ; shift
3898 for _G_dir
3900 # The ugly find invocation is necessary to exit with non-zero
3901 # status for old find binaries that don't support -exec fully.
3902 if test ! -d "$_G_dir" \
3903 || find "$_G_dir" -name "*.diff" -exec false {} \; ; then :
3904 else
3905 func_append buildreq "patch - https://www.gnu.org/s/patch$nl"
3906 break
3908 done
3911 require_buildreq_patch=:
3915 # require_buildtools_uptodate
3916 # ---------------------------
3917 # Ensure all the packages listed in BUILDREQS are available on the build
3918 # machine at the minimum versions or better.
3919 require_buildtools_uptodate=func_require_buildtools_uptodate
3920 func_require_buildtools_uptodate ()
3922 $debug_cmd
3924 $require_buildreq_autobuild
3925 $require_buildreq_autoconf
3926 $require_buildreq_automake
3927 $require_buildreq_libtoolize
3928 $require_buildreq_autopoint
3929 $require_buildreq_patch
3931 test -n "$buildreq" && {
3932 _G_error_hdr=
3934 func_check_versions $buildreq
3935 $func_check_versions_result || {
3936 test -n "$buildreq_readme" \
3937 && test -f "$buildreq_readme" \
3938 && _G_error_hdr="\
3939 $buildreq_readme explains how to obtain these prerequisite programs:
3941 func_strtable 0 11 12 36 \
3942 "Program" "Min_version" "Homepage" $buildreq
3943 func_fatal_error "$_G_error_hdr$func_strtable_result"
3947 require_buildtools_uptodate=:
3951 # require_copyright_holder
3952 # ------------------------
3953 # Ensure there is a sensible non-empty default value in '$copyright_holder'.
3954 require_copyright_holder=func_require_copyright_holder
3955 func_require_copyright_holder ()
3957 $debug_cmd
3959 test -n "$copyright_holder" || {
3960 copyright_holder='Free Software Foundation, Inc.'
3961 func_warning settings "\
3962 Please set copyright_holder explicitly in 'bootstrap.conf';
3963 defaulting to '$copyright_holder'."
3966 require_copyright_holder=:
3970 # require_doc_base
3971 # ----------------
3972 # Ensure doc_base has a sensible value, extracted from 'gnulib-cache.m4'
3973 # if possible, otherwise letting 'gnulib-tool' pick a default.
3974 require_doc_base=func_require_doc_base
3975 func_require_doc_base ()
3977 $debug_cmd
3979 $require_gnulib_cache
3981 test -f "$gnulib_cache" && test -z "$doc_base" && {
3982 func_extract_trace_first "gl_DOC_BASE" "$gnulib_cache"
3983 doc_base=$func_extract_trace_first_result
3985 test -n "$doc_base" && func_verbose "doc_base='$doc_base'"
3988 require_doc_base=:
3992 # require_dotgitmodules
3993 # ---------------------
3994 # Ensure we have a '.gitmodules' file, with appropriate 'gnulib' settings.
3995 require_dotgitmodules=func_require_dotgitmodules
3996 func_require_dotgitmodules ()
3998 $debug_cmd
4000 $require_git
4002 test true = "$GIT" || {
4003 # A gnulib entry in .gitmodules always takes precedence.
4004 _G_path=`$GIT config --file .gitmodules submodule.gnulib.path 2>/dev/null`
4006 test -n "$_G_path" || {
4007 $require_vc_ignore_files
4009 func_verbose "creating '.gitmodules'"
4011 # If the .gitmodules file doesn't exist, create it now, and mark
4012 # it as ignored for the VCS.
4013 test -n "$gnulib_path" || gnulib_path=gnulib
4014 test -n "$gnulib_url" || gnulib_url=git://git.sv.gnu.org/gnulib
4017 echo '[submodule "gnulib"]'
4018 echo " path = $gnulib_path"
4019 echo " url = $gnulib_url"
4020 } >> .gitmodules
4022 test -n "$vc_ignore_files" \
4023 || func_insert_if_absent ".gitmodules" $vc_ignore_files
4027 require_dotgitmodules=:
4031 # require_extra_locale_categories
4032 # -------------------------------
4033 # Ensure there is a default value in '$extra_locale_categories'
4034 require_extra_locale_categories=func_require_extra_locale_categories
4035 func_require_extra_locale_categories ()
4037 $debug_cmd
4039 # Defaults to empty, so run with whatever value may have been set in
4040 # 'bootstrap.conf'.
4041 require_extra_locale_categories=:
4045 # require_git
4046 # -----------
4047 # Ignore git if it's not available, or we're not in a git checkout tree.
4048 require_git=func_require_git
4049 func_require_git ()
4051 $debug_cmd
4053 $opt_skip_git && GIT=true
4055 test true = "$GIT" || {
4056 if test -d .git/.; then
4057 ($GIT --version) >/dev/null 2>&1 || GIT=true
4061 func_verbose "GIT='$GIT'"
4063 require_git=:
4067 # require_gnulib_cache
4068 # --------------------
4069 # Ensure there is a non-empty default for '$gnulib_cache', and that it
4070 # names an existing file.
4071 require_gnulib_cache=func_require_gnulib_cache
4072 func_require_gnulib_cache ()
4074 $debug_cmd
4076 $require_macro_dir
4078 test -n "$gnulib_cache" \
4079 || gnulib_cache=$macro_dir/gnulib-cache.m4
4081 func_verbose "found '$gnulib_cache'"
4083 require_gnulib_cache=:
4087 # require_gnulib_copy_cmd
4088 # -----------------------
4089 # Only calculate the options for copying files with gnulib once.
4090 require_gnulib_copy_cmd=func_require_gnulib_copy_cmd
4091 func_require_gnulib_copy_cmd ()
4093 $debug_cmd
4095 $require_gnulib_tool
4096 $require_gnulib_tool_base_options
4098 gnulib_copy_cmd="$gnulib_tool $gnulib_tool_base_options --copy-file"
4099 $opt_copy || func_append gnulib_copy_cmd " --symlink"
4100 $opt_quiet || func_append gnulib_copy_cmd " --verbose"
4102 require_gnulib_copy_cmd=:
4106 # require_gnulib_merge_changelog
4107 # ------------------------------
4108 # See if we can use gnulib's git-merge-changelog merge driver.
4109 require_gnulib_merge_changelog=func_require_gnulib_merge_changelog
4110 func_require_gnulib_merge_changelog ()
4112 $debug_cmd
4114 test -f ChangeLog && {
4115 $require_git
4117 func_grep_q '^\(/\|\)ChangeLog$' .gitignore || test true = "$GIT" || {
4118 if $GIT config merge.merge-changelog.driver >/dev/null; then
4120 elif (git-merge-changelog --version) >/dev/null 2>&1; then
4121 func_echo "initializing git-merge-changelog driver"
4122 $GIT config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
4123 $GIT config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
4124 else
4125 func_warning recommend \
4126 "Consider installing git-merge-changelog from gnulib."
4131 require_gnulib_merge_changelog=:
4135 # require_gnulib_mk
4136 # -----------------
4137 # Ensure gnulib_mk has a sensible value, extracted from 'gnulib-cache.m4'
4138 # if possible, otherwise letting 'gnulib-tool' pick a default.
4139 require_gnulib_mk=func_require_gnulib_mk
4140 func_require_gnulib_mk ()
4142 $debug_cmd
4144 $require_gnulib_cache
4146 test -f "$gnulib_cache" && test -z "$gnulib_mk" && {
4147 func_extract_trace_first "gl_MAKEFILE_NAME" "$gnulib_cache"
4148 gnulib_mk=$func_extract_trace_first_result
4150 test -n "$gnulib_mk" && func_verbose "gnulib_mk='$gnulib_mk'"
4153 require_gnulib_mk=:
4157 # require_gnulib_name
4158 # -------------------
4159 # Ensure gnulib_name has a sensible value, extracted from 'gnulib-cache.m4'
4160 # if possible, otherwise letting 'gnulib-tool' pick a default.
4161 require_gnulib_name=func_require_gnulib_name
4162 func_require_gnulib_name ()
4164 $debug_cmd
4166 $require_gnulib_cache
4168 test -f "$gnulib_cache" && test -z "$gnulib_name" && {
4169 func_extract_trace_first "gl_LIB" "$gnulib_cache"
4170 gnulib_name=$func_extract_trace_first_result
4172 test -n "$gnulib_name" && func_verbose "gnulib_name='$gnulib_name'"
4175 require_gnulib_name=:
4179 # require_gnulib_path
4180 # require_gnulib_url
4181 # -------------------
4182 # Ensure 'gnulib_path' and 'gnulib_url' are set.
4183 require_gnulib_path=func_require_dotgitmodules_parameters
4184 require_gnulib_url=func_require_dotgitmodules_parameters
4185 func_require_dotgitmodules_parameters ()
4187 $debug_cmd
4189 $require_git
4191 test true = "$GIT" && {
4192 # If we can't find git (or if the user specified '--skip-git'),
4193 # then use an existing gnulib directory specified with
4194 # '--gnulib-srcdir' if possible.
4195 test -n "$gnulib_path" \
4196 || test ! -x "$opt_gnulib_srcdir/gnulib-tool" \
4197 || gnulib_path=$opt_gnulib_srcdir
4201 $require_dotgitmodules
4203 test -f .gitmodules && {
4204 # Extract the parameters with sed, since git may be missing
4205 test -n "$gnulib_path" \
4206 || gnulib_path=`$SED -e '/^.submodule "gnulib".$/,${
4207 /[ ]*path *= */{
4208 s|[ ]*||g;s|^[^=]*=||;p
4211 d' .gitmodules |$SED 1q`
4212 test -n "$gnulib_url" \
4213 || gnulib_url=`$SED -e '/^.submodule "gnulib".$/,${
4214 /[ ]*url *= */{
4215 s|[ ]*||g;s|^[^=]*=||;p
4218 d' .gitmodules |$SED 1q`
4220 func_verbose "gnulib_path='$gnulib_path'"
4221 func_verbose "gnulib_url='$gnulib_url'"
4224 require_gnulib_path=:
4225 require_gnulib_url=:
4229 # require_gnulib_submodule
4230 # ------------------------
4231 # Ensure that there is a current gnulib submodule at '$gnulib_path'.
4232 require_gnulib_submodule=func_require_gnulib_submodule
4233 func_require_gnulib_submodule ()
4235 $debug_cmd
4237 $require_git
4239 if test true = "$GIT"; then
4240 func_warning recommend \
4241 "No 'git' found; imported gnulib modules may be outdated."
4242 else
4243 $require_gnulib_path
4244 $require_gnulib_url
4246 if test -f .gitmodules && test -f "$gnulib_path/gnulib-tool"; then
4247 : All present and correct.
4249 elif test -n "$opt_gnulib_srcdir"; then
4250 # Older git can't clone into an empty directory.
4251 rmdir "$gnulib_path" 2>/dev/null
4252 func_show_eval "$GIT clone --reference '$opt_gnulib_srcdir' \
4253 '$gnulib_url' '$gnulib_path'" \
4254 || func_fatal_error "Unable to fetch gnulib submodule."
4256 # Without --gnulib-srcdir, and no existing checked out submodule, we
4257 # create a new shallow clone of the remote gnulib repository.
4258 else
4259 trap func_cleanup_gnulib 1 2 13 15
4261 shallow=
4262 test -n "$gnulib_clone_since" && \
4263 $GIT clone -h 2>&1 |func_grep_q -- --shallow-since \
4264 && shallow="--shallow-since=$gnulib_clone_since"
4266 func_show_eval "$GIT clone $shallow '$gnulib_url' '$gnulib_path'" \
4267 func_cleanup_gnulib
4269 # FIXME: Solaris /bin/sh will try to execute '-' if any of
4270 # these signals are caught after this.
4271 trap - 1 2 13 15
4274 # Make sure we've checked out the correct revision of gnulib.
4275 func_show_eval "$GIT submodule init -- $gnulib_path" \
4276 && func_show_eval "$GIT submodule update -- $gnulib_path" \
4277 || func_fatal_error "Unable to update gnulib submodule."
4280 require_gnulib_submodule=:
4284 # require_gnulib_tool
4285 # -------------------
4286 # Ensure that '$gnulib_tool' is set, and points to an executable file,
4287 # or else fall back to using the binary 'true' if the main gnulib
4288 # files appear to have been imported already.
4289 require_gnulib_tool=func_require_gnulib_tool
4290 func_require_gnulib_tool ()
4292 $debug_cmd
4294 test true = "$gnulib_tool" || {
4295 $require_gnulib_submodule
4296 $require_gnulib_path
4298 test -n "$gnulib_tool" \
4299 || gnulib_tool=$gnulib_path/gnulib-tool
4301 test -x "$gnulib_tool" || {
4302 gnulib_tool=true
4303 func_warning recommend \
4304 "No 'gnulib-tool' found; gnulib modules may be missing."
4307 test true = "$gnulib_tool" \
4308 || func_verbose "found '$gnulib_tool'"
4311 require_gnulib_tool=:
4315 # require_gnulib_tool_base_options
4316 # --------------------------------
4317 # Ensure that '$gnulib_tool_base_options' contains all the base options
4318 # required according to user configuration from bootstrap.conf.
4319 require_gnulib_tool_base_options=func_require_gnulib_tool_base_options
4320 func_require_gnulib_tool_base_options ()
4322 $debug_cmd
4324 $require_gnulib_tool
4326 gnulib_tool_base_options=
4328 test true = "$gnulib_tool" || {
4329 # 'gnulib_modules' and others are maintained in 'bootstrap.conf':
4330 # Use 'gnulib --import' to fetch gnulib modules.
4331 $require_build_aux
4332 test -n "$build_aux" \
4333 && func_append_uniq gnulib_tool_base_options " --aux-dir=$build_aux"
4334 $require_macro_dir
4335 test -n "$macro_dir" \
4336 && func_append_uniq gnulib_tool_base_options " --m4-base=$macro_dir"
4337 $require_doc_base
4338 test -n "$doc_base" \
4339 && func_append_uniq gnulib_tool_base_options " --doc-base=$doc_base"
4340 $require_gnulib_name
4341 test -n "$gnulib_name" \
4342 && func_append_uniq gnulib_tool_base_options " --lib=$gnulib_name"
4343 $require_local_gl_path
4344 test -n "$local_gl_path" && {
4345 eval "set dummy $local_gl_path_quoted" ; shift
4346 for _G_dir
4348 func_append_uniq gnulib_tool_base_options " --local-dir=$_G_dir"
4349 done
4351 $require_source_base
4352 test -n "$source_base" \
4353 && func_append_uniq gnulib_tool_base_options " --source-base=$source_base"
4356 require_gnulib_tool_base_options=:
4360 # require_libtoolize
4361 # ------------------
4362 # Skip libtoolize if it's not needed.
4363 require_libtoolize=func_require_libtoolize
4364 func_require_libtoolize ()
4366 $debug_cmd
4368 # Unless we're not searching for libtool use by this package, set
4369 # LIBTOOLIZE to true if none of 'LT_INIT', 'AC_PROG_LIBTOOL' and
4370 # 'AM_PROG_LIBTOOL' are used in configure.
4371 test true = "$LIBTOOLIZE" || {
4372 func_extract_trace LT_INIT
4373 test -n "$func_extract_trace_result" || func_extract_trace AC_PROG_LIBTOOL
4374 test -n "$func_extract_trace_result" || func_extract_trace AM_PROG_LIBTOOL
4375 test -n "$func_extract_trace_result" || LIBTOOLIZE=true
4378 test -n "$LIBTOOLIZE" || {
4379 # Find libtoolize, named glibtoolize in Mac Ports, but prefer
4380 # user-installed libtoolize to ancient glibtoolize shipped by
4381 # Apple with Mac OS X when Mac Ports is not installed.
4382 func_find_tool LIBTOOLIZE libtoolize glibtoolize
4385 test -n "$LIBTOOLIZE" || func_fatal_error "\
4386 Please install GNU Libtool, or 'export LIBTOOLIZE=/path/to/libtoolize'."
4388 func_verbose "export LIBTOOLIZE='$LIBTOOLIZE'"
4390 # Make sure the search result is visible to subshells
4391 export LIBTOOLIZE
4393 require_libtoolize=:
4397 # require_local_gl_path
4398 # ---------------------
4399 # Ensure local_gl_path has a sensible value, extracted from 'gnulib-cache.m4' if
4400 # possible, otherwise letting 'gnulib-tool' pick a default.
4401 require_local_gl_path=func_require_local_gl_path
4402 func_require_local_gl_path ()
4404 $debug_cmd
4406 $require_gnulib_cache
4408 # Compat with older bootstrap versions.
4409 test -n "$local_gl_dir" && {
4410 func_warning settings "\
4411 Please use 'local_gl_path' instead of 'local_gl_dir' in your
4412 'bootstrap.conf' file."
4413 local_gl_path=$local_gl_dir
4414 local_gl_dir=
4417 test -f "$gnulib_cache" && test -z "$local_gl_path" && {
4418 func_extract_trace_first "gl_LOCAL_DIR" "$gnulib_cache"
4419 local_gl_path=$func_extract_trace_first_result
4420 test -n "$local_gl_path" && func_verbose "local_gl_path='$local_gl_path'"
4423 test -z "$local_gl_path_quoted" && test -n "$local_gl_path" && {
4424 save_IFS=$IFS
4425 set dummy
4426 # Don't use PATH_SEPARATOR here, gnulib must be fixed to store only ':' as
4427 # path separator into gnulib-cache.m4 (consistency reasons among systems).
4428 IFS=:
4429 for _G_dir in $local_gl_path
4431 set "$@" "$_G_dir"
4432 done
4433 shift
4434 IFS=$save_IFS
4435 func_quote eval "$@"
4436 local_gl_path_quoted=$func_quote_result
4439 require_local_gl_path=:
4443 # require_macro_dir
4444 # -----------------
4445 # Ensure that '$macro_dir' is set, and if it doesn't already point to an
4446 # existing directory, create one.
4447 require_macro_dir=func_require_macro_dir
4448 func_require_macro_dir ()
4450 $debug_cmd
4452 # Sometimes this is stored in 'configure.ac'.
4453 test -n "$macro_dir" || {
4454 # AC_CONFIG_MACRO_DIRS takes a space delimited list of directories,
4455 # but we only care about the first one in bootstrap.
4456 func_extract_trace_first AC_CONFIG_MACRO_DIRS
4457 macro_dir=`expr "x$func_extract_trace_first_result" : 'x\([^ ]*\)'`
4459 test -n "$macro_dir" || {
4460 func_extract_trace_first AC_CONFIG_MACRO_DIR
4461 macro_dir=$func_extract_trace_first_result
4464 # Otherwise we might find it in 'Makefile.am'.
4465 test -n "$macro_dir" || {
4466 $require_aclocal_amflags
4468 # Take the argument following the first '-I', if any.
4469 _G_minus_I_seen=false
4470 for _G_arg in $aclocal_amflags; do
4471 case $_G_minus_I_seen,$_G_arg in
4472 :,*) macro_dir=$_G_arg; break ;;
4473 *,-I) _G_minus_I_seen=: ;;
4474 *,-I*) macro_dir=`expr x$_G_arg : 'x-I\(.*\)$'`; break ;;
4475 esac
4476 done
4479 func_verbose "macro_dir='$macro_dir'"
4481 func_check_configuration macro_dir \
4482 "AC_CONFIG_MACRO_DIRS([name of a directory for configure m4 files])"
4484 $require_vc_ignore_files
4486 # If the macro_dir directory doesn't exist, create it now, and mark it
4487 # as ignored for the VCS.
4488 if test ! -d "$macro_dir"; then
4489 mkdir "$macro_dir" || func_permissions_error "$macro_dir"
4491 test -n "$vc_ignore_files" \
4492 || func_insert_if_absent "$macro_dir" $vc_ignore_files
4495 require_macro_dir=:
4499 # require_makefile_am
4500 # -------------------
4501 # Ensure there is a 'Makefile.am' in the current directory.
4502 require_makefile_am=func_require_makefile_am
4503 func_require_makefile_am ()
4505 $debug_cmd
4507 test -n "$makefile_am" \
4508 || makefile_am=Makefile.am
4510 <"$makefile_am"
4512 func_verbose "found '$makefile_am'"
4514 require_makefile_am=:
4518 # require_package
4519 # ---------------
4520 # Ensure that '$package' contains a sensible default value.
4521 require_package=func_require_package
4522 func_require_package ()
4524 $debug_cmd
4526 test -n "$package" || {
4527 $require_package_name
4529 package=`echo "$package_name" \
4530 |$SED -e 's/GNU //' \
4531 -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
4534 func_verbose "package='$package'"
4536 require_package=:
4540 # require_package_bugreport
4541 # -------------------------
4542 # Ensure that this has a sensible value, extracted from 'configure.ac'
4543 # if appropriate (and possible!).
4544 require_package_bugreport=func_require_package_bugreport
4545 func_require_package_bugreport ()
4547 $debug_cmd
4549 func_extract_trace AC_INIT
4551 save_ifs=$IFS
4552 IFS=:
4553 set dummy $func_extract_trace_result
4554 IFS=$save_ifs
4555 shift
4557 test -n "$package_bugreport" || package_bugreport=$3
4558 func_check_configuration package_bugreport \
4559 "AC_INIT([$package_name], [$package_version], [bug-$package@gnu.org])"
4560 func_verbose "package_bugreport='$package_bugreport'"
4562 require_package_bugreport=:
4566 # require_package_name
4567 # --------------------
4568 # Ensure that this has a sensible value, extracted from 'configure.ac'
4569 # if appropriate (and possible!).
4570 require_package_name=func_require_package_name
4571 func_require_package_name ()
4573 $debug_cmd
4575 func_extract_trace AC_INIT
4577 save_ifs=$IFS
4578 IFS=:
4579 set dummy $func_extract_trace_result
4580 IFS=$save_ifs
4581 shift
4583 test -n "$package_name" || package_name=$1
4584 func_check_configuration package_name \
4585 "AC_INIT([name of your package], [package version number])"
4586 func_verbose "package_name='$package_name'"
4588 require_package_name=:
4592 # require_package_version
4593 # -----------------------
4594 # Ensure that this has a sensible value, extracted from 'configure.ac'
4595 # if appropriate (and possible!). While we might have set all the
4596 # parameters extracted from AC_INIT at once, 'package_version' in
4597 # particular is not necessarily available as early as the others, since
4598 # 'git-version-gen' is often involved, and until then we can't rely on
4599 # getting a correct version number from an AC_INIT extraction.
4600 require_package_version=func_require_package_version
4601 func_require_package_version ()
4603 $debug_cmd
4605 func_extract_trace AC_INIT
4607 save_ifs=$IFS
4608 IFS=:
4609 set dummy $func_extract_trace_result
4610 IFS=$save_ifs
4611 shift
4613 test -n "$package_version" || package_version=$2
4614 test -n "$package_version" || {
4615 # The embedded echo is to squash whitespace before globbing.
4616 case " "`echo $gnulib_modules`" " in
4617 *" git-version-gen "*)
4618 func_fatal_error "\
4619 cannot \$require_package_version in bootstrap.conf before
4620 func_gnulib_tool has installed the 'git-version-gen' script."
4623 func_check_configuration package_version \
4624 "AC_INIT([name of your package], [package version number])"
4626 esac
4628 func_verbose "package_version='$package_version'"
4630 require_package_version=:
4634 # require_patch
4635 # -------------
4636 # Find patch, according to the PATCH environment variable, or else
4637 # searching the user's PATH.
4638 require_patch=func_require_patch
4639 func_require_patch ()
4641 $debug_cmd
4643 test -n "$PATCH" || {
4644 # Find a patch program, preferring gpatch, which is usually better
4645 # than the vendor patch.
4646 func_find_tool PATCH gpatch patch
4649 test -n "$PATCH" || func_fatal_error "\
4650 Please install GNU Patch, or 'export PATCH=/path/to/gnu/patch'."
4652 func_verbose "export PATCH='$PATCH'"
4654 # Make sure the search result is visible to subshells
4655 export PATCH
4657 require_patch=:
4661 # require_source_base
4662 # -------------------
4663 # Ensure that source_base has a sensible value, extracted from
4664 # 'gnulib-cache.m4' if possible.
4665 require_source_base=func_require_source_base
4666 func_require_source_base ()
4668 $debug_cmd
4670 $require_gnulib_cache
4672 test -f "$gnulib_cache" && test -z "$source_base" && {
4673 func_extract_trace_first "gl_SOURCE_BASE" "$gnulib_cache"
4675 source_base=$func_extract_trace_first_result
4677 func_verbose "source_base='$source_base'"
4680 require_source_base=:
4684 # require_vc_ignore_files
4685 # -----------------------
4686 # Ensure that '$vc_ignore' has been processed to list VCS ignore files
4687 # in '$vc_ignore_files'
4688 require_vc_ignore_files=func_require_vc_ignore_files
4689 func_require_vc_ignore_files ()
4691 $debug_cmd
4693 test -n "$vc_ignore" || vc_ignore=auto
4695 if test auto = "$vc_ignore" && test -z "$vc_ignore_files"; then
4696 vc_ignore_files=
4697 test -d .git && vc_ignore_files=.gitignore
4698 test -d CVS && vc_ignore_files="$vc_ignore_files .cvsignore"
4699 else
4700 vc_ignore_files=$vc_ignore
4703 func_verbose "vc_ignore_files='$vc_ignore_files'"
4705 require_vc_ignore_files=:
4709 ## ----------------- ##
4710 ## Helper functions. ##
4711 ## ----------------- ##
4713 # This section contains the helper functions used by the rest of 'bootstrap'.
4715 # func_len STRING
4716 # ---------------
4717 # STRING may not start with a hyphen.
4718 if (eval 'x=123; test x${#x} = "x3"') 2>/dev/null
4719 then
4720 # This is an XSI compatible shell, allowing a faster implementation...
4721 eval 'func_len ()
4723 $debug_cmd
4725 func_len_result=${#1}
4727 else
4728 # ...otherwise fall back to using expr, which is often a shell builtin.
4729 func_len ()
4731 $debug_cmd
4733 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo 0`
4738 # func_cmp_s FILE1 FILE2
4739 # ----------------------
4740 # Return non-zero exit status unless FILE1 and FILE2 are identical, without
4741 # any output at all, even error messages.
4742 func_cmp_s ()
4744 $debug_cmd
4746 # This function relies on non-zero exit status, which will cause the
4747 # program to exit when running in 'set -e' mode.
4748 $CMP "$@" >/dev/null 2>&1
4752 # func_grep_q EXPRESSION [FILENAME..]
4753 # -----------------------------------
4754 # Check whether EXPRESSION matches any line of any listed FILENAME,
4755 # without any output at all, even error messages.
4756 func_grep_q ()
4758 $debug_cmd
4760 # This function relies on non-zero exit status, which will cause the
4761 # program to exit when running in 'set -e' mode.
4762 $GREP "$@" >/dev/null 2>&1
4766 # func_ifcontains LIST MEMBER YES-CMD [NO-CMD]
4767 # --------------------------------------------
4768 # If whitespace-separated LIST contains MEMBER then execute YES-CMD,
4769 # otherwise if NO-CMD was given, execute that.
4770 func_ifcontains ()
4772 $debug_cmd
4774 _G_wslist=$1
4775 _G_member=$2
4776 _G_yes_cmd=$3
4777 _G_no_cmd=${4-":"}
4779 _G_found=false
4780 for _G_item in $_G_wslist; do
4781 test "x$_G_item" = "x$_G_member" && {
4782 _G_found=:
4783 break
4785 done
4786 if $_G_found; then
4787 eval "$_G_yes_cmd"
4788 _G_status=$?
4789 else
4790 eval "$_G_no_cmd"
4791 _G_status=$?
4794 test 0 -eq "$_G_status" || exit $_G_status
4798 # func_strpad STR WIDTH CHAR
4799 # --------------------------
4800 # Trim STR, or pad with CHAR to force a total length of WIDTH.
4801 func_strpad ()
4803 $debug_cmd
4805 _G_width=`expr "$2" - 1`
4806 func_strpad_result=`$ECHO "$1" |$SED '
4808 s|^.\{0,'"$_G_width"'\}$|&'"$3"'|
4814 # func_strrpad STR WIDTH CHAR
4815 # ---------------------------
4816 # Trim STR, or right-justify-pad with CHAR to force a total length of
4817 # WIDTH.
4818 func_strrpad ()
4820 $debug_cmd
4822 _G_width=`expr "$2" - 1`
4823 func_strrpad_result=`$ECHO "$1" |$SED '
4825 s|^.\{0,'"$_G_width"'\}$|'"$3"'&|
4831 # func_strrow INDENT FIELD WIDTH [FIELDn WIDTHn]...
4832 # -------------------------------------------------
4833 # Return a string containing each FIELD left justified to WIDTH, with
4834 # the whole thing indented by INDENT spaces. This function is used to
4835 # render one row of aligned columns for a table by func_strtable().
4836 func_strrow ()
4838 $debug_cmd
4840 func_strrow_linelen=$1; shift
4842 _G_row=
4843 while test $# -gt 0; do
4844 func_strrow_linelen=`expr $func_strrow_linelen + $2`
4845 func_strpad "$1" $2 " "
4846 func_append _G_row "$func_strpad_result"
4847 shift; shift
4848 done
4850 func_strrpad "$_G_row" $func_strrow_linelen " "
4851 func_strrow_result=$func_strrpad_result
4855 # func_strtable INDENT WIDTH1...WIDTHn HEADER1...HEADERn FIELD1...FIELDn
4856 # ----------------------------------------------------------------------
4857 # Generate a string of newline-separated rows arranged in lined-up
4858 # columns of the given WIDTHs, with the entire table indented by INDENT
4859 # spaces. The number of columns is determined by the number of integer
4860 # valued WIDTH arguments following INDENT. The next set (i.e. a number
4861 # of arguments equal to the number of WIDTH arguments) of fields are
4862 # treated as the table's column HEADERs, and are separated from the
4863 # remainder of the table by an indented row of '-' characters. Remaining
4864 # arguments are each aligned below the next available header, wrapping
4865 # to a new row as necessary. Finally another row of '-' characters is
4866 # added to mark the end of the table.
4868 # For example an unindented 3 column table with 2 rows of data would be
4869 # generated by this call:
4871 # func_strtable 3 20 10 25 \
4872 # Header1 Header2 Header3 \
4873 # Row1Col1 Row1Col2 Row1Col3 \
4874 # Row2Col1 Row2Col2 Row2Col3
4876 # returning the following string:
4878 # " Header1 Header2 Header3
4879 # -------------------------------------------------------
4880 # Row1Col1 Row1Col2 Row1Col3
4881 # Row2Col1 Row2Col2 Row2Col3
4882 # -------------------------------------------------------"
4883 func_strtable ()
4885 $debug_cmd
4887 # Save the indent value, we'll need it for each row we render.
4888 _G_indent=$1; shift
4890 # Collect remaining numeric args into a list for reuse between
4891 # members of each row when we call func_strrow later.
4892 _G_widths=$1; shift
4893 while test 0 -lt `expr "$1" : '[1-9][0-9]*$'`; do
4894 func_append _G_widths " $1"; shift
4895 done
4897 # Extract the same number of positional parameters as there are
4898 # width elements - we'll do the header rows separately so that
4899 # we can insert a divider line.
4900 _G_header=$_G_indent
4901 for _G_width in $_G_widths; do
4902 func_append _G_header " $1 $_G_width"; shift
4903 done
4904 func_strrow $_G_header
4906 # Strip off the indent, and make a divider with '-' chars, then
4907 # reindent.
4908 _G_divider=`$ECHO "$func_strrow_result" \
4909 |$SED 's|[^ ]|-|g
4911 s|- |--|g
4915 # Append the header and divider to the running result.
4916 func_append func_strtable_result "\
4917 $func_strrow_result
4918 $_G_divider
4921 # The remaining rows are zipped between the width values we
4922 # unwound earlier just like the header row above.
4923 while test $# -gt 0; do
4924 _G_row=$_G_indent
4925 for _G_width in $_G_widths; do
4926 func_append _G_row " $1 $_G_width"; shift
4927 done
4928 func_strrow $_G_row
4929 func_append func_strtable_result "\
4930 $func_strrow_result
4932 done
4934 # Mark the end of the table with a final divider line.
4935 func_append func_strtable_result "$_G_divider"
4939 # func_internal_error ARG...
4940 # --------------------------
4941 # Echo program name prefixed message to standard error, and exit.
4942 func_internal_error ()
4944 func_fatal_error "\
4945 INTERNAL: " ${1+"$@"} "
4946 Please report this bug to 'bug-gnulib@gnu.org'
4947 in as much detail as possible."
4951 # func_permissions_error FILE-OR-DIRECTORY
4952 # ----------------------------------------
4953 # Echo program name prefixed permissions error message to standard
4954 # error, and exit.
4955 func_permissions_error ()
4957 $debug_cmd
4959 func_fatal_error "Failed to create '$1', check permissions."
4963 # func_show_eval CMD [FAIL_EXP]
4964 # -----------------------------
4965 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
4966 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
4967 # is given, then evaluate it.
4968 func_show_eval ()
4970 $debug_cmd
4972 $require_term_colors
4974 _G_cmd=$1
4975 _G_fail_exp=${2-':'}
4977 ${opt_silent-'false'} || {
4978 func_quote eval $_G_cmd
4979 eval func_truncate_cmd $func_quote_result
4980 func_echo "running: $tc_bold$func_truncate_cmd_result$tc_reset"
4983 ${opt_dry_run-'false'} || {
4984 eval "$_G_cmd"
4985 _G_status=$?
4986 test 0 -eq "$_G_status" || eval "(exit $_G_status); $_G_fail_exp"
4991 # func_truncate_cmd CMD [ARG]...
4992 # ------------------------------
4993 # For unreasonably long commands (such as a gnulib-tool invocation with
4994 # the full module list for import), truncate CMD after the second non-
4995 # option ARG.
4996 func_truncate_cmd ()
4998 $debug_cmd
5000 _G_last_arg_opt_p=false
5001 func_truncate_cmd_result=
5003 set dummy "$@"; shift
5005 while test $# -gt 0; do
5006 _G_opt=$1; shift
5008 test -n "$func_truncate_cmd_result" \
5009 && func_append func_truncate_cmd_result ' '
5010 func_append func_truncate_cmd_result "$_G_opt"
5012 func_len "x$func_truncate_cmd_result"
5014 case $_G_opt in
5015 -*) _G_last_arg_opt_p=: ;;
5016 *) $_G_last_arg_opt_p \
5017 || test "$min_cmd_len" -gt "$func_len_result" \
5018 || break
5019 _G_last_arg_opt_p=false
5021 esac
5022 done
5024 test $# -gt 0 && func_append func_truncate_cmd_result "..."
5028 # func_gitignore_entries FILE...
5029 # ------------------------------
5030 # Strip blank and comment lines to leave significant entries.
5031 func_gitignore_entries ()
5033 $debug_cmd
5035 $SED -e '/^#/d' -e '/^$/d' "$@"
5039 # func_insert_if_absent STR FILE...
5040 # ---------------------------------
5041 # If $STR is not already on a line by itself in $FILE, insert it, at the
5042 # start. Entries are inserted at the start of the ignore list to ensure
5043 # existing entries starting with ! are not overridden. Such entries
5044 # support whilelisting exceptions after a more generic blacklist pattern.
5045 # sorting the new contents of the file and replacing $FILE with the result.
5046 func_insert_if_absent ()
5048 $debug_cmd
5050 str=$1
5051 shift
5053 for file
5055 test -f "$file" || touch "$file"
5057 duplicate_entries=`func_gitignore_entries "$file" |sort |uniq -d`
5058 test -n "$duplicate_entries" \
5059 && func_error "duplicate entries in $file: " $duplicate_entries
5061 func_grep_q "^$str\$" "$file" \
5062 || func_verbose "inserting '$str' into '$file'"
5064 linesold=`func_gitignore_entries "$file" |wc -l`
5065 linesnew=`{ $ECHO "$str"; cat "$file"; } \
5066 |func_gitignore_entries |sort -u |wc -l`
5067 test "$linesold" -eq "$linesnew" \
5068 || { $SED "1i\\$nl$str$nl" "$file" >"$file"T && mv "$file"T "$file"; } \
5069 || func_permissions_error "$file"
5070 done
5074 # func_get_version APP
5075 # --------------------
5076 # echo the version number (if any) of APP, which is looked up along your
5077 # PATH.
5078 func_get_version ()
5080 $debug_cmd
5082 _G_app=$1
5084 # Rather than uncomment the sed script in-situ, strip the comments
5085 # programatically before passing the result to $SED for evaluation.
5086 sed_get_version=`$ECHO '# extract version within line
5087 s|.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1|
5088 t done
5090 # extract version at start of line
5091 s|^\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1|
5092 t done
5096 :done
5097 # the following essentially does s|5.005|5.5|
5098 s|\.0*\([1-9]\)|.\1|g
5100 q' \
5101 |$SED '/^[ ]*#.*$/d'`
5103 func_tool_version_output $_G_app >/dev/null
5104 _G_status=$?
5106 test 0 -ne "$_G_status" \
5107 || $_G_app --version 2>&1 |$SED -n "$sed_get_version"
5109 (exit $_G_status)
5113 # func_check_tool APP
5114 # -------------------
5115 # Search PATH for an executable at APP.
5116 func_check_tool ()
5118 $debug_cmd
5120 func_check_tool_result=
5122 case $1 in
5123 *[\\/]*)
5124 test -x "$1" && func_check_tool_result=$1
5127 save_IFS=$IFS
5128 IFS=${PATH_SEPARATOR-:}
5129 for _G_check_tool_path in $PATH; do
5130 IFS=$save_IFS
5131 if test -x "$_G_check_tool_path/$1"; then
5132 func_check_tool_result=$_G_check_tool_path/$1
5133 break
5135 done
5136 IFS=$save_IFS
5138 esac
5142 # func_check_versions APP1 VER1 URL1 ...[APPN VERN URLN]
5143 # ------------------------------------------------------
5144 func_check_versions ()
5146 $debug_cmd
5148 func_check_versions_result=:
5150 while test $# -gt 0; do
5151 _G_app=$1; shift
5152 _G_reqver=$1; shift
5153 _G_url=$1; shift
5155 # Diagnose bad buildreq formatting.
5156 case $_G_url in
5157 [a-z]*://*) ;; # looks like a url
5158 *) func_fatal_error "\
5159 '$_G_url' from the buildreq table in
5160 'bootstrap.conf' does not look like the URL for downloading
5161 $_G_app. Please ensure that buildreq is a strict newline
5162 delimited list of triples; 'program min-version url'."
5164 esac
5166 # Honor $APP variables ($TAR, $AUTOCONF, etc.)
5167 _G_appvar=`echo $_G_app |tr '[a-z]' '[A-Z]'`
5168 test TAR = "$_G_appvar" && _G_appvar=AMTAR
5169 eval "_G_app=\${$_G_appvar-$_G_app}"
5171 # Fail if no version specified, but the program can't be found.
5172 if test x- = "x$_G_reqver"; then
5173 func_check_tool $_G_app
5174 if test -z "$func_check_tool_result"; then
5175 func_error "Prerequisite '$_G_app' not not found. Please install it, or
5176 'export $_G_appvar=/path/to/$_G_app'."
5177 func_check_versions_result=false
5178 else
5179 func_verbose "found '$func_check_tool_result' for $_G_appvar."
5181 else
5182 _G_instver=`func_get_version $_G_app`
5184 # Fail if --version didn't work.
5185 if test -z "$_G_instver"; then
5186 func_error "Prerequisite '$_G_app' not found. Please install it, or
5187 'export $_G_appvar=/path/to/$_G_app'."
5188 func_check_versions_result=false
5190 # Fail if a newer version than what we have is required.
5191 else
5192 func_verbose "found '$_G_app' version $_G_instver."
5194 case $_G_reqver in
5196 # If $buildreq version starts with '=', version must
5197 # match the installed program exactly.
5198 test "x$_G_reqver" = "x=$_G_instver" || {
5199 func_error "\
5200 '$_G_app' version == $_G_instver is too old
5201 'exactly $_G_app-$_G_reqver is required"
5202 func_check_versions_result=false
5206 # Otherwise, anything that is not older is a match.
5207 func_lt_ver "$_G_reqver" "$_G_instver" || {
5208 func_error "\
5209 '$_G_app' version == $_G_instver is too old
5210 '$_G_app' version >= $_G_reqver is required"
5211 func_check_versions_result=false
5214 esac
5217 done
5221 # func_cleanup_gnulib
5222 # -------------------
5223 # Recursively delete everything below the path in the global variable
5224 # GNULIB_PATH.
5225 func_cleanup_gnulib ()
5227 $debug_cmd
5229 _G_status=$?
5230 $RM -fr "$gnulib_path"
5231 exit $_G_status
5235 # func_download_po_files SUBDIR DOMAIN
5236 # ------------------------------------
5237 func_download_po_files ()
5239 $debug_cmd
5241 func_echo "getting translations into $1 for $2..."
5242 _G_cmd=`printf "$po_download_command_format" "$2" "$1"`
5243 eval "$_G_cmd"
5247 # func_update_po_files PO_DIR DOMAIN
5248 # ----------------------------------
5249 # Mirror .po files to $po_dir/.reference and copy only the new
5250 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
5251 # Note po files that exist locally only are left in $po_dir but will
5252 # not be included in LINGUAS and hence will not be distributed.
5253 func_update_po_files ()
5255 $debug_cmd
5257 # Directory containing primary .po files.
5258 # Overwrite them only when we're sure a .po file is new.
5259 _G_po_dir=$1
5260 _G_domain=$2
5262 # Mirror *.po files into this dir.
5263 # Usually contains *.s1 checksum files.
5264 _G_ref_po_dir=$_G_po_dir/.reference
5266 test -d "$_G_ref_po_dir" || mkdir $_G_ref_po_dir || return
5267 func_download_po_files $_G_ref_po_dir $_G_domain \
5268 && ls "$_G_ref_po_dir"/*.po 2>/dev/null \
5269 |$SED -e 's|.*/||' -e 's|\.po$||' > "$_G_po_dir/LINGUAS" || return
5271 # Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6+.
5272 func_find_tool SHA1SUM sha1sum gsha1sum shasum sha1
5274 test -n "$SHA1SUM" || func_fatal_error "\
5275 Please install GNU Coreutils, or 'export SHA1SUM=/path/to/sha1sum'."
5277 _G_langs=`cd $_G_ref_po_dir && echo *.po|$SED 's|\.po||g'`
5278 test '*' = "$_G_langs" && _G_langs=x
5279 for _G_po in $_G_langs; do
5280 case $_G_po in x) continue;; esac
5281 _G_new_po=$_G_ref_po_dir/$_G_po.po
5282 _G_cksum_file=$_G_ref_po_dir/$_G_po.s1
5283 if ! test -f "$_G_cksum_file" ||
5284 ! test -f "$_G_po_dir/$_G_po.po" ||
5285 ! $SHA1SUM -c "$_G_cksum_file" \
5286 < "$_G_new_po" > /dev/null; then
5287 echo "updated $_G_po_dir/$_G_po.po..."
5288 cp "$_G_new_po" "$_G_po_dir/$_G_po.po" \
5289 && $SHA1SUM < "$_G_new_po" > "$_G_cksum_file" || return
5291 done
5296 ## --------------- ##
5297 ## Option parsing. ##
5298 ## --------------- ##
5300 # Hook in the functions to make sure our own options are parsed during
5301 # the option parsing loop.
5303 usage='$progpath [OPTION]...'
5305 # Short help message in response to '-h'. Add to this in 'bootstrap.conf'
5306 # if you accept any additional options.
5307 usage_message="Common Bootstrap Options:
5308 -c, --copy copy files instead of creating symbolic links.
5309 --debug enable verbose shell tracing
5310 -n, --dry-run print commands rather than running them
5311 -f, --force attempt to bootstrap even if the sources seem not
5312 to have been checked out.
5313 --gnulib-srcdir=DIRNAME
5314 specify a local directory where gnulib sources
5315 reside. Use this if you already have the gnulib
5316 sources on your machine, and don't want to waste
5317 your bandwidth downloading them again. Defaults to
5318 \$GNULIB_SRCDIR.
5319 --no-warnings equivalent to '-Wnone'
5320 --skip-git do not fetch files from remote repositories
5321 --skip-po do not download po files.
5322 -v, --verbose verbosely report processing
5323 --version print version information and exit
5324 -W, --warnings=CATEGORY
5325 report the warnings falling in CATEGORY [all]
5326 -h, --help print short or long help message and exit
5329 # Additional text appended to 'usage_message' in response to '--help'.
5330 long_help_message=$long_help_message"
5331 'recommend' show warnings about missing recommended packages
5332 'settings' show warnings about missing '$progname.conf' settings
5333 'upgrade' show warnings about out-dated files
5335 If the file '$progname.conf' exists in the same directory as this
5336 script, its contents are read as shell variables to configure the
5337 bootstrap.
5339 For build prerequisites, environment variables like \$AUTOCONF and
5340 \$AMTAR are honored.
5342 Running without arguments will suffice in most cases.
5345 # Warning categories used by 'bootstrap', append others if you use them
5346 # in your 'bootstrap.conf'.
5347 warning_categories='recommend settings upgrade'
5350 # bootstrap_options_prep [ARG]...
5351 # -------------------------------
5352 # Preparation for options parsed by Bootstrap.
5353 bootstrap_options_prep ()
5355 $debug_cmd
5357 # Option defaults:
5358 opt_copy=${copy-'false'}
5359 opt_dry_run=false
5360 opt_force=false
5361 opt_gnulib_srcdir=$GNULIB_SRCDIR
5362 opt_skip_git=false
5363 opt_skip_po=false
5365 # Pass back the list of options we consumed.
5366 func_quote eval ${1+"$@"}
5367 bootstrap_options_prep_result=$func_quote_result
5369 func_add_hook func_options_prep bootstrap_options_prep
5372 # bootstrap_parse_options [ARG]...
5373 # --------------------------------
5374 # Provide handling for Bootstrap specific options.
5375 bootstrap_parse_options ()
5377 $debug_cmd
5379 # Perform our own loop to consume as many options as possible in
5380 # each iteration.
5381 while test $# -gt 0; do
5382 _G_opt=$1
5383 shift
5384 case $_G_opt in
5385 --dry-run|--dryrun|-n)
5386 opt_dry_run=: ;;
5387 --copy|-c) opt_copy=: ;;
5388 --force|-f) opt_force=: ;;
5390 --gnulib-srcdir)
5391 test $# = 0 && func_missing_arg $_G_opt && break
5392 opt_gnulib_srcdir=$1
5393 shift
5396 --skip-git|--no-git)
5397 opt_skip_git=:
5400 --skip-po|--no-po)
5401 opt_skip_po=:
5404 # Separate non-argument short options:
5405 -c*|-f*|-n*)
5406 func_split_short_opt "$_G_opt"
5407 set dummy "$func_split_short_opt_name" \
5408 "-$func_split_short_opt_arg" ${1+"$@"}
5409 shift
5412 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
5413 esac
5414 done
5416 # save modified positional parameters for caller
5417 func_quote eval ${1+"$@"}
5418 bootstrap_parse_options_result=$func_quote_result
5420 func_add_hook func_parse_options bootstrap_parse_options
5423 # bootstrap_validate_options [ARG]...
5424 # -----------------------------------
5425 # Perform any sanity checks on option settings and/or unconsumed
5426 # arguments.
5427 bootstrap_validate_options ()
5429 $debug_cmd
5431 # Validate options.
5432 test $# -gt 0 \
5433 && func_fatal_help "too many arguments"
5435 # Pass back the (empty) list of unconsumed options.
5436 func_quote eval ${1+"$@"}
5437 bootstrap_validate_options_result=$func_quote_result
5439 func_add_hook func_validate_options bootstrap_validate_options
5442 ## -------------------------------------------------- ##
5443 ## Source package customisations in 'bootstrap.conf'. ##
5444 ## -------------------------------------------------- ##
5446 # Override the default configuration, if necessary.
5447 # Make sure that bootstrap.conf is sourced from the current directory
5448 # if we were invoked as "sh bootstrap".
5449 case $0 in
5450 */*) test -r "$0.conf" && . "$0.conf" ;;
5451 *) test -r "$0.conf" && . ./"$0.conf" ;;
5452 esac
5455 ## ------------------------------- ##
5456 ## Actually perform the bootstrap. ##
5457 ## ------------------------------- ##
5459 func_bootstrap ${1+"$@"}
5461 # The End.
5462 exit ${exit_status-$EXIT_SUCCESS}
5464 # Local variables:
5465 # mode: shell-script
5466 # sh-indentation: 2
5467 # eval: (add-hook 'before-save-hook 'time-stamp)
5468 # time-stamp-pattern: "500/scriptversion=%:y-%02m-%02d.%02H; # UTC"
5469 # time-stamp-time-zone: "UTC"
5470 # End: