2 ## DO NOT EDIT - This file generated from build-aux/bootstrap.in
3 ## by inline-source v2014-01-03.01
5 # Bootstrap an Autotooled package from checked-out sources.
6 # Written by Gary V. Vaughan, 2010
8 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
9 # This is free software; see the source for copying conditions. There is NO
10 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # This program is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 # Originally written by Paul Eggert. The canonical version of this
26 # script is maintained as build-aux/bootstrap in gnulib, however, to
27 # be useful to your project, you should place a copy of it under
28 # version control in the top-level directory of your project. The
29 # intent is that all customization can be done with a bootstrap.conf
30 # file also maintained in your version control; gnulib comes with a
31 # template build-aux/bootstrap.conf to get you started.
33 # Please report bugs or propose patches to bug-gnulib@gnu.org.
40 # Most GNUish projects do not keep all of the generated Autotool
41 # files under version control, but running all of the right tools
42 # with the right arguments, in the correct order to regenerate
43 # all of those files in readiness for configuration and building
44 # can be surprisingly involved! Many projects have a 'bootstrap'
45 # script under version control to invoke Autotools and perform
46 # other assorted book-keeping with version numbers and the like.
48 # This bootstrap script aims to probe the configure.ac and top
49 # Makefile.am of your project to automatically determine what
50 # the correct ordering and arguments are and then run the tools for
51 # you. In order to use it, you can generate an initial standalone
54 # gl/build-aux/inline-source gl/build-aux/bootstrap.in > bootstrap
56 # You should then store than script in version control for other
57 # developers in you project. It will give you instructions about
58 # how to keep it up to date if the sources change.
60 # See gl/doc/bootstrap.texi for documentation on how to write
61 # a bootstrap.conf to customize it for your project's
65 ## ================================================================== ##
67 ## DO NOT EDIT THIS FILE, CUSTOMIZE IT USING A BOOTSTRAP.CONF ##
69 ## ================================================================== ##
71 ## ------------------------------- ##
72 ## User overridable command paths. ##
73 ## ------------------------------- ##
75 # All uppercase denotes values stored in the environment. These
76 # variables should generally be overridden by the user - however, we do
77 # set them to 'true' in some parts of this script to prevent them being
78 # called at the wrong time by other tools that we call ('autoreconf',
81 # We also allow 'LIBTOOLIZE', 'M4', 'SHA1SUM' and some others to be
82 # overridden, and export the result for child processes, but they are
83 # handled by the function 'func_find_tool' and not defaulted in this
86 : ${ACLOCAL="aclocal"}
87 : ${AUTOCONF="autoconf"}
88 : ${AUTOHEADER="autoheader"}
89 : ${AUTOM4TE="autom4te"}
90 : ${AUTOHEADER="autoheader"}
91 : ${AUTOMAKE="automake"}
92 : ${AUTOPOINT="autopoint"}
93 : ${AUTORECONF="autoreconf"}
95 : ${CONFIG_SHELL="/bin/sh"}
116 # A newline delimited list of triples of programs (that respond to
117 # --version), the minimum version numbers required (or just '-' in the
118 # version field if any version will be sufficient) and homepage URLs
119 # to help locate missing packages.
122 # Name of a file containing instructions on installing missing packages
123 # required in 'buildreq'.
124 buildreq_readme=README-hacking
126 # These are extracted from AC_INIT in configure.ac, though you can
127 # override those values in 'bootstrap.conf' if you prefer.
135 # These are extracted from 'gnulib-cache.m4', or else fall-back
136 # automatically on the gnulib defaults; unless you set the values
137 # manually in 'bootstrap.conf'.
145 # The list of gnulib modules required at 'gnulib-tool' time. If you
146 # check 'gnulib-cache.m4' into your repository, then this list will be
147 # extracted automatically.
150 # Extra gnulib files that are not in modules, which override files of
151 # the same name installed by other bootstrap tools.
152 gnulib_non_module_files="
156 build-aux/texinfo.tex
158 build-aux/config.guess
163 # Relative path to the local gnulib submodule, and url to the upstream
164 # git repository. If you have a gnulib entry in your .gitmodules file,
165 # these values are ignored.
169 # Additional gnulib-tool options to use.
170 gnulib_tool_options="
174 # bootstrap removes any macro-files that are not included by aclocal.m4,
175 # except for files listed in this variable that are always kept.
180 # When truncating long commands for display, always allow at least this
181 # many characters before truncating.
184 # The command to download all .po files for a specified domain into
185 # a specified directory. Fill in the first %s is the domain name, and
186 # the second with the destination directory. Use rsync's -L and -r
187 # options because the latest/%s directory and the .po files within are
189 po_download_command_format=\
190 "rsync --delete --exclude '*.s1' -Lrtvz \
191 'translationproject.org::tp/latest/%s/' '%s'"
193 # Other locale categories that need message catalogs.
194 extra_locale_categories=
196 # Additional xgettext options to use. Gnulib might provide you with an
197 # extensive list of additional options to append to this, but gettext
198 # 0.16.1 and newer appends them automaticaly, so you can safely ignore
199 # the complaints from 'gnulib-tool' if your $configure_ac states:
201 # AM_GNU_GETTEXT_VERSION([0.16.1])
203 --flag=_:1:pass-c-format
204 --flag=N_:1:pass-c-format
207 # Package copyright holder for gettext files. Defaults to FSF if unset.
210 # File that should exist in the top directory of a checked out hierarchy,
211 # but not in a distribution tarball.
214 # Whether to use copies instead of symlinks by default (if set to true,
215 # the --copy option has no effect).
218 # Set this to ".cvsignore .gitignore" in 'bootstrap.conf' if you want
219 # those files to be generated in directories like 'lib/', 'm4/', and 'po/',
220 # or set it to "auto" to make this script select what to use based
221 # on what version control system (if any) is used in the source directory.
222 # Or set it to "none" to ignore VCS ignore files entirely. Default is
227 ## ------------------- ##
228 ## External Libraries. ##
229 ## ------------------- ##
231 # Source required external libraries:
232 # Set a version string for this script.
233 scriptversion=2015-01-20.17; # UTC
235 # General shell script boiler plate, and helper functions.
236 # Written by Gary V. Vaughan, 2004
238 # Copyright (C) 2004-2015 Free Software Foundation, Inc.
239 # This is free software; see the source for copying conditions. There is NO
240 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
242 # This program is free software; you can redistribute it and/or modify
243 # it under the terms of the GNU General Public License as published by
244 # the Free Software Foundation; either version 3 of the License, or
245 # (at your option) any later version.
247 # As a special exception to the GNU General Public License, if you distribute
248 # this file as part of a program or library that is built using GNU Libtool,
249 # you may include this file under the same distribution terms that you use
250 # for the rest of that program.
252 # This program is distributed in the hope that it will be useful,
253 # but WITHOUT ANY WARRANTY; without even the implied warranty of
254 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
255 # General Public License for more details.
257 # You should have received a copy of the GNU General Public License
258 # along with this program. If not, see <http://www.gnu.org/licenses/>.
260 # Please report bugs or propose patches to gary@gnu.org.
267 # Evaluate this file near the top of your script to gain access to
268 # the functions and variables defined here:
270 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
272 # If you need to override any of the default environment variable
273 # settings, do that before evaluating this file.
276 ## -------------------- ##
277 ## Shell normalisation. ##
278 ## -------------------- ##
280 # Some shells need a little help to be as Bourne compatible as possible.
281 # Before doing anything else, make sure all that help has been provided!
283 DUALCASE=1; export DUALCASE # for MKS sh
284 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
287 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
288 # is contrary to our usage. Disable this feature.
289 alias -g '${1+"$@"}'='"$@"'
292 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
295 # NLS nuisances: We save the old values in case they are required later.
298 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
300 eval "if test set = \"\${$_G_var+set}\"; then
301 save_$_G_var=\$$_G_var
304 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
305 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
310 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
312 # Make sure IFS has a sensible default
318 # There are apparently some retarded systems that use ';' as a PATH separator!
319 if test "${PATH_SEPARATOR+set}" != set; then
321 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
322 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
329 ## ------------------------- ##
330 ## Locate command utilities. ##
331 ## ------------------------- ##
334 # func_executable_p FILE
335 # ----------------------
336 # Check that FILE is an executable regular file.
339 test -f "$1" && test -x "$1"
343 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
344 # --------------------------------------------
345 # Search for either a program that responds to --version with output
346 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
347 # trying all the directories in PATH with each of the elements of
350 # CHECK_FUNC should accept the path to a candidate program, and
351 # set $func_check_prog_result if it truncates its output less than
352 # $_G_path_prog_max characters.
360 _G_path_prog_found=false
361 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
362 for _G_dir in $_G_PATH; do
364 test -z "$_G_dir" && _G_dir=.
365 for _G_prog_name in $_G_progs_list; do
366 for _exeext in '' .EXE; do
367 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
368 func_executable_p "$_G_path_prog" || continue
369 case `"$_G_path_prog" --version 2>&1` in
370 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
371 *) $_G_check_func $_G_path_prog
372 func_path_progs_result=$func_check_prog_result
375 $_G_path_prog_found && break 3
380 test -z "$func_path_progs_result" && {
381 echo "no acceptable sed could be found in \$PATH" >&2
387 # We want to be able to use the functions in this file before configure
388 # has figured out where the best binaries are kept, which means we have
389 # to search for them ourselves - except when the results are already set
390 # where we skip the searches.
392 # Unless the user overrides by setting SED, search the path for either GNU
393 # sed, or the sed that truncates its output the least.
395 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
396 for _G_i in 1 2 3 4 5 6 7; do
397 _G_sed_script=$_G_sed_script$nl$_G_sed_script
399 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
402 func_check_prog_sed ()
407 printf 0123456789 >conftest.in
410 cat conftest.in conftest.in >conftest.tmp
411 mv conftest.tmp conftest.in
412 cp conftest.in conftest.nl
413 echo '' >> conftest.nl
414 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
415 diff conftest.out conftest.nl >/dev/null 2>&1 || break
416 _G_count=`expr $_G_count + 1`
417 if test "$_G_count" -gt "$_G_path_prog_max"; then
418 # Best one so far, save it but keep looking for a better one
419 func_check_prog_result=$_G_path_prog
420 _G_path_prog_max=$_G_count
422 # 10*(2^10) chars as input seems more than enough
423 test 10 -lt "$_G_count" && break
425 rm -f conftest.in conftest.tmp conftest.nl conftest.out
428 func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
430 SED=$func_path_progs_result
434 # Unless the user overrides by setting GREP, search the path for either GNU
435 # grep, or the grep that truncates its output the least.
437 func_check_prog_grep ()
443 printf 0123456789 >conftest.in
446 cat conftest.in conftest.in >conftest.tmp
447 mv conftest.tmp conftest.in
448 cp conftest.in conftest.nl
449 echo 'GREP' >> conftest.nl
450 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
451 diff conftest.out conftest.nl >/dev/null 2>&1 || break
452 _G_count=`expr $_G_count + 1`
453 if test "$_G_count" -gt "$_G_path_prog_max"; then
454 # Best one so far, save it but keep looking for a better one
455 func_check_prog_result=$_G_path_prog
456 _G_path_prog_max=$_G_count
458 # 10*(2^10) chars as input seems more than enough
459 test 10 -lt "$_G_count" && break
461 rm -f conftest.in conftest.tmp conftest.nl conftest.out
464 func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
465 GREP=$func_path_progs_result
469 ## ------------------------------- ##
470 ## User overridable command paths. ##
471 ## ------------------------------- ##
473 # All uppercase variable names are used for environment variables. These
474 # variables can be overridden by the user before calling a script that
475 # uses them if a suitable command of that name is not already available
476 # in the command search PATH.
479 : ${ECHO="printf %s\n"}
480 : ${EGREP="$GREP -E"}
481 : ${FGREP="$GREP -F"}
487 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
490 ## -------------------- ##
491 ## Useful sed snippets. ##
492 ## -------------------- ##
494 sed_dirname='s|/[^/]*$||'
495 sed_basename='s|^.*/||'
497 # Sed substitution that helps us do robust quoting. It backslashifies
498 # metacharacters that are still active within double-quoted strings.
499 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
501 # Same as above, but do not quote variable references.
502 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
504 # Sed substitution that turns a string into a regex matching for the
506 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
508 # Sed substitution that converts a w32 file name or path
509 # that contains forward slashes, into one that contains
510 # (escaped) backslashes. A very naive implementation.
511 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
513 # Re-'\' parameter expansions in output of sed_double_quote_subst that
514 # were '\'-ed in input to the same. If an odd number of '\' preceded a
515 # '$' in input to sed_double_quote_subst, that '$' was protected from
516 # expansion. Since each input '\' is now two '\'s, look for any number
517 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
522 sed_double_backslash="\
525 s/^$_G_bs2$_G_dollar/$_G_bs&/
526 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
530 ## ----------------- ##
531 ## Global variables. ##
532 ## ----------------- ##
534 # Except for the global variables explicitly listed below, the following
535 # functions in the '^func_' namespace, and the '^require_' namespace
536 # variables initialised in the 'Resource management' section, sourcing
537 # this file will not pollute your global namespace with anything
538 # else. There's no portable way to scope variables in Bourne shell
539 # though, so actually running these functions will sometimes place
540 # results into a variable named after the function, and often use
541 # temporary variables in the '^_G_' namespace. If you are careful to
542 # avoid using those namespaces casually in your sourcing script, things
543 # should continue to work as you expect. And, of course, you can freely
544 # overwrite any of the functions or variables defined here before
545 # calling anything to customize them.
549 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
550 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
552 # Allow overriding, eg assuming that you follow the convention of
553 # putting '$debug_cmd' at the start of all your functions, you can get
554 # bash to show function call trace with:
556 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
557 debug_cmd=${debug_cmd-":"}
560 # By convention, finish your script with:
564 # so that you can set exit_status to non-zero if you want to indicate
565 # something went wrong during execution without actually bailing out at
566 # the point of failure.
567 exit_status=$EXIT_SUCCESS
569 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
570 # is ksh but when the shell is invoked as "sh" and the current value of
571 # the _XPG environment variable is not equal to 1 (one), the special
572 # positional parameter $0, within a function call, is the name of the
576 # The name of this program.
577 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
579 # Make sure we have an absolute progpath for reexecution:
581 [\\/]*|[A-Za-z]:\\*) ;;
583 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
584 progdir=`cd "$progdir" && pwd`
585 progpath=$progdir/$progname
589 IFS=${PATH_SEPARATOR-:}
590 for progdir in $PATH; do
592 test -x "$progdir/$progname" && break
595 test -n "$progdir" || progdir=`pwd`
596 progpath=$progdir/$progname
601 ## ----------------- ##
602 ## Standard options. ##
603 ## ----------------- ##
605 # The following options affect the operation of the functions defined
606 # below, and should be set appropriately depending on run-time para-
607 # meters passed on the command line.
613 # Categories 'all' and 'none' are always available. Append any others
614 # you will pass as the first argument to func_warning from your own
618 # By default, display warnings according to 'opt_warning_types'. Set
619 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
620 # treat the next displayed warning as a fatal error.
621 warning_func=func_warn_and_continue
623 # Set to 'all' to display all warnings, 'none' to suppress all
624 # warnings, or a space delimited list of some subset of
625 # 'warning_categories' to display only the listed warnings.
626 opt_warning_types=all
629 ## -------------------- ##
630 ## Resource management. ##
631 ## -------------------- ##
633 # This section contains definitions for functions that each ensure a
634 # particular resource (a file, or a non-empty configuration variable for
635 # example) is available, and if appropriate to extract default values
636 # from pertinent package files. Call them using their associated
637 # 'require_*' variable to ensure that they are executed, at most, once.
639 # It's entirely deliberate that calling these functions can set
640 # variables that don't obey the namespace limitations obeyed by the rest
641 # of this file, in order that that they be as useful as possible to
645 # require_term_colors
646 # -------------------
647 # Allow display of bold text on terminals that support it.
648 require_term_colors=func_require_term_colors
649 func_require_term_colors ()
654 # COLORTERM and USE_ANSI_COLORS environment variables take
655 # precedence, because most terminfo databases neglect to describe
656 # whether color sequences are supported.
657 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
659 if test 1 = "$USE_ANSI_COLORS"; then
660 # Standard ANSI escape sequences
662 tc_bold='
\e[1m'; tc_standout='
\e[7m'
663 tc_red='
\e[31m'; tc_green='
\e[32m'
664 tc_blue='
\e[34m'; tc_cyan='
\e[36m'
666 # Otherwise trust the terminfo database after all.
667 test -n "`tput sgr0 2>/dev/null`" && {
669 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
671 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
672 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
673 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
674 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
675 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
680 require_term_colors=:
684 ## ----------------- ##
685 ## Function library. ##
686 ## ----------------- ##
688 # This section contains a variety of useful functions to call in your
689 # scripts. Take note of the portable wrappers for features provided by
690 # some modern shells, which will fall back to slower equivalents on
691 # less featureful shells.
694 # func_append VAR VALUE
695 # ---------------------
696 # Append VALUE onto the existing contents of VAR.
698 # We should try to minimise forks, especially on Windows where they are
699 # unreasonably slow, so skip the feature probes when bash or zsh are
701 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
702 : ${_G_HAVE_ARITH_OP="yes"}
703 : ${_G_HAVE_XSI_OPS="yes"}
704 # The += operator was introduced in bash 3.1
705 case $BASH_VERSION in
706 [12].* | 3.0 | 3.0*) ;;
708 : ${_G_HAVE_PLUSEQ_OP="yes"}
714 # Can be empty, in which case the shell is probed, "yes" if += is
715 # useable or anything else if it does not work.
716 test -z "$_G_HAVE_PLUSEQ_OP" \
717 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
718 && _G_HAVE_PLUSEQ_OP=yes
720 if test yes = "$_G_HAVE_PLUSEQ_OP"
722 # This is an XSI compatible shell, allowing a faster implementation...
730 # ...otherwise fall back to using expr, which is often a shell builtin.
740 # func_append_quoted VAR VALUE
741 # ----------------------------
742 # Quote VALUE and append to the end of shell variable VAR, separated
744 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
745 eval 'func_append_quoted ()
749 func_quote_for_eval "$2"
750 eval "$1+=\\ \$func_quote_for_eval_result"
753 func_append_quoted ()
757 func_quote_for_eval "$2"
758 eval "$1=\$$1\\ \$func_quote_for_eval_result"
763 # func_append_uniq VAR VALUE
764 # --------------------------
765 # Append unique VALUE onto the existing contents of VAR, assuming
766 # entries are delimited by the first character of VALUE. For example:
768 # func_append_uniq options " --another-option option-argument"
770 # will only append to $options if " --another-option option-argument "
771 # is not already present somewhere in $options already (note spaces at
772 # each end implied by leading space in second argument).
777 eval _G_current_value='`$ECHO $'$1'`'
778 _G_delim=`expr "$2" : '\(.\)'`
780 case $_G_delim$_G_current_value$_G_delim in
782 *) func_append "$@" ;;
789 # Set func_arith_result to the result of evaluating TERMs.
790 test -z "$_G_HAVE_ARITH_OP" \
791 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
792 && _G_HAVE_ARITH_OP=yes
794 if test yes = "$_G_HAVE_ARITH_OP"; then
799 func_arith_result=$(( $* ))
806 func_arith_result=`expr "$@"`
813 # Set func_basename_result to FILE with everything up to and including
814 # the last / stripped.
815 if test yes = "$_G_HAVE_XSI_OPS"; then
816 # If this shell supports suffix pattern removal, then use it to avoid
817 # forking. Hide the definitions single quotes in case the shell chokes
818 # on unsupported syntax...
819 _b='func_basename_result=${1##*/}'
821 */*) func_dirname_result=${1%/*}$2 ;;
822 * ) func_dirname_result=$3 ;;
826 # ...otherwise fall back to using sed.
827 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
828 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
829 if test "X$func_dirname_result" = "X$1"; then
830 func_dirname_result=$3
832 func_append func_dirname_result "$2"
836 eval 'func_basename ()
844 # func_dirname FILE APPEND NONDIR_REPLACEMENT
845 # -------------------------------------------
846 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
847 # otherwise set result to NONDIR_REPLACEMENT.
848 eval 'func_dirname ()
856 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
857 # --------------------------------------------------------
858 # Perform func_basename and func_dirname in a single function
860 # dirname: Compute the dirname of FILE. If nonempty,
861 # add APPEND to the result, otherwise set result
862 # to NONDIR_REPLACEMENT.
863 # value returned in "$func_dirname_result"
864 # basename: Compute filename of FILE.
865 # value retuned in "$func_basename_result"
866 # For efficiency, we do not delegate to the functions above but instead
867 # duplicate the functionality here.
868 eval 'func_dirname_and_basename ()
879 # Echo program name prefixed message.
888 for _G_line in $_G_message; do
890 $ECHO "$progname: $_G_line"
896 # func_echo_all ARG...
897 # --------------------
898 # Invoke $ECHO with all args, space-separated.
905 # func_echo_infix_1 INFIX ARG...
906 # ------------------------------
907 # Echo program name, followed by INFIX on the first line, with any
908 # additional lines not showing INFIX.
917 _G_prefix="$progname: $_G_infix: "
920 # Strip color escape sequences before counting printable length
921 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
923 test -n "$_G_tc" && {
924 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
925 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
928 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
930 func_echo_infix_1_IFS=$IFS
932 for _G_line in $_G_message; do
933 IFS=$func_echo_infix_1_IFS
934 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
937 IFS=$func_echo_infix_1_IFS
943 # Echo program name prefixed message to standard error.
950 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
954 # func_fatal_error ARG...
955 # -----------------------
956 # Echo program name prefixed message to standard error, and exit.
966 # func_grep EXPRESSION FILENAME
967 # -----------------------------
968 # Check whether EXPRESSION matches any line of FILENAME, without output.
973 $GREP "$1" "$2" >/dev/null 2>&1
979 # Set func_len_result to the length of STRING. STRING may not
980 # start with a hyphen.
981 test -z "$_G_HAVE_XSI_OPS" \
983 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
984 && _G_HAVE_XSI_OPS=yes
986 if test yes = "$_G_HAVE_XSI_OPS"; then
991 func_len_result=${#1}
998 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
1003 # func_mkdir_p DIRECTORY-PATH
1004 # ---------------------------
1005 # Make sure the entire path to DIRECTORY-PATH is available.
1010 _G_directory_path=$1
1013 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
1015 # Protect directory names starting with '-'
1016 case $_G_directory_path in
1017 -*) _G_directory_path=./$_G_directory_path ;;
1020 # While some portion of DIR does not yet exist...
1021 while test ! -d "$_G_directory_path"; do
1022 # ...make a list in topmost first order. Use a colon delimited
1023 # list incase some portion of path contains whitespace.
1024 _G_dir_list=$_G_directory_path:$_G_dir_list
1026 # If the last portion added has no slash in it, the list is done
1027 case $_G_directory_path in */*) ;; *) break ;; esac
1029 # ...otherwise throw away the child directory and loop
1030 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
1032 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
1034 func_mkdir_p_IFS=$IFS; IFS=:
1035 for _G_dir in $_G_dir_list; do
1036 IFS=$func_mkdir_p_IFS
1037 # mkdir can fail with a 'File exist' error if two processes
1038 # try to create one of the directories concurrently. Don't
1039 # stop in that case!
1040 $MKDIR "$_G_dir" 2>/dev/null || :
1042 IFS=$func_mkdir_p_IFS
1044 # Bail out if we (or some other process) failed to create a directory.
1045 test -d "$_G_directory_path" || \
1046 func_fatal_error "Failed to create '$1'"
1051 # func_mktempdir [BASENAME]
1052 # -------------------------
1053 # Make a temporary directory that won't clash with other running
1054 # libtool processes, and avoids race conditions if possible. If
1055 # given, BASENAME is the basename for that directory.
1060 _G_template=${TMPDIR-/tmp}/${1-$progname}
1062 if test : = "$opt_dry_run"; then
1063 # Return a directory name, but don't create it in dry-run mode
1064 _G_tmpdir=$_G_template-$$
1067 # If mktemp works, use that first and foremost
1068 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
1070 if test ! -d "$_G_tmpdir"; then
1071 # Failing that, at least try and use $RANDOM to avoid a race
1072 _G_tmpdir=$_G_template-${RANDOM-0}$$
1074 func_mktempdir_umask=`umask`
1077 umask $func_mktempdir_umask
1080 # If we're not in dry-run mode, bomb out on failure
1081 test -d "$_G_tmpdir" || \
1082 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
1089 # func_normal_abspath PATH
1090 # ------------------------
1091 # Remove doubled-up and trailing slashes, "." path components,
1092 # and cancel out any ".." path components in PATH after making
1093 # it an absolute path.
1094 func_normal_abspath ()
1098 # These SED scripts presuppose an absolute path with a trailing slash.
1099 _G_pathcar='s|^/\([^/]*\).*$|\1|'
1100 _G_pathcdr='s|^/[^/]*||'
1101 _G_removedotparts=':dotsl
1105 _G_collapseslashes='s|/\{1,\}|/|g'
1106 _G_finalslash='s|/*$|/|'
1108 # Start from root dir and reassemble the path.
1109 func_normal_abspath_result=
1110 func_normal_abspath_tpath=$1
1111 func_normal_abspath_altnamespace=
1112 case $func_normal_abspath_tpath in
1114 # Empty path, that just means $cwd.
1115 func_stripname '' '/' "`pwd`"
1116 func_normal_abspath_result=$func_stripname_result
1119 # The next three entries are used to spot a run of precisely
1120 # two leading slashes without using negated character classes;
1121 # we take advantage of case's first-match behaviour.
1123 # Unusual form of absolute path, do nothing.
1126 # Not necessarily an ordinary path; POSIX reserves leading '//'
1127 # and for example Cygwin uses it to access remote file shares
1128 # over CIFS/SMB, so we conserve a leading double slash if found.
1129 func_normal_abspath_altnamespace=/
1132 # Absolute path, do nothing.
1135 # Relative path, prepend $cwd.
1136 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
1140 # Cancel out all the simple stuff to save iterations. We also want
1141 # the path to end with a slash for ease of parsing, so make sure
1142 # there is one (and only one) here.
1143 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1144 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
1146 # Processed it all yet?
1147 if test / = "$func_normal_abspath_tpath"; then
1148 # If we ascended to the root using ".." the result may be empty now.
1149 if test -z "$func_normal_abspath_result"; then
1150 func_normal_abspath_result=/
1154 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
1156 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1158 # Figure out what to do with it
1159 case $func_normal_abspath_tcomponent in
1161 # Trailing empty path component, ignore it.
1164 # Parent dir; strip last assembled component from result.
1165 func_dirname "$func_normal_abspath_result"
1166 func_normal_abspath_result=$func_dirname_result
1169 # Actual path component, append it.
1170 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1174 # Restore leading double-slash if one was found on entry.
1175 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1179 # func_notquiet ARG...
1180 # --------------------
1181 # Echo program name prefixed message only when not in quiet mode.
1186 $opt_quiet || func_echo ${1+"$@"}
1188 # A bug in bash halts the script if the last line of a function
1189 # fails when set -e is in force, so we need another command to
1195 # func_relative_path SRCDIR DSTDIR
1196 # --------------------------------
1197 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1198 func_relative_path ()
1202 func_relative_path_result=
1203 func_normal_abspath "$1"
1204 func_relative_path_tlibdir=$func_normal_abspath_result
1205 func_normal_abspath "$2"
1206 func_relative_path_tbindir=$func_normal_abspath_result
1208 # Ascend the tree starting from libdir
1210 # check if we have found a prefix of bindir
1211 case $func_relative_path_tbindir in
1212 $func_relative_path_tlibdir)
1213 # found an exact match
1214 func_relative_path_tcancelled=
1217 $func_relative_path_tlibdir*)
1218 # found a matching prefix
1219 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1220 func_relative_path_tcancelled=$func_stripname_result
1221 if test -z "$func_relative_path_result"; then
1222 func_relative_path_result=.
1227 func_dirname $func_relative_path_tlibdir
1228 func_relative_path_tlibdir=$func_dirname_result
1229 if test -z "$func_relative_path_tlibdir"; then
1230 # Have to descend all the way to the root!
1231 func_relative_path_result=../$func_relative_path_result
1232 func_relative_path_tcancelled=$func_relative_path_tbindir
1235 func_relative_path_result=../$func_relative_path_result
1240 # Now calculate path; take care to avoid doubling-up slashes.
1241 func_stripname '' '/' "$func_relative_path_result"
1242 func_relative_path_result=$func_stripname_result
1243 func_stripname '/' '/' "$func_relative_path_tcancelled"
1244 if test -n "$func_stripname_result"; then
1245 func_append func_relative_path_result "/$func_stripname_result"
1248 # Normalisation. If bindir is libdir, return '.' else relative path.
1249 if test -n "$func_relative_path_result"; then
1250 func_stripname './' '' "$func_relative_path_result"
1251 func_relative_path_result=$func_stripname_result
1254 test -n "$func_relative_path_result" || func_relative_path_result=.
1260 # func_quote_for_eval ARG...
1261 # --------------------------
1262 # Aesthetically quote ARGs to be evaled later.
1263 # This function returns two values:
1264 # i) func_quote_for_eval_result
1265 # double-quoted, suitable for a subsequent eval
1266 # ii) func_quote_for_eval_unquoted_result
1267 # has all characters that are still active within double
1268 # quotes backslashified.
1269 func_quote_for_eval ()
1273 func_quote_for_eval_unquoted_result=
1274 func_quote_for_eval_result=
1275 while test 0 -lt $#; do
1278 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1280 _G_unquoted_arg=$1 ;;
1282 if test -n "$func_quote_for_eval_unquoted_result"; then
1283 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1285 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1288 case $_G_unquoted_arg in
1289 # Double-quote args containing shell metacharacters to delay
1290 # word splitting, command substitution and variable expansion
1291 # for a subsequent eval.
1292 # Many Bourne shells cannot handle close brackets correctly
1293 # in scan sets, so we specify it separately.
1294 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1295 _G_quoted_arg=\"$_G_unquoted_arg\"
1298 _G_quoted_arg=$_G_unquoted_arg
1302 if test -n "$func_quote_for_eval_result"; then
1303 func_append func_quote_for_eval_result " $_G_quoted_arg"
1305 func_append func_quote_for_eval_result "$_G_quoted_arg"
1312 # func_quote_for_expand ARG
1313 # -------------------------
1314 # Aesthetically quote ARG to be evaled later; same as above,
1315 # but do not quote variable references.
1316 func_quote_for_expand ()
1322 _G_arg=`$ECHO "$1" | $SED \
1323 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1329 # Double-quote args containing shell metacharacters to delay
1330 # word splitting and command substitution for a subsequent eval.
1331 # Many Bourne shells cannot handle close brackets correctly
1332 # in scan sets, so we specify it separately.
1333 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1338 func_quote_for_expand_result=$_G_arg
1342 # func_stripname PREFIX SUFFIX NAME
1343 # ---------------------------------
1344 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1345 # PREFIX and SUFFIX must not contain globbing or regex special
1346 # characters, hashes, percent signs, but SUFFIX may contain a leading
1347 # dot (in which case that matches only a dot).
1348 if test yes = "$_G_HAVE_XSI_OPS"; then
1349 eval 'func_stripname ()
1353 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1354 # positional parameters, so assign one to ordinary variable first.
1355 func_stripname_result=$3
1356 func_stripname_result=${func_stripname_result#"$1"}
1357 func_stripname_result=${func_stripname_result%"$2"}
1365 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1366 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1372 # func_show_eval CMD [FAIL_EXP]
1373 # -----------------------------
1374 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1375 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1376 # is given, then evaluate it.
1382 _G_fail_exp=${2-':'}
1384 func_quote_for_expand "$_G_cmd"
1385 eval "func_notquiet $func_quote_for_expand_result"
1390 if test 0 -ne "$_G_status"; then
1391 eval "(exit $_G_status); $_G_fail_exp"
1397 # func_show_eval_locale CMD [FAIL_EXP]
1398 # ------------------------------------
1399 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1400 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1401 # is given, then evaluate it. Use the saved locale for evaluation.
1402 func_show_eval_locale ()
1407 _G_fail_exp=${2-':'}
1410 func_quote_for_expand "$_G_cmd"
1411 eval "func_echo $func_quote_for_expand_result"
1415 eval "$_G_user_locale
1418 eval "$_G_safe_locale"
1419 if test 0 -ne "$_G_status"; then
1420 eval "(exit $_G_status); $_G_fail_exp"
1428 # Turn $1 into a string suitable for a shell variable name.
1429 # Result is stored in $func_tr_sh_result. All characters
1430 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1431 # if $1 begins with a digit, a '_' is prepended as well.
1437 [0-9]* | *[!a-zA-Z0-9_]*)
1438 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1441 func_tr_sh_result=$1
1447 # func_verbose ARG...
1448 # -------------------
1449 # Echo program name prefixed message in verbose mode only.
1454 $opt_verbose && func_echo "$*"
1460 # func_warn_and_continue ARG...
1461 # -----------------------------
1462 # Echo program name prefixed warning message to standard error.
1463 func_warn_and_continue ()
1467 $require_term_colors
1469 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1473 # func_warning CATEGORY ARG...
1474 # ----------------------------
1475 # Echo program name prefixed warning message to standard error. Warning
1476 # messages can be filtered according to CATEGORY, where this function
1477 # elides messages where CATEGORY is not listed in the global variable
1478 # 'opt_warning_types'.
1483 # CATEGORY must be in the warning_categories list!
1484 case " $warning_categories " in
1486 *) func_internal_error "invalid warning category '$1'" ;;
1492 case " $opt_warning_types " in
1493 *" $_G_category "*) $warning_func ${1+"$@"} ;;
1498 # func_sort_ver VER1 VER2
1499 # -----------------------
1500 # 'sort -V' is not generally available.
1501 # Note this deviates from the version comparison in automake
1502 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1503 # but this should suffice as we won't be specifying old
1504 # version formats or redundant trailing .0 in bootstrap.conf.
1505 # If we did want full compatibility then we should probably
1506 # use m4_version_compare from autoconf.
1511 printf '%s\n%s\n' "$1" "$2" \
1512 | 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
1515 # func_lt_ver PREV CURR
1516 # ---------------------
1517 # Return true if PREV and CURR are in the correct order according to
1518 # func_sort_ver, otherwise false. Use it like this:
1520 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1525 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1530 # mode: shell-script
1532 # eval: (add-hook 'before-save-hook 'time-stamp)
1533 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1534 # time-stamp-time-zone: "UTC"
1538 # Set a version string for this script.
1539 scriptversion=2014-01-07.03; # UTC
1541 # A portable, pluggable option parser for Bourne shell.
1542 # Written by Gary V. Vaughan, 2010
1544 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
1545 # This is free software; see the source for copying conditions. There is NO
1546 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1548 # This program is free software: you can redistribute it and/or modify
1549 # it under the terms of the GNU General Public License as published by
1550 # the Free Software Foundation, either version 3 of the License, or
1551 # (at your option) any later version.
1553 # This program is distributed in the hope that it will be useful,
1554 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1555 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1556 # GNU General Public License for more details.
1558 # You should have received a copy of the GNU General Public License
1559 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1561 # Please report bugs or propose patches to gary@gnu.org.
1568 # This file is a library for parsing options in your shell scripts along
1569 # with assorted other useful supporting features that you can make use
1572 # For the simplest scripts you might need only:
1575 # . relative/path/to/funclib.sh
1576 # . relative/path/to/options-parser
1578 # func_options ${1+"$@"}
1579 # eval set dummy "$func_options_result"; shift
1580 # ...rest of your script...
1582 # In order for the '--version' option to work, you will need to have a
1583 # suitably formatted comment like the one at the top of this file
1584 # starting with '# Written by ' and ending with '# warranty; '.
1586 # For '-h' and '--help' to work, you will also need a one line
1587 # description of your script's purpose in a comment directly above the
1588 # '# Written by ' line, like the one at the top of this file.
1590 # The default options also support '--debug', which will turn on shell
1591 # execution tracing (see the comment above debug_cmd below for another
1592 # use), and '--verbose' and the func_verbose function to allow your script
1593 # to display verbose messages only when your user has specified
1596 # After sourcing this file, you can plug processing for additional
1597 # options by amending the variables from the 'Configuration' section
1598 # below, and following the instructions in the 'Option parsing'
1599 # section further down.
1601 ## -------------- ##
1602 ## Configuration. ##
1603 ## -------------- ##
1605 # You should override these variables in your script after sourcing this
1606 # file so that they reflect the customisations you have added to the
1609 # The usage line for option parsing errors and the start of '-h' and
1610 # '--help' output messages. You can embed shell variables for delayed
1611 # expansion at the time the message is displayed, but you will need to
1612 # quote other shell meta-characters carefully to prevent them being
1613 # expanded when the contents are evaled.
1614 usage='$progpath [OPTION]...'
1616 # Short help message in response to '-h' and '--help'. Add to this or
1617 # override it after sourcing this library to reflect the full set of
1618 # options your script accepts.
1620 --debug enable verbose shell tracing
1621 -W, --warnings=CATEGORY
1622 report the warnings falling in CATEGORY [all]
1623 -v, --verbose verbosely report processing
1624 --version print version information and exit
1625 -h, --help print short or long help message and exit
1628 # Additional text appended to 'usage_message' in response to '--help'.
1630 Warning categories include:
1631 'all' show all warnings
1632 'none' turn off all the warnings
1633 'error' warnings are treated as fatal errors"
1635 # Help message printed before fatal option parsing errors.
1636 fatal_help="Try '\$progname --help' for more information."
1640 ## ------------------------- ##
1641 ## Hook function management. ##
1642 ## ------------------------- ##
1644 # This section contains functions for adding, removing, and running hooks
1645 # to the main code. A hook is just a named list of of function, that can
1646 # be run in order later on.
1648 # func_hookable FUNC_NAME
1649 # -----------------------
1650 # Declare that FUNC_NAME will run hooks added with
1651 # 'func_add_hook FUNC_NAME ...'.
1656 func_append hookable_fns " $1"
1660 # func_add_hook FUNC_NAME HOOK_FUNC
1661 # ---------------------------------
1662 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
1663 # first have been declared "hookable" by a call to 'func_hookable'.
1668 case " $hookable_fns " in
1670 *) func_fatal_error "'$1' does not accept hook functions." ;;
1673 eval func_append ${1}_hooks '" $2"'
1677 # func_remove_hook FUNC_NAME HOOK_FUNC
1678 # ------------------------------------
1679 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1684 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1688 # func_run_hooks FUNC_NAME [ARG]...
1689 # ---------------------------------
1690 # Run all hook functions registered to FUNC_NAME.
1691 # It is assumed that the list of hook functions contains nothing more
1692 # than a whitespace-delimited list of legal shell function names, and
1693 # no effort is wasted trying to catch shell meta-characters or preserve
1699 case " $hookable_fns " in
1701 *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1704 eval _G_hook_fns=\$$1_hooks; shift
1706 for _G_hook in $_G_hook_fns; do
1707 eval $_G_hook '"$@"'
1709 # store returned options list back into positional
1710 # parameters for next 'cmd' execution.
1711 eval _G_hook_result=\$${_G_hook}_result
1712 eval set dummy "$_G_hook_result"; shift
1715 func_quote_for_eval ${1+"$@"}
1716 func_run_hooks_result=$func_quote_for_eval_result
1721 ## --------------- ##
1722 ## Option parsing. ##
1723 ## --------------- ##
1725 # In order to add your own option parsing hooks, you must accept the
1726 # full positional parameter list in your hook function, remove any
1727 # options that you action, and then pass back the remaining unprocessed
1728 # options in '<hooked_function_name>_result', escaped suitably for
1729 # 'eval'. Like this:
1731 # my_options_prep ()
1735 # # Extend the existing usage message.
1736 # usage_message=$usage_message'
1737 # -s, --silent don'\''t print informational messages
1740 # func_quote_for_eval ${1+"$@"}
1741 # my_options_prep_result=$func_quote_for_eval_result
1743 # func_add_hook func_options_prep my_options_prep
1746 # my_silent_option ()
1750 # # Note that for efficiency, we parse as many options as we can
1751 # # recognise in a loop before passing the remainder back to the
1752 # # caller on the first unrecognised argument we encounter.
1753 # while test $# -gt 0; do
1756 # --silent|-s) opt_silent=: ;;
1757 # # Separate non-argument short options:
1758 # -s*) func_split_short_opt "$_G_opt"
1759 # set dummy "$func_split_short_opt_name" \
1760 # "-$func_split_short_opt_arg" ${1+"$@"}
1763 # *) set dummy "$_G_opt" "$*"; shift; break ;;
1767 # func_quote_for_eval ${1+"$@"}
1768 # my_silent_option_result=$func_quote_for_eval_result
1770 # func_add_hook func_parse_options my_silent_option
1773 # my_option_validation ()
1777 # $opt_silent && $opt_verbose && func_fatal_help "\
1778 # '--silent' and '--verbose' options are mutually exclusive."
1780 # func_quote_for_eval ${1+"$@"}
1781 # my_option_validation_result=$func_quote_for_eval_result
1783 # func_add_hook func_validate_options my_option_validation
1785 # You'll alse need to manually amend $usage_message to reflect the extra
1786 # options you parse. It's preferable to append if you can, so that
1787 # multiple option parsing hooks can be added safely.
1790 # func_options [ARG]...
1791 # ---------------------
1792 # All the functions called inside func_options are hookable. See the
1793 # individual implementations for details.
1794 func_hookable func_options
1799 func_options_prep ${1+"$@"}
1800 eval func_parse_options \
1801 ${func_options_prep_result+"$func_options_prep_result"}
1802 eval func_validate_options \
1803 ${func_parse_options_result+"$func_parse_options_result"}
1805 eval func_run_hooks func_options \
1806 ${func_validate_options_result+"$func_validate_options_result"}
1808 # save modified positional parameters for caller
1809 func_options_result=$func_run_hooks_result
1813 # func_options_prep [ARG]...
1814 # --------------------------
1815 # All initialisations required before starting the option parse loop.
1816 # Note that when calling hook functions, we pass through the list of
1817 # positional parameters. If a hook function modifies that list, and
1818 # needs to propogate that back to rest of this script, then the complete
1819 # modified list must be put in 'func_run_hooks_result' before
1821 func_hookable func_options_prep
1822 func_options_prep ()
1830 func_run_hooks func_options_prep ${1+"$@"}
1832 # save modified positional parameters for caller
1833 func_options_prep_result=$func_run_hooks_result
1837 # func_parse_options [ARG]...
1838 # ---------------------------
1839 # The main option parsing loop.
1840 func_hookable func_parse_options
1841 func_parse_options ()
1845 func_parse_options_result=
1847 # this just eases exit handling
1848 while test $# -gt 0; do
1849 # Defer to hook functions for initial option parsing, so they
1850 # get priority in the event of reusing an option name.
1851 func_run_hooks func_parse_options ${1+"$@"}
1853 # Adjust func_parse_options positional parameters to match
1854 eval set dummy "$func_run_hooks_result"; shift
1856 # Break out of the loop if we already parsed every option.
1857 test $# -gt 0 || break
1862 --debug|-x) debug_cmd='set -x'
1863 func_echo "enabling shell trace mode"
1867 --no-warnings|--no-warning|--no-warn)
1868 set dummy --warnings none ${1+"$@"}
1872 --warnings|--warning|-W)
1873 test $# = 0 && func_missing_arg $_G_opt && break
1874 case " $warning_categories $1" in
1876 # trailing space prevents matching last $1 above
1877 func_append_uniq opt_warning_types " $1"
1880 opt_warning_types=$warning_categories
1883 opt_warning_types=none
1887 opt_warning_types=$warning_categories
1888 warning_func=func_fatal_error
1892 "unsupported warning category: '$1'"
1898 --verbose|-v) opt_verbose=: ;;
1899 --version) func_version ;;
1900 -\?|-h) func_usage ;;
1901 --help) func_help ;;
1903 # Separate optargs to long options (plugins may need this):
1904 --*=*) func_split_equals "$_G_opt"
1905 set dummy "$func_split_equals_lhs" \
1906 "$func_split_equals_rhs" ${1+"$@"}
1910 # Separate optargs to short options:
1912 func_split_short_opt "$_G_opt"
1913 set dummy "$func_split_short_opt_name" \
1914 "$func_split_short_opt_arg" ${1+"$@"}
1918 # Separate non-argument short options:
1920 func_split_short_opt "$_G_opt"
1921 set dummy "$func_split_short_opt_name" \
1922 "-$func_split_short_opt_arg" ${1+"$@"}
1927 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
1928 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1932 # save modified positional parameters for caller
1933 func_quote_for_eval ${1+"$@"}
1934 func_parse_options_result=$func_quote_for_eval_result
1938 # func_validate_options [ARG]...
1939 # ------------------------------
1940 # Perform any sanity checks on option settings and/or unconsumed
1942 func_hookable func_validate_options
1943 func_validate_options ()
1947 # Display all warnings if -W was not given.
1948 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1950 func_run_hooks func_validate_options ${1+"$@"}
1952 # Bail if the options were screwed!
1953 $exit_cmd $EXIT_FAILURE
1955 # save modified positional parameters for caller
1956 func_validate_options_result=$func_run_hooks_result
1961 ## ----------------- ##
1962 ## Helper functions. ##
1963 ## ----------------- ##
1965 # This section contains the helper functions used by the rest of the
1966 # hookable option parser framework in ascii-betical order.
1969 # func_fatal_help ARG...
1970 # ----------------------
1971 # Echo program name prefixed message to standard error, followed by
1972 # a help hint, and exit.
1977 eval \$ECHO \""Usage: $usage"\"
1978 eval \$ECHO \""$fatal_help"\"
1979 func_error ${1+"$@"}
1986 # Echo long help message to standard output and exit.
1992 $ECHO "$long_help_message"
1997 # func_missing_arg ARGNAME
1998 # ------------------------
1999 # Echo program name prefixed message to standard error and set global
2005 func_error "Missing argument for '$1'."
2010 # func_split_equals STRING
2011 # ------------------------
2012 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
2013 # splitting STRING at the '=' sign.
2014 test -z "$_G_HAVE_XSI_OPS" \
2016 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
2017 && _G_HAVE_XSI_OPS=yes
2019 if test yes = "$_G_HAVE_XSI_OPS"
2021 # This is an XSI compatible shell, allowing a faster implementation...
2022 eval 'func_split_equals ()
2026 func_split_equals_lhs=${1%%=*}
2027 func_split_equals_rhs=${1#*=}
2028 test "x$func_split_equals_lhs" = "x$1" \
2029 && func_split_equals_rhs=
2032 # ...otherwise fall back to using expr, which is often a shell builtin.
2033 func_split_equals ()
2037 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
2038 func_split_equals_rhs=
2039 test "x$func_split_equals_lhs" = "x$1" \
2040 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
2042 fi #func_split_equals
2045 # func_split_short_opt SHORTOPT
2046 # -----------------------------
2047 # Set func_split_short_opt_name and func_split_short_opt_arg shell
2048 # variables after splitting SHORTOPT after the 2nd character.
2049 if test yes = "$_G_HAVE_XSI_OPS"
2051 # This is an XSI compatible shell, allowing a faster implementation...
2052 eval 'func_split_short_opt ()
2056 func_split_short_opt_arg=${1#??}
2057 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
2060 # ...otherwise fall back to using expr, which is often a shell builtin.
2061 func_split_short_opt ()
2065 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
2066 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
2068 fi #func_split_short_opt
2073 # Echo short help message to standard output and exit.
2079 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
2084 # func_usage_message
2085 # ------------------
2086 # Echo short help message to standard output.
2087 func_usage_message ()
2091 eval \$ECHO \""Usage: $usage"\"
2098 /^Written by/q' < "$progpath"
2100 eval \$ECHO \""$usage_message"\"
2106 # Echo version message to standard output and exit.
2111 printf '%s\n' "$progname $scriptversion"
2121 /^# Written by /,/# warranty; / {
2124 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
2131 /^warranty; /q' < "$progpath"
2138 # mode: shell-script
2140 # eval: (add-hook 'before-save-hook 'time-stamp)
2141 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2142 # time-stamp-time-zone: "UTC"
2146 # Extract macro arguments from autotools input with GNU M4.
2147 # Written by Gary V. Vaughan, 2010
2149 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
2150 # This is free software; see the source for copying conditions. There is NO
2151 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2153 # Make sure we've evaluated scripts we depend on.
2154 test -z "$progpath" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/funclib.sh
2155 test extract-trace = "$progname" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/options-parser
2157 # Set a version string.
2158 scriptversion=2015-01-20.17; # UTC
2160 # This program is free software: you can redistribute it and/or modify
2161 # it under the terms of the GNU General Public License as published by
2162 # the Free Software Foundation, either version 3 of the License, or
2163 # (at your option) any later version.
2165 # This program is distributed in the hope that it will be useful,
2166 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2167 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2168 # GNU General Public License for more details.
2170 # You should have received a copy of the GNU General Public License
2171 # along with this program. If not, see <http://www.gnu.org/licenses/>.
2173 # Please report bugs or propose patches to gary@gnu.org.
2180 # Run './extract-trace --help' for help with using this script from the
2183 # Or source first 'options-parser' and then this file into your own
2184 # scripts in order to make use of the function and variable framework
2185 # they define, and also to avoid the overhead of forking to run this
2186 # script in its own process on every call.
2190 ## ----------------- ##
2191 ## Helper functions. ##
2192 ## ----------------- ##
2194 # This section contains the helper functions used by the rest of
2198 # func_autoconf_configure MAYBE-CONFIGURE-FILE
2199 # --------------------------------------------
2200 # Ensure that MAYBE-CONFIGURE-FILE is the name of a file in the current
2201 # directory that contains an uncommented call to AC_INIT.
2202 func_autoconf_configure ()
2212 # If we were passed a genuine file, make sure it calls AC_INIT.
2214 && _G_ac_init=`$SED "$_G_sed_no_comment" "$1" |$GREP AC_INIT`
2216 # Otherwise it is not a genuine Autoconf input file.
2217 test -n "$_G_ac_init"
2220 test 0 -ne "$_G_status" \
2221 && func_verbose "'$1' not using Autoconf"
2227 # func_tool_version_output CMD [FATAL-ERROR-MSG]
2228 # ----------------------------------------------
2229 # Attempt to run 'CMD --version', discarding errors. The output can be
2230 # ignored by redirecting stdout, and this function used simply to test
2231 # whether the command exists and exits normally when passed a
2232 # '--version' argument.
2233 # When FATAL-ERROR-MSG is given, then this function will display the
2234 # message and exit if running 'CMD --version' returns a non-zero exit
2236 func_tool_version_output ()
2241 _G_fatal_error_msg=$2
2243 # Some tools, like 'git2cl' produce thousands of lines of output
2244 # unless stdin is /dev/null - in that case we want to return
2245 # successfully without saving all of that output. Other tools,
2246 # such as 'help2man' exit with a non-zero status when stdin comes
2247 # from /dev/null, so we re-execute without /dev/null if that
2248 # happens. This means that occasionally, the output from both calls
2249 # ends up in the result, but the alternative would be to discard the
2250 # output from one call, and hope the other produces something useful.
2251 { $_G_cmd --version </dev/null || $_G_cmd --version; } 2>/dev/null
2254 test 0 -ne "$_G_status" && test -n "$_G_fatal_error_msg" \
2255 && func_fatal_error "$_G_fatal_error_msg"
2261 # func_tool_version_number CMD [FATAL-ERROR-MSG]
2262 # ----------------------------------------------
2263 # Pass arguments to func_tool_version_output, but set
2264 # $func_tool_version_number_result to the last dot delimited digit string
2265 # on the first line of output.
2266 func_tool_version_number ()
2270 _G_verout=`func_tool_version_output "$@"`
2273 # A version number starts with a digit following a space on the first
2274 # line of output from `--version`.
2275 _G_verout=`echo "$_G_verout" |sed 1q`
2276 if test -n "$_G_verout"; then
2277 _G_vernum=`expr "$_G_verout" : '.* \([0-9][^ ]*\)'`
2280 if test -n "$_G_vernum"; then
2281 printf '%s\n' "$_G_vernum"
2283 printf '%s\n' "$_G_verout"
2290 # func_find_tool ENVVAR NAMES...
2291 # ------------------------------
2292 # Search for a required program. Use the value of ENVVAR, if set,
2293 # otherwise find the first of the NAMES that can be run (i.e.,
2294 # supports --version). If found, set ENVVAR to the program name,
2300 _G_find_tool_envvar=$1
2302 _G_find_tool_names=$@
2303 eval "_G_find_tool_res=\$$_G_find_tool_envvar"
2304 if test -n "$_G_find_tool_res"; then
2305 _G_find_tool_error_prefix="\$$find_tool_envvar: "
2311 _G_find_tool_save_IFS=$IFS
2312 IFS=${PATH_SEPARATOR-:}
2313 for _G_dir in $PATH; do
2314 IFS=$_G_find_tool_save_IFS
2315 _G_progpath=$_G_dir/$_G_prog
2316 test -r "$_G_progpath" && {
2317 _G_curver=`func_tool_version_number $_G_progpath`
2318 case $_G_bestver,$_G_curver in
2320 # first non--version responsive prog sticks!
2321 test -n "$_G_progpath" || _G_find_tool_res=$_G_progpath
2324 # first --version responsive prog beats non--version responsive!
2325 _G_find_tool_res=$_G_progpath
2326 _G_bestver=$_G_curver
2329 # another --version responsive prog must be newer to beat previous one!
2330 test "x$_G_curver" = "x$_G_bestver" \
2331 || func_lt_ver "$_G_curver" "$_G_bestver" \
2333 _G_find_tool_res=$_G_progpath
2334 _G_bestver=$_G_curver
2340 IFS=$_G_find_tool_save_IFS
2343 if test -n "$_G_find_tool_res"; then
2344 func_tool_version_number >/dev/null $_G_find_tool_res "\
2345 ${_G_find_tool_error_prefix}Cannot run '$_G_find_tool_res --version'"
2347 # Make sure the result is exported to the environment for children
2349 eval "$_G_find_tool_envvar=\$_G_find_tool_res"
2350 eval "export $_G_find_tool_envvar"
2353 One of these is required:
2354 $_G_find_tool_names"
2360 ## -------------------- ##
2361 ## Resource management. ##
2362 ## -------------------- ##
2364 # This section contains definitions for functions that each ensure a
2365 # particular resource (a file, or a non-empty configuration variable for
2366 # example) is available, and if appropriate to extract default values
2367 # from pertinent package files. Where a variable already has a non-
2368 # empty value (as set by the package's 'bootstrap.conf'), that value is
2369 # used in preference to deriving the default. Call them using their
2370 # associated 'require_*' variable to ensure that they are executed, at
2373 # It's entirely deliberate that calling these functions can set
2374 # variables that don't obey the namespace limitations obeyed by the rest
2375 # of this file, in order that that they be as useful as possible to
2379 # require_configure_ac
2380 # --------------------
2381 # Ensure that there is a 'configure.ac' or 'configure.in' file in the
2382 # current directory that contains an uncommented call to AC_INIT, and
2383 # that '$configure_ac' contains its name.
2384 require_configure_ac=func_require_configure_ac
2385 func_require_configure_ac ()
2389 test -z "$configure_ac" \
2390 && func_autoconf_configure configure.ac && configure_ac=configure.ac
2391 test -z "$configure_ac" \
2392 && func_autoconf_configure configure.in && configure_ac=configure.in
2393 test -z "$configure_ac" \
2394 || func_verbose "found '$configure_ac'"
2396 require_configure_ac=:
2402 # Search for GNU M4, and export it in $M4.
2403 require_gnu_m4=func_require_gnu_m4
2404 func_require_gnu_m4 ()
2409 # Find the first m4 binary that responds to --version.
2410 func_find_tool M4 gm4 gnum4 m4
2413 test -n "$M4" || func_fatal_error "\
2414 Please install GNU M4, or 'export M4=/path/to/gnu/m4'."
2416 func_verbose "export M4='$M4'"
2418 # Make sure the search result is visible to subshells
2425 ## --------------- ##
2426 ## Core functions. ##
2427 ## --------------- ##
2429 # This section contains the high level functions used when calling this
2430 # file as a script. 'func_extract_trace' is probably the only one that you
2431 # won't want to replace if you source this file into your own script.
2434 # func_extract_trace MACRO_NAMES [FILENAME]...
2435 # --------------------------------------------
2436 # set '$func_extract_trace_result' to a colon delimited list of arguments
2437 # to any of the comma separated list of MACRO_NAMES in FILENAME. If no
2438 # FILENAME is given, then '$configure_ac' is assumed.
2439 func_extract_trace ()
2443 $require_configure_ac
2446 _G_m4_traces=`$ECHO "--trace=$1" |$SED 's%,% --trace=%g'`
2447 _G_re_macros=`$ECHO "($1)" |$SED 's%,%|%g'`
2448 _G_macros="$1"; shift
2450 set dummy $configure_ac
2454 # Generate an error if the first file is missing
2457 # Sadly, we can't use 'autom4te' tracing to extract macro arguments,
2458 # because it complains about things we want to ignore at bootstrap
2459 # time - like missing m4_include files; AC_PREREQ being newer than
2460 # the installed autoconf; and returns nothing when tracing
2461 # 'AM_INIT_AUTOMAKE' when aclocal hasn't been generated yet.
2463 # The following tries to emulate a less persnickety version of (and
2464 # due to not having to wait for Perl startup on every invocation,
2465 # it's probably faster too):
2467 # autom4te --language=Autoconf --trace=$my_macro:\$% "$@"
2469 # First we give a minimal set of macro declarations to M4 to prime
2470 # it for reading Autoconf macros, while still providing some of the
2471 # functionality generally used at m4-time to supply dynamic
2472 # arguments to Autocof functions, but without following
2473 # 'm4_s?include' files.
2477 m4_define([m4_copy], [m4_define([$2], m4_defn([$1]))])
2478 m4_define([m4_rename], [m4_copy([$1], [$2])m4_undefine([$1])])
2480 # Disable these macros.
2481 m4_undefine([m4_dnl])
2482 m4_undefine([m4_include])
2483 m4_undefine([m4_m4exit])
2484 m4_undefine([m4_m4wrap])
2485 m4_undefine([m4_maketemp])
2487 # Copy and rename macros not handled by "m4 --prefix".
2488 m4_define([dnl], [m4_builtin([dnl])])
2489 m4_copy([m4_define], [m4_defun])
2490 m4_rename([m4_ifelse], [m4_if])
2491 m4_ifdef([m4_mkstemp], [m4_undefine([m4_mkstemp])])
2492 m4_rename([m4_patsubst], [m4_bpatsubst])
2493 m4_rename([m4_regexp], [m4_bregexp])
2495 # "m4sugar.mini" - useful m4-time macros for dynamic arguments.
2496 # If we discover packages that need more m4 macros defined in
2497 # order to bootstrap correctly, add them here:
2498 m4_define([m4_bmatch],
2499 [m4_if([$#], 0, [], [$#], 1, [], [$#], 2, [$2],
2500 [m4_if(m4_bregexp([$1], [$2]), -1,
2501 [$0([$1], m4_shift3($@))], [$3])])])
2502 m4_define([m4_ifndef], [m4_ifdef([$1], [$3], [$2])])
2503 m4_define([m4_ifset],
2504 [m4_ifdef([$1], [m4_ifval(m4_defn([$1]), [$2], [$3])], [$3])])
2505 m4_define([m4_require], [$1])
2506 m4_define([m4_shift3], [m4_shift(m4shift(m4shift($@)))])
2508 # "autoconf.mini" - things from autoconf macros we care about.
2509 m4_copy([m4_defun], [AC_DEFUN])
2511 # Dummy definitions for the macros we want to trace.
2512 # AM_INIT_AUTOMAKE at least produces no trace without this.
2517 for _G_macro in $_G_macros; do
2519 func_append _G_mini "AC_DEFUN([$_G_macro])$nl"
2523 # We discard M4's stdout, but the M4 trace output from reading our
2524 # "autoconf.mini" followed by any other files passed to this
2525 # function is then scanned by sed to transform it into a colon
2526 # delimited argument list assigned to a shell variable.
2527 _G_transform='s|#.*$||; s|^dnl .*$||; s| dnl .*$||;'
2529 # Unfortunately, alternation in regexp addresses doesn't work in at
2530 # least BSD (and hence Mac OS X) sed, so we have to append a capture
2531 # and print block for each traced macro to the sed transform script.
2534 for _G_macro in $_G_macros; do
2536 func_append _G_transform '
2537 /^m4trace: -1- '"$_G_macro"'/ {
2538 s|^m4trace: -1- '"$_G_macro"'[([]*||
2547 # Save the command pipeline results for further use by callers of
2549 func_extract_trace_result=`$ECHO "$_G_mini" \
2550 |$M4 -daq --prefix $_G_m4_traces - "$@" 2>&1 1>/dev/null \
2551 |$SED -n -e "$_G_transform"`
2555 # func_extract_trace_first MACRO_NAMES [FILENAME]...
2556 # --------------------------------------------------
2557 # Exactly like func_extract_trace, except that only the first argument
2558 # to the first invocation of one of the comma separated MACRO_NAMES is
2559 # returned in '$func_extract_trace_first_result'.
2560 func_extract_trace_first ()
2564 func_extract_trace ${1+"$@"}
2565 func_extract_trace_first_result=`$ECHO "$func_extract_trace_result" \
2566 |$SED -e 's|:.*$||g' -e 1q`
2570 # func_main [ARG]...
2571 # ------------------
2577 usage='$progname MACRO_NAME FILE [...]'
2580 The first argument to this program is the name of an autotools macro
2581 whose arguments you want to extract by examining the files listed in the
2582 remaining arguments using the same tool that Autoconf and Automake use,
2585 The arguments are returned separated by colons, with each traced call
2586 on a separate line.'
2588 # Option processing.
2590 eval set dummy "$func_options_result"; shift
2592 # Validate remaining non-option arguments.
2594 || func_fatal_help "not enough arguments"
2596 # Pass non-option arguments to extraction function.
2597 func_extract_trace "$@"
2600 test -n "$func_extract_trace_result" \
2601 && $ECHO "$func_extract_trace_result"
2608 ## --------------------------- ##
2609 ## Actually perform the trace. ##
2610 ## --------------------------- ##
2612 # Only call 'func_main' if this script was called directly.
2613 test extract-trace = "$progname" && func_main "$@"
2616 # mode: shell-script
2618 # eval: (add-hook 'before-save-hook 'time-stamp)
2619 # time-stamp-pattern: "20/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2620 # time-stamp-time-zone: "UTC"
2623 # Set a version string for *this* script.
2624 scriptversion=2015-01-20.17; # UTC
2627 ## ------------------- ##
2628 ## Hookable functions. ##
2629 ## ------------------- ##
2631 # After 'bootstrap.conf' has been sourced, execution proceeds by calling
2632 # 'func_bootstrap'. Wherever a function is decorated with
2633 # 'func_hookable func_name', you will find a matching 'func_run_hooks
2634 # func_name', which executes all functions added with 'func_add_hook
2635 # func_name my_func'.
2637 # You might notice that many of these functions begin with a series of
2638 # '$require_foo' lines. See the docu-comments at the start of the
2639 # 'Resource management' section for a description of what these are.
2642 # func_bootstrap [ARG]...
2643 # -----------------------
2644 # All the functions called inside func_bootstrap are hookable. See the
2645 # the individual implementations for details.
2650 # Save the current positional parameters to prevent them being
2651 # corrupted by calls to 'set' in 'func_init'.
2652 func_quote_for_eval ${1+"$@"}
2653 _G_saved_positional_parameters=$func_quote_for_eval_result
2658 # Option processing.
2659 eval func_options "$_G_saved_positional_parameters"
2661 # Post-option preparation.
2664 # Reconfigure the package.
2667 # Ensure .version is up-to-date.
2668 func_update_dotversion
2677 # Any early initialisations can be hooked to this function. Consider
2678 # whether you can hook onto 'func_prep' instead, because if you hook
2679 # any slow to execute code in here, it will also add to the time before
2680 # './bootstrap --version' can respond.
2681 func_hookable func_init
2686 func_run_hooks func_init
2692 # Function to perform preparation for remaining bootstrap process. If
2693 # your hooked code relies on the outcome of 'func_options' hook it here
2694 # rather than to 'func_init'.
2696 # All the functions called inside func_prep are hookable. See the
2697 # individual implementations for details.
2698 func_hookable func_prep
2703 $require_buildtools_uptodate
2704 $require_checkout_only_file
2706 $require_gnulib_merge_changelog
2708 # Report the results of SED and GREP searches from funclib.sh.
2709 func_verbose "GREP='$GREP'"
2710 func_verbose "SED='$SED'"
2712 # fetch update files from the translation project
2713 func_update_translations
2715 func_run_hooks func_prep
2719 # func_update_translations
2720 # ------------------------
2721 # Update package po files and translations.
2722 func_hookable func_update_translations
2723 func_update_translations ()
2731 func_update_po_files po $package || exit $?
2734 func_run_hooks func_update_translations
2741 # Reconfigure the current package by running the appropriate autotools in a
2743 func_hookable func_reconfigure
2748 $require_automake_options
2750 # Automake (without 'foreign' option) requires that NEWS & README exist.
2751 case " $automake_options " in
2759 # Ensure ChangeLog presence.
2760 if test -n "$gnulib_modules"; then
2761 func_ifcontains "$gnulib_modules" gitlog-to-changelog \
2762 func_ensure_changelog
2764 $require_gnulib_cache
2765 if $SED -n '/^gl_MODULES(\[/,/^])$/p' $gnulib_cache 2>/dev/null |
2766 func_grep_q gitlog-to-changelog
2768 func_ensure_changelog
2772 # Released 'autopoint' has the tendency to install macros that have
2773 # been obsoleted in current 'gnulib', so run this before 'gnulib-tool'.
2776 # Autoreconf runs 'aclocal' before 'libtoolize', which causes spurious
2777 # warnings if the initial 'aclocal' is confused by the libtoolized
2778 # (or worse: out-of-date) macro directory.
2781 # If you need to do anything after 'gnulib-tool' is done, but before
2782 # 'autoreconf' runs, you don't need to override this whole function,
2783 # because 'func_gnulib_tool' is hookable.
2788 func_run_hooks func_reconfigure
2794 # Run 'gnulib-tool' to fetch gnulib modules into the current package.
2796 # It's assumed that since you are using gnulib's 'bootstrap' script,
2797 # you're also using gnulib elsewhere in your package. If not, then
2798 # you can replace this function in 'bootstrap.conf' with:
2800 # func_gnulib_tool () { :; }
2802 # (although the function returns immediately if $gnulib_tool is set to
2803 # true in any case).
2804 func_hookable func_gnulib_tool
2809 $require_gnulib_tool
2812 test true = "$gnulib_tool" || {
2813 # bootstrap.conf written for gnulib bootstrap expects
2814 # gnulib_tool_option_extras to which --no-changelog is appended,
2815 # but libtool bootstrap expects you to append to gnulib_tool_options
2816 # so that you can override the --no-changelog default: make sure we
2817 # support both styles so users can migrate between them easily.
2818 gnulib_tool_all_options="$gnulib_tool_options $gnulib_tool_option_extras"
2820 if test -n "$gnulib_modules"; then
2821 $require_gnulib_cache
2822 $require_gnulib_tool_base_options
2824 gnulib_mode=--import
2826 # Try not to pick up any stale values from 'gnulib-cache.m4'.
2827 rm -f "$gnulib_cache"
2829 test -n "$gnulib_tool_base_options" \
2830 && func_append_uniq gnulib_tool_all_options " $gnulib_tool_base_options"
2831 test -n "$gnulib_mk" \
2832 && func_append_uniq gnulib_tool_all_options " --makefile-name=$gnulib_mk"
2833 test -n "$tests_base" && {
2834 func_append_uniq gnulib_tool_all_options " --tests-base=$tests_base"
2835 func_append_uniq gnulib_tool_all_options " --with-tests"
2839 # 'gnulib_modules' and others are cached in 'gnulib-cache.m4':
2840 # Use 'gnulib --update' to fetch gnulib modules.
2841 gnulib_mode=--update
2844 # Add a sensible default libtool option to gnulib_tool_options.
2845 # The embedded echo is to squash whitespace before globbing.
2846 case `echo " "$gnulib_tool_all_options" "` in
2847 *" --no-libtool "*|*" --libtool "*) ;;
2848 *) if test true = "$LIBTOOLIZE"; then
2849 func_append_uniq gnulib_tool_all_options " --no-libtool"
2851 func_append_uniq gnulib_tool_all_options " --libtool"
2856 $opt_copy || func_append_uniq gnulib_tool_all_options " --symlink"
2858 func_append_uniq gnulib_tool_all_options " $gnulib_mode"
2859 func_append gnulib_tool_all_options " $gnulib_modules"
2861 # The embedded echo is to squash whitespace before display.
2862 gnulib_cmd=`echo $gnulib_tool $gnulib_tool_all_options`
2864 func_show_eval "$gnulib_cmd" 'exit $?'
2866 # Use 'gnulib-tool --copy-file' to install non-module files.
2867 func_install_gnulib_non_module_files
2870 func_run_hooks func_gnulib_tool
2876 # Function to perform all finalisation for the bootstrap process.
2877 func_hookable func_fini
2882 func_gettext_configuration
2883 func_clean_dangling_symlinks
2884 func_clean_unused_macros
2885 func_skip_po_recommendation
2887 func_run_hooks func_fini
2889 $require_bootstrap_uptodate
2891 func_echo "Done. Now you can run './configure'."
2895 # func_gettext_configuration
2896 # --------------------------
2897 # Edit configuration values into po/Makevars.
2898 func_hookable func_gettext_configuration
2899 func_gettext_configuration ()
2905 test true = "$AUTOPOINT" || {
2906 $require_copyright_holder
2907 $require_extra_locale_categories
2908 $require_package_bugreport
2910 # Escape xgettext options for sed Makevars generation below.
2911 # We have to delete blank lines in a separate script so that we don't
2912 # append \\\ to the penultimate line, and then delete the last empty
2913 # line, which messes up the variable substitution later in this
2914 # function. Note that adding a literal \\\ requires double escaping
2915 # here, once for the execution subshell, and again for the assignment,
2916 # which is why there are actually 12 (!!) backslashes in the script.
2917 _G_xgettext_options=`echo "$xgettext_options$nl" |$SED '/^$/d' |$SED '
2919 s|$| \\\\\\\\\\\\|'`
2921 # Create gettext configuration.
2922 func_echo "Creating po/Makevars from po/Makevars.template ..."
2925 /^EXTRA_LOCALE_CATEGORIES *=/s|=.*|= '"$extra_locale_categories"'|
2926 /^COPYRIGHT_HOLDER *=/s|=.*|= '"$copyright_holder"'|
2927 /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$package_bugreport"'|
2928 /^XGETTEXT_OPTIONS *=/{
2931 '"$_G_xgettext_options"' \\\
2932 $${end_of_xgettext_options+}
2934 ' po/Makevars.template >po/Makevars || exit 1
2937 func_run_hooks func_gettext_configuration
2942 ## --------------- ##
2943 ## Core functions. ##
2944 ## --------------- ##
2946 # This section contains the main functions called from the 'Hookable
2947 # functions' (shown above), and are the ones you're most likely
2948 # to want to replace with your own implementations in 'bootstrap.conf'.
2953 # If this package uses gettext, then run 'autopoint'.
2960 test true = "$AUTOPOINT" \
2961 || func_show_eval "$AUTOPOINT --force" 'exit $?'
2967 # If this package uses libtool, then run 'libtoolize'.
2974 test true = "$LIBTOOLIZE" || {
2975 _G_libtoolize_options=
2976 $opt_copy && func_append _G_libtoolize_options " --copy"
2977 $opt_force && func_append _G_libtoolize_options " --force"
2978 $opt_verbose || func_append _G_libtoolize_options " --quiet"
2979 func_show_eval "$LIBTOOLIZE$_G_libtoolize_options" 'exit $?'
2984 # func_gnulib_tool_copy_file SRC DEST
2985 # -----------------------------------
2986 # Copy SRC, a path relative to the gnulib sub-tree, to DEST, a path
2987 # relative to the top-level source directory using gnulib-tool so that
2988 # any patches or replacements in $local_gl_dir are applied.
2989 func_gnulib_tool_copy_file ()
2993 $require_gnulib_tool
2996 if test true = "$gnulib_tool"; then
2997 # If gnulib-tool is not available (e.g. bootstrapping in a
2998 # distribution tarball), make sure that at least we have some
2999 # version of the required file already in place.
3000 test -f "$2" || func_fatal_error "\
3001 Can't find, copy or download '$2', a required
3002 gnulib supplied file, please provide the location of a
3003 complete 'gnulib' tree by setting 'gnulib_path' in your
3004 'bootstrap.conf' or with the '--gnulib-srcdir' option -
3005 or else specify the location of your 'git' binary by
3006 setting 'GIT' in the environment so that a fresh
3007 'gnulib' submodule can be cloned."
3009 $require_gnulib_copy_cmd
3011 $gnulib_copy_cmd $1 $2 2>/dev/null || {
3012 $require_gnulib_path
3014 func_error "'$gnulib_path/$1' does not exist"
3021 # func_install_gnulib_non_module_files
3022 # ------------------------------------
3023 # Get additional non-module files from gnulib, overriding existing files.
3024 func_install_gnulib_non_module_files ()
3029 $require_gnulib_tool
3031 test -n "$gnulib_non_module_files" && {
3034 for file in $gnulib_non_module_files; do
3036 */COPYING*) dest=COPYING;;
3037 */INSTALL) dest=INSTALL;;
3038 build-aux/missing) dest=
3039 func_warning settings "\
3040 Please remove build-aux/missing from gnulib_module_files in
3041 'bootstrap.conf', as it may clash with Automake's version."
3043 build-aux/*) dest=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
3047 # Be sure to show all copying errors before bailing out
3049 || func_gnulib_tool_copy_file "$file" "$dest" \
3050 || maybe_exit_cmd="exit $EXIT_FAILURE"
3058 # func_ensure_changelog
3059 # ---------------------
3060 # Even with 'gitlog-to-changelog' generated ChangeLogs, automake
3061 # will not run to completion with no ChangeLog file.
3062 func_ensure_changelog ()
3066 test -f ChangeLog && mv -f ChangeLog ChangeLog~
3068 cat >ChangeLog <<'EOT'
3069 ## ---------------------- ##
3070 ## DO NOT EDIT THIS FILE! ##
3071 ## ---------------------- ##
3073 ChangeLog is generated by gitlog-to-changelog.
3076 _G_message="creating dummy 'ChangeLog'"
3077 test -f ChangeLog~ \
3078 && func_append _G_message ' (backup in ChangeLog~)'
3079 func_verbose "$_G_message"
3087 # Without AM_INIT_AUTOMAKE([foreign]), automake will not run to
3088 # completion with no NEWS file, even though NEWS.md or NEWS.txt
3089 # is often preferable.
3096 for _G_news in NEWS.txt NEWS.md NEWS.rst; do
3097 test -f "$_G_news" && break
3100 test -f "$_G_news" && $LN_S $_G_news NEWS
3101 func_verbose "$LN_S $_G_news NEWS"
3108 # func_ensure_README
3109 # ------------------
3110 # Without AM_INIT_AUTOMAKE([foreign]), automake will not run to
3111 # completion with no README file, even though README.md or README.txt
3112 # is often preferable.
3113 func_ensure_README ()
3119 for _G_readme in README.txt README.md README.rst; do
3120 test -f "$_G_readme" && break
3123 test -f "$_G_readme" && $LN_S $_G_readme README
3124 func_verbose "$LN_S $_G_readme README"
3131 # func_autoreconf [SUBDIR]
3132 # ------------------------
3133 # Being careful not to re-run 'autopoint' or 'libtoolize', and not to
3134 # try to run 'autopoint', 'libtoolize' or 'autoheader' on packages that
3135 # don't use them, defer to 'autoreconf' for execution of the remaining
3136 # autotools to bootstrap this package.
3138 # Projects with multiple trees to reconfigure can hook another call to
3139 # this function onto func_reconfigure:
3141 # my_autoreconf_foo ()
3143 # func_autoreconf foo
3145 # func_add_hook func_reconfigure my_autoreconf_foo
3151 $require_build_aux # automake and others put files in here
3152 $require_macro_dir # aclocal and others put files in here
3154 # We ran these manually already, and autoreconf won't exec ':'
3155 save_AUTOPOINT=$AUTOPOINT; AUTOPOINT=true
3156 save_LIBTOOLIZE=$LIBTOOLIZE; LIBTOOLIZE=true
3158 _G_autoreconf_options=
3159 $opt_copy || func_append _G_autoreconf_options " --symlink"
3160 $opt_force && func_append _G_autoreconf_options " --force"
3161 $opt_verbose && func_append _G_autoreconf_options " --verbose"
3162 func_show_eval "$AUTORECONF$_G_autoreconf_options --install${1+ $1}" 'exit $?'
3164 AUTOPOINT=$save_AUTOPOINT
3165 LIBTOOLIZE=$save_LIBTOOLIZE
3169 # func_check_configuration VARNAME [CONFIGURE_MACRO]
3170 # --------------------------------------------------
3171 # Exit with a suitable diagnostic for an important configuration change
3172 # that needs to be made before bootstrap can run correctly.
3173 func_check_configuration ()
3177 $require_configure_ac
3179 eval 'test -n "$'$1'"' || {
3180 _G_error_msg="please set '$1' in 'bootstrap.conf'"
3181 if test -n "$configure_ac" && test -n "$2"; then
3182 func_append _G_error_msg "
3183 or add the following (or similar) to your '$configure_ac':
3187 func_fatal_error "$_G_error_msg"
3192 # func_clean_dangling_symlinks
3193 # ----------------------------
3194 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
3195 # gnulib-populated directories. Such .m4 files would cause aclocal to
3196 # fail. The following requires GNU find 4.2.3 or newer. Considering
3197 # the usual portability constraints of this script, that may seem a very
3198 # demanding requirement, but it should be ok. Ignore any failure,
3199 # which is fine, since this is only a convenience to help developers
3200 # avoid the relatively unusual case where a symlinked-to .m4 file is
3201 # git-removed from gnulib between successive runs of this script.
3202 func_clean_dangling_symlinks ()
3207 $require_source_base
3209 func_verbose "cleaning dangling symlinks"
3211 find "$macro_dir" "$source_base" \
3212 -depth \( -name '*.m4' -o -name '*.[ch]' \) \
3213 -type l -xtype l -delete > /dev/null 2>&1
3217 # func_clean_unused_macros
3218 # ------------------------
3219 # Autopoint can result in over-zealously adding macros into $macro_dir
3220 # even though they are not actually used, for example tests to help
3221 # build the 'intl' directory even though you have specified
3222 # 'AM_GNU_GETTEXT([external])' in your configure.ac. This function
3223 # looks removes any macro files that can be found in gnulib, but
3224 # are not 'm4_include'd by 'aclocal.m4'.
3225 func_clean_unused_macros ()
3229 $require_gnulib_path
3232 test -n "$gnulib_path" && test -f aclocal.m4 && {
3233 aclocal_m4s=`find . -name aclocal.m4 -print`
3235 # We use 'ls|grep' instead of 'ls *.m4' to avoid exceeding
3236 # command line length limits in some shells.
3237 for file in `cd "$macro_dir" && ls -1 |$GREP '\.m4$'`; do
3239 # Remove a macro file when aclocal.m4 does not m4_include it...
3240 func_grep_q 'm4_include([[]'$macro_dir/$file'])' $aclocal_m4s \
3241 || test ! -f "$gnulib_path/m4/$file" || {
3243 # ...and there is an identical file in gnulib...
3244 if func_cmp_s "$gnulib_path/m4/$file" "$macro_dir/$file"; then
3246 # ...and it's not in the precious list ('echo' is needed
3247 # here to squash whitespace for the match expression).
3248 case " "`echo $gnulib_precious`" " in
3250 *) rm -f "$macro_dir/$file"
3252 "removing unused gnulib file '$macro_dir/$file'"
3261 # func_skip_po_recommendation
3262 # ---------------------------
3263 # If there is a po directory, and '--skip-po' wasn't passed, let the
3264 # user know that they can use '--skip-po' on subsequent invocations.
3265 func_skip_po_recommendation ()
3271 || func_warning recommend "\
3272 If your pofiles are up-to-date, you can rerun bootstrap
3273 as '$progname --skip-po' to avoid redownloading."
3277 # func_update_dotversion
3278 # ----------------------
3279 # Even with 'gitlog-to-changelog' generated ChangeLogs, automake
3280 # will not run to completion with no ChangeLog file.
3281 func_update_dotversion ()
3285 test -f "$build_aux/git-version-gen" && {
3286 _G_message="updating .version"
3287 test -f .version && {
3288 mv .version .version~
3289 func_append _G_message " (backup in .version~)"
3291 func_verbose "updating .version"
3293 $build_aux/git-version-gen dummy-arg > .version
3299 ## -------------------- ##
3300 ## Resource management. ##
3301 ## -------------------- ##
3303 # This section contains definitions for functions that each ensure a
3304 # particular resource (a file, or a non-empty configuration variable for
3305 # example) is available, and if appropriate to extract default values
3306 # from pertinent package files. Where a variable already has a non-
3307 # empty value (as set by the package's 'bootstrap.conf'), that value is
3308 # used in preference to deriving the default. Call them using their
3309 # associated 'require_*' variable to ensure that they are executed, at
3313 # require_checkout_only_file
3314 # --------------------------
3315 # Bail out if this package only bootstraps properly from a repository
3317 require_checkout_only_file=func_require_checkout_only_file
3318 func_require_checkout_only_file ()
3323 test -n "$checkout_only_file" && test ! -f "$checkout_only_file" \
3324 && func_fatal_error "\
3325 Bootstrapping from a non-checked-out distribution is risky.
3326 If you wish to bootstrap anyway, use the '--force' option."
3329 require_checkout_only_file=:
3333 # require_aclocal_amflags
3334 # -----------------------
3335 # Ensure '$aclocal_amflags' has a sensible default, extracted from
3336 # 'Makefile.am' if necessary.
3337 require_aclocal_amflags=func_require_aclocal_amflags
3338 func_require_aclocal_amflags ()
3342 $require_makefile_am
3344 _G_sed_extract_aclocal_amflags='s|#.*$||
3345 /^[ ]*ACLOCAL_AMFLAGS[ ]*=/ {
3346 s|^.*=[ ]*\(.*\)|aclocal_amflags="\1"|
3350 _G_aclocal_flags_cmd=`$SED -n "$_G_sed_extract_aclocal_amflags" \
3352 eval "$_G_aclocal_flags_cmd"
3354 func_verbose "ACLOCAL_AMFLAGS='$aclocal_amflags'"
3356 require_aclocal_amflags=:
3360 # require_autoheader
3361 # ------------------
3362 # Skip autoheader if it's not needed.
3363 require_autoheader=func_require_autoheader
3364 func_require_autoheader ()
3368 test true = "$AUTOHEADER" || {
3369 func_extract_trace AC_CONFIG_HEADERS
3370 test -n "$func_extract_trace_result" \
3371 || func_extract_trace AC_CONFIG_HEADER
3373 test -n "$func_extract_trace_result" || {
3376 func_verbose "export AUTOHEADER='$AUTOHEADER'"
3378 # Make sure the search result is visible to subshells
3383 require_autoheader=:
3387 # require_automake_options
3388 # ------------------------
3389 # Extract options from AM_AUTOMAKE_INIT.
3390 require_automake_options=func_require_automake_options
3391 func_require_automake_options ()
3395 func_extract_trace AM_INIT_AUTOMAKE
3396 automake_options=$func_extract_trace_result
3398 require_automake_options=:
3404 # Skip autopoint if it's not needed.
3405 require_autopoint=func_require_autopoint
3406 func_require_autopoint ()
3410 test true = "$AUTOPOINT" || {
3411 func_extract_trace AM_GNU_GETTEXT_VERSION
3413 test -n "$func_extract_trace_result" || {
3416 func_verbose "export AUTOPOINT='$AUTOPOINT'"
3418 # Make sure the search result is visible to subshells
3427 # require_bootstrap_uptodate
3428 # --------------------------
3429 # Complain if the version of bootstrap in the gnulib directory differs
3430 # from the one we are running.
3431 require_bootstrap_uptodate=func_require_bootstrap_uptodate
3432 func_require_bootstrap_uptodate ()
3438 _G_bootstrap_sources="
3439 $build_aux/bootstrap.in
3440 $build_aux/extract-trace
3441 $build_aux/funclib.sh
3442 $build_aux/options-parser
3445 _G_missing_bootstrap_sources=false
3446 for _G_src in $_G_bootstrap_sources; do
3447 test -f "$_G_src" || _G_missing_bootstrap_sources=:
3450 if $_G_missing_bootstrap_sources; then
3451 func_warning upgrade "\
3452 Please add bootstrap to your gnulib_modules list in
3453 'bootstrap.conf', so that I can tell you when there are
3457 $build_aux/inline-source $build_aux/bootstrap.in > bootstrap.new
3459 if func_cmp_s "$progpath" bootstrap.new; then
3461 func_verbose "bootstrap script up to date"
3463 chmod 555 bootstrap.new
3464 func_warning upgrade "\
3465 An updated bootstrap script has been generated for you in
3466 'bootstrap.new'. After you've verified that you want
3467 the changes, you can update with:
3468 mv -f bootstrap.new $progname
3471 Or you can disable this check permanently by adding the
3472 following to 'bootstrap.conf':
3473 require_bootstrap_uptodate=:"
3477 require_bootstrap_uptodate=:
3483 # Ensure that '$build_aux' is set, and if it doesn't already point to an
3484 # existing directory, create one.
3485 require_build_aux=func_require_build_aux
3486 func_require_build_aux ()
3490 test -n "$build_aux" || {
3491 func_extract_trace_first AC_CONFIG_AUX_DIR
3492 build_aux=$func_extract_trace_first_result
3493 func_check_configuration build_aux \
3494 "AC_CONFIG_AUX_DIR([name of a directory for build scripts])"
3496 func_verbose "build_aux='$build_aux'"
3499 $require_vc_ignore_files
3501 # If the build_aux directory doesn't exist, create it now, and mark it
3502 # as ignored for the VCS.
3503 if test ! -d "$build_aux"; then
3504 func_show_eval "mkdir '$build_aux'"
3506 test -n "$vc_ignore_files" \
3507 || func_insert_if_absent "$build_aux" $vc_ignore_files
3514 # require_buildreq_autobuild
3515 # --------------------------
3516 # Try to find whether the bootstrap requires autobuild.
3517 require_buildreq_autobuild=func_require_buildreq_autobuild
3518 func_require_buildreq_autobuild ()
3524 test -f "$macro_dir/autobuild.m4" \
3525 || printf '%s\n' "$buildreq" |func_grep_q '^[ ]*autobuild' \
3527 func_extract_trace AB_INIT
3528 test -n "$func_extract_trace_result" && {
3529 func_append buildreq 'autobuild - http://josefsson.org/autobuild/
3531 func_verbose "auto-adding 'autobuild' to build requirements"
3535 require_buildreq_autobuild=:
3539 # require_buildreq_autoconf
3540 # require_buildreq_autopoint
3541 # require_buildreq_libtoolize
3542 # ---------------------------
3543 # Try to find the minimum compatible version of autoconf/libtool
3544 # required to bootstrap successfully, and add it to '$buildreq'.
3545 for tool in autoconf libtoolize autopoint; do
3547 v=require_buildreq_${tool}
3550 autoconf) m=AC_PREREQ ;;
3551 libtoolize) m=LT_PREREQ; b=libtool ;;
3552 autopoint) m=AM_GNU_GETTEXT_VERSION b=gettext ;;
3560 # The following is ignored if undefined, but might be necessary
3561 # in order for `func_find_tool` to run.
3562 ${require_'$tool'-:}
3564 printf '\''%s\n'\'' "$buildreq" |func_grep_q '\''^[ ]*'$tool\'' || {
3565 func_extract_trace '$m'
3566 _G_version=$func_extract_trace_result
3567 test -n "$_G_version" && {
3568 func_append buildreq "\
3569 '$tool' $_G_version http://www.gnu.org/s/'$b'
3572 "auto-adding '\'$tool'-$_G_version'\'' to build requirements"
3582 # require_buildreq_automake
3583 # -------------------------
3584 # Try to find the minimum compatible version of automake required to
3585 # bootstrap successfully, and add it to '$buildreq'.
3586 require_buildreq_automake=func_require_buildreq_automake
3587 func_require_buildreq_automake ()
3591 # if automake is not already listed in $buildreq...
3592 printf '%s\n' "$buildreq" |func_grep_q automake || {
3593 func_extract_trace AM_INIT_AUTOMAKE
3595 # ...and AM_INIT_AUTOMAKE is declared...
3596 test -n "$func_extract_trace_result" && {
3597 automake_version=`$ECHO "$func_extract_trace_result" \
3598 |$SED -e 's|[^0-9]*||' -e 's| .*$||'`
3599 test -n "$automake_version" || automake_version=-
3601 func_append buildreq "\
3602 automake $automake_version http://www.gnu.org/s/automake
3605 "auto-adding 'automake-$automake_version' to build requirements"
3609 require_buildreq_automake=:
3613 # require_buildreq_patch
3614 # ----------------------
3615 # Automatically add a patch build-requirement if there are diff files
3617 require_buildreq_patch=func_require_buildreq_patch
3618 func_require_buildreq_patch ()
3622 $require_local_gl_dir
3624 # This ensures PATCH is set appropriately by the time
3625 # func_check_versions enforces $buildreq.
3628 # If patch is not already listed in $buildreq...
3629 printf '%s\n' "$buildreq" |func_grep_q '^[ ]*patch' || {
3630 # The ugly find invocation is necessary to exit with non-zero
3631 # status for old find binaries that don't support -exec fully.
3632 if test ! -d "$local_gl_dir" \
3633 || find "$local_gl_dir" -name "*.diff" -exec false {} \; ; then :
3635 func_append buildreq 'patch - http://www.gnu.org/s/patch
3640 require_buildreq_patch=:
3644 # require_buildtools_uptodate
3645 # ---------------------------
3646 # Ensure all the packages listed in BUILDREQS are available on the build
3647 # machine at the minimum versions or better.
3648 require_buildtools_uptodate=func_require_buildtools_uptodate
3649 func_require_buildtools_uptodate ()
3653 $require_buildreq_autobuild
3654 $require_buildreq_autoconf
3655 $require_buildreq_automake
3656 $require_buildreq_libtoolize
3657 $require_buildreq_autopoint
3658 $require_buildreq_patch
3660 test -n "$buildreq" && {
3663 func_check_versions $buildreq
3664 $func_check_versions_result || {
3665 test -n "$buildreq_readme" \
3666 && test -f "$buildreq_readme" \
3668 $buildreq_readme explains how to obtain these prerequisite programs:
3670 func_strtable 0 11 12 36 \
3671 "Program" "Min_version" "Homepage" $buildreq
3672 func_fatal_error "$_G_error_hdr$func_strtable_result"
3676 require_buildtools_uptodate=:
3680 # require_copyright_holder
3681 # ------------------------
3682 # Ensure there is a sensible non-empty default value in '$copyright_holder'.
3683 require_copyright_holder=func_require_copyright_holder
3684 func_require_copyright_holder ()
3688 test -n "$copyright_holder" || {
3689 copyright_holder='Free Software Foundation, Inc.'
3690 func_warning settings "\
3691 Please set copyright_holder explicitly in 'bootstrap.conf';
3692 defaulting to '$copyright_holder'."
3695 require_copyright_holder=:
3701 # Ensure doc_base has a sensible value, extracted from 'gnulib-cache.m4'
3702 # if possible, otherwise letting 'gnulib-tool' pick a default.
3703 require_doc_base=func_require_doc_base
3704 func_require_doc_base ()
3708 $require_gnulib_cache
3710 test -f "$gnulib_cache" && test -z "$doc_base" && {
3711 func_extract_trace_first "gl_DOC_BASE" "$gnulib_cache"
3712 doc_base=$func_extract_trace_first_result
3714 test -n "$doc_base" && func_verbose "doc_base='$doc_base'"
3721 # require_dotgitmodules
3722 # ---------------------
3723 # Ensure we have a '.gitmodules' file, with appropriate 'gnulib' settings.
3724 require_dotgitmodules=func_require_dotgitmodules
3725 func_require_dotgitmodules ()
3731 test true = "$GIT" || {
3732 # A gnulib entry in .gitmodules always takes precedence.
3733 _G_path=`$GIT config --file .gitmodules submodule.gnulib.path 2>/dev/null`
3735 test -n "$_G_path" || {
3736 $require_vc_ignore_files
3738 func_verbose "creating '.gitmodules'"
3740 # If the .gitmodules file doesn't exist, create it now, and mark
3741 # it as ignored for the VCS.
3742 test -n "$gnulib_path" || gnulib_path=gnulib
3743 test -n "$gnulib_url" || gnulib_url=git://git.sv.gnu.org/gnulib
3746 echo '[submodule "gnulib"]'
3747 echo " path = $gnulib_path"
3748 echo " url = $gnulib_url"
3751 test -n "$vc_ignore_files" \
3752 || func_insert_if_absent ".gitmodules" $vc_ignore_files
3756 require_dotgitmodules=:
3760 # require_extra_locale_categories
3761 # -------------------------------
3762 # Ensure there is a default value in '$extra_locale_categories'
3763 require_extra_locale_categories=func_require_extra_locale_categories
3764 func_require_extra_locale_categories ()
3768 # Defaults to empty, so run with whatever value may have been set in
3770 require_extra_locale_categories=:
3776 # Ignore git if it's not available, or we're not in a git checkout tree.
3777 require_git=func_require_git
3782 $opt_skip_git && GIT=true
3784 test true = "$GIT" || {
3785 if test -d .git/.; then
3786 ($GIT --version) >/dev/null 2>&1 || GIT=true
3790 func_verbose "GIT='$GIT'"
3796 # require_gnulib_cache
3797 # --------------------
3798 # Ensure there is a non-empty default for '$gnulib_cache', and that it
3799 # names an existing file.
3800 require_gnulib_cache=func_require_gnulib_cache
3801 func_require_gnulib_cache ()
3807 test -n "$gnulib_cache" \
3808 || gnulib_cache=$macro_dir/gnulib-cache.m4
3810 func_verbose "found '$gnulib_cache'"
3812 require_gnulib_cache=:
3816 # require_gnulib_copy_cmd
3817 # -----------------------
3818 # Only calculate the options for copying files with gnulib once.
3819 require_gnulib_copy_cmd=func_require_gnulib_copy_cmd
3820 func_require_gnulib_copy_cmd ()
3824 $require_gnulib_tool
3825 $require_gnulib_tool_base_options
3827 gnulib_copy_cmd="$gnulib_tool $gnulib_tool_base_options --copy-file"
3828 $opt_copy || func_append gnulib_copy_cmd " --symlink"
3829 $opt_quiet || func_append gnulib_copy_cmd " --verbose"
3831 require_gnulib_copy_cmd=:
3835 # require_gnulib_merge_changelog
3836 # ------------------------------
3837 # See if we can use gnulib's git-merge-changelog merge driver.
3838 require_gnulib_merge_changelog=func_require_gnulib_merge_changelog
3839 func_require_gnulib_merge_changelog ()
3843 test -f ChangeLog && {
3846 func_grep_q '^\(/\|\)ChangeLog$' .gitignore || test true = "$GIT" || {
3847 if $GIT config merge.merge-changelog.driver >/dev/null; then
3849 elif (git-merge-changelog --version) >/dev/null 2>&1; then
3850 func_echo "initializing git-merge-changelog driver"
3851 $GIT config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
3852 $GIT config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
3854 func_warning recommend \
3855 "Consider installing git-merge-changelog from gnulib."
3860 require_gnulib_merge_changelog=:
3866 # Ensure gnulib_mk has a sensible value, extracted from 'gnulib-cache.m4'
3867 # if possible, otherwise letting 'gnulib-tool' pick a default.
3868 require_gnulib_mk=func_require_gnulib_mk
3869 func_require_gnulib_mk ()
3873 $require_gnulib_cache
3875 test -f "$gnulib_cache" && test -z "$gnulib_mk" && {
3876 func_extract_trace_first "gl_MAKEFILE_NAME" "$gnulib_cache"
3877 gnulib_mk=$func_extract_trace_first_result
3879 test -n "$gnulib_mk" && func_verbose "gnulib_mk='$gnulib_mk'"
3886 # require_gnulib_name
3887 # -------------------
3888 # Ensure gnulib_name has a sensible value, extracted from 'gnulib-cache.m4'
3889 # if possible, otherwise letting 'gnulib-tool' pick a default.
3890 require_gnulib_name=func_require_gnulib_name
3891 func_require_gnulib_name ()
3895 $require_gnulib_cache
3897 test -f "$gnulib_cache" && test -z "$gnulib_name" && {
3898 func_extract_trace_first "gl_LIB" "$gnulib_cache"
3899 gnulib_name=$func_extract_trace_first_result
3901 test -n "$gnulib_name" && func_verbose "gnulib_name='$gnulib_name'"
3904 require_gnulib_name=:
3908 # require_gnulib_path
3909 # require_gnulib_url
3910 # -------------------
3911 # Ensure 'gnulib_path' and 'gnulib_url' are set.
3912 require_gnulib_path=func_require_dotgitmodules_parameters
3913 require_gnulib_url=func_require_dotgitmodules_parameters
3914 func_require_dotgitmodules_parameters ()
3920 test true = "$GIT" && {
3921 # If we can't find git (or if the user specified '--skip-git'),
3922 # then use an existing gnulib directory specified with
3923 # '--gnulib-srcdir' if possible.
3924 test -n "$gnulib_path" \
3925 || test ! -x "$opt_gnulib_srcdir/gnulib-tool" \
3926 || gnulib_path=$opt_gnulib_srcdir
3930 $require_dotgitmodules
3932 test -f .gitmodules && {
3933 # Extract the parameters with sed, since git may be missing
3934 test -n "$gnulib_path" \
3935 || gnulib_path=`$SED -e '/^.submodule "gnulib".$/,${
3937 s|[ ]*||g;s|^[^=]*=||;p
3940 d' .gitmodules |$SED 1q`
3941 test -n "$gnulib_url" \
3942 || gnulib_url=`$SED -e '/^.submodule "gnulib".$/,${
3944 s|[ ]*||g;s|^[^=]*=||;p
3947 d' .gitmodules |$SED 1q`
3949 func_verbose "gnulib_path='$gnulib_path'"
3950 func_verbose "gnulib_url='$gnulib_url'"
3953 require_gnulib_path=:
3954 require_gnulib_url=:
3958 # require_gnulib_submodule
3959 # ------------------------
3960 # Ensure that there is a current gnulib submodule at '$gnulib_path'.
3961 require_gnulib_submodule=func_require_gnulib_submodule
3962 func_require_gnulib_submodule ()
3968 if test true = "$GIT"; then
3969 func_warning recommend \
3970 "No 'git' found; imported gnulib modules may be outdated."
3972 $require_gnulib_path
3975 if test -f .gitmodules && test -f "$gnulib_path/gnulib-tool"; then
3976 : All present and correct.
3978 elif test -n "$opt_gnulib_srcdir"; then
3979 # Older git can't clone into an empty directory.
3980 rmdir "$gnulib_path" 2>/dev/null
3981 func_show_eval "$GIT clone --reference '$opt_gnulib_srcdir' \
3982 '$gnulib_url' '$gnulib_path'" \
3983 || func_fatal_error "Unable to fetch gnulib submodule."
3985 # Without --gnulib-srcdir, and no existing checked out submodule, we
3986 # create a new shallow clone of the remote gnulib repository.
3988 trap func_cleanup_gnulib 1 2 13 15
3991 $GIT clone -h 2>&1 |func_grep_q -- --depth \
3992 && shallow='--depth 365'
3994 func_show_eval "$GIT clone $shallow '$gnulib_url' '$gnulib_path'" \
3997 # FIXME: Solaris /bin/sh will try to execute '-' if any of
3998 # these signals are caught after this.
4002 # Make sure we've checked out the correct revision of gnulib.
4003 func_show_eval "$GIT submodule init -- $gnulib_path" \
4004 && func_show_eval "$GIT submodule update -- $gnulib_path" \
4005 || func_fatal_error "Unable to update gnulib submodule."
4008 require_gnulib_submodule=:
4012 # require_gnulib_tool
4013 # -------------------
4014 # Ensure that '$gnulib_tool' is set, and points to an executable file,
4015 # or else fall back to using the binary 'true' if the main gnulib
4016 # files appear to have been imported already.
4017 require_gnulib_tool=func_require_gnulib_tool
4018 func_require_gnulib_tool ()
4022 test true = "$gnulib_tool" || {
4023 $require_gnulib_submodule
4024 $require_gnulib_path
4026 test -n "$gnulib_tool" \
4027 || gnulib_tool=$gnulib_path/gnulib-tool
4029 test -x "$gnulib_tool" || {
4031 func_warning recommend \
4032 "No 'gnulib-tool' found; gnulib modules may be missing."
4035 test true = "$gnulib_tool" \
4036 || func_verbose "found '$gnulib_tool'"
4039 require_gnulib_tool=:
4043 # require_gnulib_tool_base_options
4044 # --------------------------------
4045 # Ensure that '$gnulib_tool_base_options' contains all the base options
4046 # required according to user configuration from bootstrap.conf.
4047 require_gnulib_tool_base_options=func_require_gnulib_tool_base_options
4048 func_require_gnulib_tool_base_options ()
4052 $require_gnulib_tool
4054 gnulib_tool_base_options=
4056 test true = "$gnulib_tool" || {
4057 # 'gnulib_modules' and others are maintained in 'bootstrap.conf':
4058 # Use 'gnulib --import' to fetch gnulib modules.
4060 test -n "$build_aux" \
4061 && func_append_uniq gnulib_tool_base_options " --aux-dir=$build_aux"
4063 test -n "$macro_dir" \
4064 && func_append_uniq gnulib_tool_base_options " --m4-base=$macro_dir"
4066 test -n "$doc_base" \
4067 && func_append_uniq gnulib_tool_base_options " --doc-base=$doc_base"
4068 $require_gnulib_name
4069 test -n "$gnulib_name" \
4070 && func_append_uniq gnulib_tool_base_options " --lib=$gnulib_name"
4071 $require_local_gl_dir
4072 test -n "$local_gl_dir" \
4073 && func_append_uniq gnulib_tool_base_options " --local-dir=$local_gl_dir"
4074 $require_source_base
4075 test -n "$source_base" \
4076 && func_append_uniq gnulib_tool_base_options " --source-base=$source_base"
4079 require_gnulib_tool_base_options=:
4083 # require_libtoolize
4084 # ------------------
4085 # Skip libtoolize if it's not needed.
4086 require_libtoolize=func_require_libtoolize
4087 func_require_libtoolize ()
4091 # Unless we're not searching for libtool use by this package, set
4092 # LIBTOOLIZE to true if none of 'LT_INIT', 'AC_PROG_LIBTOOL' and
4093 # 'AM_PROG_LIBTOOL' are used in configure.
4094 test true = "$LIBTOOLIZE" || {
4095 func_extract_trace LT_INIT
4096 test -n "$func_extract_trace_result" || func_extract_trace AC_PROG_LIBTOOL
4097 test -n "$func_extract_trace_result" || func_extract_trace AM_PROG_LIBTOOL
4098 test -n "$func_extract_trace_result" || LIBTOOLIZE=true
4101 test -n "$LIBTOOLIZE" || {
4102 # Find libtoolize, named glibtoolize in Mac Ports, but prefer
4103 # user-installed libtoolize to ancient glibtoolize shipped by
4104 # Apple with Mac OS X when Mac Ports is not installed.
4105 func_find_tool LIBTOOLIZE libtoolize glibtoolize
4108 test -n "$LIBTOOLIZE" || func_fatal_error "\
4109 Please install GNU Libtool, or 'export LIBTOOLIZE=/path/to/libtoolize'."
4111 func_verbose "export LIBTOOLIZE='$LIBTOOLIZE'"
4113 # Make sure the search result is visible to subshells
4116 require_libtoolize=:
4120 # require_local_gl_dir
4121 # --------------------
4122 # Ensure local_gl_dir has a sensible value, extracted from 'gnulib-cache.m4'
4123 # if possible, otherwise letting 'gnulib-tool' pick a default.
4124 require_local_gl_dir=func_require_local_gl_dir
4125 func_require_local_gl_dir ()
4129 $require_gnulib_cache
4131 test -f "$gnulib_cache" && test -z "$local_gl_dir" && {
4132 func_extract_trace_first "gl_LOCAL_DIR" "$gnulib_cache"
4133 local_gl_dir=$func_extract_trace_first_result
4135 test -n "$local_gl_dir" && func_verbose "local_gl_dir='$local_gl_dir'"
4138 require_local_gl_dir=:
4144 # Ensure that '$macro_dir' is set, and if it doesn't already point to an
4145 # existing directory, create one.
4146 require_macro_dir=func_require_macro_dir
4147 func_require_macro_dir ()
4151 # Sometimes this is stored in 'configure.ac'.
4152 test -n "$macro_dir" || {
4153 # AC_CONFIG_MACRO_DIRS takes a space delimited list of directories,
4154 # but we only care about the first one in bootstrap.
4155 func_extract_trace_first AC_CONFIG_MACRO_DIRS
4156 macro_dir=`expr "x$func_extract_trace_first_result" : 'x\([^ ]*\)'`
4158 test -n "$macro_dir" || {
4159 func_extract_trace_first AC_CONFIG_MACRO_DIR
4160 macro_dir=$func_extract_trace_first_result
4163 # Otherwise we might find it in 'Makefile.am'.
4164 test -n "$macro_dir" || {
4165 $require_aclocal_amflags
4167 # Take the argument following the first '-I', if any.
4168 _G_minus_I_seen=false
4169 for _G_arg in $aclocal_amflags; do
4170 case $_G_minus_I_seen,$_G_arg in
4171 :,*) macro_dir=$_G_arg; break ;;
4172 *,-I) _G_minus_I_seen=: ;;
4173 *,-I*) macro_dir=`expr x$_G_arg : 'x-I\(.*\)$'`; break ;;
4178 func_verbose "macro_dir='$macro_dir'"
4180 func_check_configuration macro_dir \
4181 "AC_CONFIG_MACRO_DIRS([name of a directory for configure m4 files])"
4183 $require_vc_ignore_files
4185 # If the macro_dir directory doesn't exist, create it now, and mark it
4186 # as ignored for the VCS.
4187 if test ! -d "$macro_dir"; then
4188 mkdir "$macro_dir" || func_permissions_error "$macro_dir"
4190 test -n "$vc_ignore_files" \
4191 || func_insert_if_absent "$macro_dir" $vc_ignore_files
4198 # require_makefile_am
4199 # -------------------
4200 # Ensure there is a 'Makefile.am' in the current directory.
4201 require_makefile_am=func_require_makefile_am
4202 func_require_makefile_am ()
4206 test -n "$makefile_am" \
4207 || makefile_am=Makefile.am
4211 func_verbose "found '$makefile_am'"
4213 require_makefile_am=:
4219 # Ensure that '$package' contains a sensible default value.
4220 require_package=func_require_package
4221 func_require_package ()
4225 test -n "$package" || {
4226 $require_package_name
4228 package=`echo "$package_name" \
4229 |$SED -e 's/GNU //' \
4230 -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
4233 func_verbose "package='$package'"
4239 # require_package_bugreport
4240 # -------------------------
4241 # Ensure that this has a sensible value, extracted from 'configure.ac'
4242 # if appropriate (and possible!).
4243 require_package_bugreport=func_require_package_bugreport
4244 func_require_package_bugreport ()
4248 func_extract_trace AC_INIT
4252 set dummy $func_extract_trace_result
4256 test -n "$package_bugreport" || package_bugreport=$3
4257 func_check_configuration package_bugreport \
4258 "AC_INIT([$package_name], [$package_version], [bug-$package@gnu.org])"
4259 func_verbose "package_bugreport='$package_bugreport'"
4261 require_package_bugreport=:
4265 # require_package_name
4266 # --------------------
4267 # Ensure that this has a sensible value, extracted from 'configure.ac'
4268 # if appropriate (and possible!).
4269 require_package_name=func_require_package_name
4270 func_require_package_name ()
4274 func_extract_trace AC_INIT
4278 set dummy $func_extract_trace_result
4282 test -n "$package_name" || package_name=$1
4283 func_check_configuration package_name \
4284 "AC_INIT([name of your package], [package version number])"
4285 func_verbose "package_name='$package_name'"
4287 require_package_name=:
4291 # require_package_version
4292 # -----------------------
4293 # Ensure that this has a sensible value, extracted from 'configure.ac'
4294 # if appropriate (and possible!). While we might have set all the
4295 # parameters extracted from AC_INIT at once, 'package_version' in
4296 # particular is not necessarily available as early as the others, since
4297 # 'git-version-gen' is often involved, and until then we can't rely on
4298 # getting a correct version number from an AC_INIT extraction.
4299 require_package_version=func_require_package_version
4300 func_require_package_version ()
4304 func_extract_trace AC_INIT
4308 set dummy $func_extract_trace_result
4312 test -n "$package_version" || package_version=$2
4313 test -n "$package_version" || {
4314 # The embedded echo is to squash whitespace before globbing.
4315 case " "`echo $gnulib_modules`" " in
4316 *" git-version-gen "*)
4318 cannot \$require_package_version in bootstrap.conf before
4319 func_gnulib_tool has installed the 'git-version-gen' script."
4322 func_check_configuration package_version \
4323 "AC_INIT([name of your package], [package version number])"
4327 func_verbose "package_version='$package_version'"
4329 require_package_version=:
4335 # Find patch, according to the PATCH environment variable, or else
4336 # searching the user's PATH.
4337 require_patch=func_require_patch
4338 func_require_patch ()
4342 test -n "$PATCH" || {
4343 # Find a patch program, preferring gpatch, which is usually better
4344 # than the vendor patch.
4345 func_find_tool PATCH gpatch patch
4348 test -n "$PATCH" || func_fatal_error "\
4349 Please install GNU Patch, or 'export PATCH=/path/to/gnu/patch'."
4351 func_verbose "export PATCH='$PATCH'"
4353 # Make sure the search result is visible to subshells
4360 # require_source_base
4361 # -------------------
4362 # Ensure that source_base has a sensible value, extracted from
4363 # 'gnulib-cache.m4' if possible.
4364 require_source_base=func_require_source_base
4365 func_require_source_base ()
4369 $require_gnulib_cache
4371 test -f "$gnulib_cache" && test -z "$source_base" && {
4372 func_extract_trace_first "gl_SOURCE_BASE" "$gnulib_cache"
4374 source_base=$func_extract_trace_first_result
4376 func_verbose "source_base='$source_base'"
4379 require_source_base=:
4383 # require_vc_ignore_files
4384 # -----------------------
4385 # Ensure that '$vc_ignore' has been processed to list VCS ignore files
4386 # in '$vc_ignore_files'
4387 require_vc_ignore_files=func_require_vc_ignore_files
4388 func_require_vc_ignore_files ()
4392 test -n "$vc_ignore" || vc_ignore=auto
4394 if test auto = "$vc_ignore" && test -z "$vc_ignore_files"; then
4396 test -d .git && vc_ignore_files=.gitignore
4397 test -d CVS && vc_ignore_files="$vc_ignore_files .cvsignore"
4399 vc_ignore_files=$vc_ignore
4402 func_verbose "vc_ignore_files='$vc_ignore_files'"
4404 require_vc_ignore_files=:
4408 ## ----------------- ##
4409 ## Helper functions. ##
4410 ## ----------------- ##
4412 # This section contains the helper functions used by the rest of 'bootstrap'.
4416 # STRING may not start with a hyphen.
4417 if (eval 'x=123; test x${#x} = "x3"') 2>/dev/null
4419 # This is an XSI compatible shell, allowing a faster implementation...
4424 func_len_result=${#1}
4427 # ...otherwise fall back to using expr, which is often a shell builtin.
4432 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo 0`
4439 # Portably unset VAR.
4440 # In some shells, an 'unset VAR' statement leaves a non-zero return
4441 # status if VAR is already unset, which might be problematic if the
4442 # statement is used at the end of a function (thus poisoning its return
4443 # value) or when 'set -e' is active (causing even a spurious abort of
4444 # the script in this case).
4447 { eval $1=; unset $1; }
4452 # func_cmp_s FILE1 FILE2
4453 # ----------------------
4454 # Return non-zero exit status unless FILE1 and FILE2 are identical, without
4455 # any output at all, even error messages.
4460 # This function relies on non-zero exit status, which will cause the
4461 # program to exit when running in 'set -e' mode.
4462 $CMP "$@" >/dev/null 2>&1
4466 # func_grep_q EXPRESSION [FILENAME..]
4467 # -----------------------------------
4468 # Check whether EXPRESSION matches any line of any listed FILENAME,
4469 # without any output at all, even error messages.
4474 # This function relies on non-zero exit status, which will cause the
4475 # program to exit when running in 'set -e' mode.
4476 $GREP "$@" >/dev/null 2>&1
4480 # func_ifcontains LIST MEMBER YES-CMD [NO-CMD]
4481 # --------------------------------------------
4482 # If whitespace-separated LIST contains MEMBER then execute YES-CMD,
4483 # otherwise if NO-CMD was given, execute that.
4494 for _G_item in $_G_wslist; do
4495 test "x$_G_item" = "x$_G_member" && {
4508 test 0 -eq "$_G_status" || exit $_G_status
4512 # func_strpad STR WIDTH CHAR
4513 # --------------------------
4514 # Trim STR, or pad with CHAR to force a total length of WIDTH.
4519 _G_width=`expr "$2" - 1`
4520 func_strpad_result=`$ECHO "$1" |$SED '
4522 s|^.\{0,'"$_G_width"'\}$|&'"$3"'|
4528 # func_strrpad STR WIDTH CHAR
4529 # ---------------------------
4530 # Trim STR, or right-justify-pad with CHAR to force a total length of
4536 _G_width=`expr "$2" - 1`
4537 func_strrpad_result=`$ECHO "$1" |$SED '
4539 s|^.\{0,'"$_G_width"'\}$|'"$3"'&|
4545 # func_strrow INDENT FIELD WIDTH [FIELDn WIDTHn]...
4546 # -------------------------------------------------
4547 # Return a string containing each FIELD left justified to WIDTH, with
4548 # the whole thing indented by INDENT spaces. This function is used to
4549 # render one row of aligned columns for a table by func_strtable().
4554 func_strrow_linelen=$1; shift
4557 while test $# -gt 0; do
4558 func_strrow_linelen=`expr $func_strrow_linelen + $2`
4559 func_strpad "$1" $2 " "
4560 func_append _G_row "$func_strpad_result"
4564 func_strrpad "$_G_row" $func_strrow_linelen " "
4565 func_strrow_result=$func_strrpad_result
4569 # func_strtable INDENT WIDTH1...WIDTHn HEADER1...HEADERn FIELD1...FIELDn
4570 # ----------------------------------------------------------------------
4571 # Generate a string of newline-separated rows arranged in lined-up
4572 # columns of the given WIDTHs, with the entire table indented by INDENT
4573 # spaces. The number of columns is determined by the number of integer
4574 # valued WIDTH arguments following INDENT. The next set (i.e. a number
4575 # of arguments equal to the number of WIDTH arguments) of fields are
4576 # treated as the table's column HEADERs, and are separated from the
4577 # remainder of the table by an indented row of '-' characters. Remaining
4578 # arguments are each aligned below the next available header, wrapping
4579 # to a new row as necessary. Finally another row of '-' characters is
4580 # added to mark the end of the table.
4582 # For example an unindented 3 column table with 2 rows of data would be
4583 # generated by this call:
4585 # func_strtable 3 20 10 25 \
4586 # Header1 Header2 Header3 \
4587 # Row1Col1 Row1Col2 Row1Col3 \
4588 # Row2Col1 Row2Col2 Row2Col3
4590 # returning the following string:
4592 # " Header1 Header2 Header3
4593 # -------------------------------------------------------
4594 # Row1Col1 Row1Col2 Row1Col3
4595 # Row2Col1 Row2Col2 Row2Col3
4596 # -------------------------------------------------------"
4601 # Save the indent value, we'll need it for each row we render.
4604 # Collect remaining numeric args into a list for reuse between
4605 # members of each row when we call func_strrow later.
4607 while test 0 -lt `expr "$1" : '[1-9][0-9]*$'`; do
4608 func_append _G_widths " $1"; shift
4611 # Extract the same number of positional parameters as there are
4612 # width elements - we'll do the header rows separately so that
4613 # we can insert a divider line.
4614 _G_header=$_G_indent
4615 for _G_width in $_G_widths; do
4616 func_append _G_header " $1 $_G_width"; shift
4618 func_strrow $_G_header
4620 # Strip off the indent, and make a divider with '-' chars, then
4622 _G_divider=`$ECHO "$func_strrow_result" \
4629 # Append the header and divider to the running result.
4630 func_append func_strtable_result "\
4635 # The remaining rows are zipped between the width values we
4636 # unwound earlier just like the header row above.
4637 while test $# -gt 0; do
4639 for _G_width in $_G_widths; do
4640 func_append _G_row " $1 $_G_width"; shift
4643 func_append func_strtable_result "\
4648 # Mark the end of the table with a final divider line.
4649 func_append func_strtable_result "$_G_divider"
4653 # func_internal_error ARG...
4654 # --------------------------
4655 # Echo program name prefixed message to standard error, and exit.
4656 func_internal_error ()
4659 INTERNAL: " ${1+"$@"} "
4660 Please report this bug to 'bug-gnulib@gnu.org'
4661 in as much detail as possible."
4665 # func_permissions_error FILE-OR-DIRECTORY
4666 # ----------------------------------------
4667 # Echo program name prefixed permissions error message to standard
4669 func_permissions_error ()
4673 func_fatal_error "Failed to create '$1', check permissions."
4677 # func_show_eval CMD [FAIL_EXP]
4678 # -----------------------------
4679 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
4680 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
4681 # is given, then evaluate it.
4686 $require_term_colors
4689 _G_fail_exp=${2-':'}
4691 ${opt_silent-'false'} || {
4692 func_quote_for_eval $_G_cmd
4693 eval func_truncate_cmd $func_quote_for_eval_result
4694 func_echo "running: $tc_bold$func_truncate_cmd_result$tc_reset"
4697 ${opt_dry_run-'false'} || {
4700 test 0 -eq "$_G_status" || eval "(exit $_G_status); $_G_fail_exp"
4705 # func_truncate_cmd CMD [ARG]...
4706 # ------------------------------
4707 # For unreasonably long commands (such as a gnulib-tool invocation with
4708 # the full module list for import), truncate CMD after the second non-
4710 func_truncate_cmd ()
4714 _G_last_arg_opt_p=false
4715 func_truncate_cmd_result=
4717 set dummy "$@"; shift
4719 while test $# -gt 0; do
4722 test -n "$func_truncate_cmd_result" \
4723 && func_append func_truncate_cmd_result ' '
4724 func_append func_truncate_cmd_result "$_G_opt"
4726 func_len "x$func_truncate_cmd_result"
4729 -*) _G_last_arg_opt_p=: ;;
4730 *) $_G_last_arg_opt_p \
4731 || test "$min_cmd_len" -gt "$func_len_result" \
4733 _G_last_arg_opt_p=false
4738 test $# -gt 0 && func_append func_truncate_cmd_result "..."
4742 # func_gitignore_entries FILE...
4743 # ------------------------------
4744 # Strip blank and comment lines to leave significant entries.
4745 func_gitignore_entries ()
4749 $SED -e '/^#/d' -e '/^$/d' "$@"
4753 # func_insert_if_absent STR FILE...
4754 # ---------------------------------
4755 # If $STR is not already on a line by itself in $FILE, insert it, at the
4756 # start. Entries are inserted at the start of the ignore list to ensure
4757 # existing entries starting with ! are not overridden. Such entries
4758 # support whilelisting exceptions after a more generic blacklist pattern.
4759 # sorting the new contents of the file and replacing $FILE with the result.
4760 func_insert_if_absent ()
4769 test -f "$file" || touch "$file"
4771 duplicate_entries=`func_gitignore_entries "$file" |sort |uniq -d`
4772 test -n "$duplicate_entries" \
4773 && func_error "duplicate entries in $file: " $duplicate_entries
4775 func_grep_q "^$str\$" "$file" \
4776 || func_verbose "inserting '$str' into '$file'"
4778 linesold=`func_gitignore_entries "$file" |wc -l`
4779 linesnew=`{ $ECHO "$str"; cat "$file"; } \
4780 |func_gitignore_entries |sort -u |wc -l`
4781 test "$linesold" -eq "$linesnew" \
4782 || { $SED "1i\\$nl$str$nl" "$file" >"$file"T && mv "$file"T "$file"; } \
4783 || func_permissions_error "$file"
4788 # func_get_version APP
4789 # --------------------
4790 # echo the version number (if any) of APP, which is looked up along your
4798 # Rather than uncomment the sed script in-situ, strip the comments
4799 # programatically before passing the result to $SED for evaluation.
4800 sed_get_version=`$ECHO '# extract version within line
4801 s|.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1|
4804 # extract version at start of line
4805 s|^\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1|
4811 # the following essentially does s|5.005|5.5|
4812 s|\.0*\([1-9]\)|.\1|g
4815 |$SED '/^[ ]*#.*$/d'`
4817 func_tool_version_output $_G_app >/dev/null
4820 test 0 -ne "$_G_status" \
4821 || $_G_app --version 2>&1 |$SED -n "$sed_get_version"
4827 # func_check_tool APP
4828 # -------------------
4829 # Search PATH for an executable at APP.
4834 func_check_tool_result=
4838 test -x "$1" && func_check_tool_result=$1
4842 IFS=${PATH_SEPARATOR-:}
4843 for _G_check_tool_path in $PATH; do
4845 if test -x "$_G_check_tool_path/$1"; then
4846 func_check_tool_result=$_G_check_tool_path/$1
4856 # func_check_versions APP1 VER1 URL1 ...[APPN VERN URLN]
4857 # ------------------------------------------------------
4858 func_check_versions ()
4862 func_check_versions_result=:
4864 while test $# -gt 0; do
4869 # Diagnose bad buildreq formatting.
4871 [a-z]*://*) ;; # looks like a url
4872 *) func_fatal_error "\
4873 '$_G_url' from the buildreq table in
4874 'bootstrap.conf' does not look like the URL for downloading
4875 $_G_app. Please ensure that buildreq is a strict newline
4876 delimited list of triples; 'program min-version url'."
4880 # Honor $APP variables ($TAR, $AUTOCONF, etc.)
4881 _G_appvar=`echo $_G_app |tr '[a-z]' '[A-Z]'`
4882 test TAR = "$_G_appvar" && _G_appvar=AMTAR
4883 eval "_G_app=\${$_G_appvar-$_G_app}"
4885 # Fail if no version specified, but the program can't be found.
4886 if test x- = "x$_G_reqver"; then
4887 func_check_tool $_G_app
4888 if test -z "$func_check_tool_result"; then
4889 func_error "Prerequisite '$_G_app' not not found. Please install it, or
4890 'export $_G_appvar=/path/to/$_G_app'."
4891 func_check_versions_result=false
4893 func_verbose "found '$func_check_tool_result' for $_G_appvar."
4896 _G_instver=`func_get_version $_G_app`
4898 # Fail if --version didn't work.
4899 if test -z "$_G_instver"; then
4900 func_error "Prerequisite '$_G_app' not found. Please install it, or
4901 'export $_G_appvar=/path/to/$_G_app'."
4902 func_check_versions_result=false
4904 # Fail if a newer version than what we have is required.
4906 func_verbose "found '$_G_app' version $_G_instver."
4910 # If $buildreq version starts with '=', version must
4911 # match the installed program exactly.
4912 test "x$_G_reqver" = "x=$_G_instver" || {
4914 '$_G_app' version == $_G_instver is too old
4915 'exactly $_G_app-$_G_reqver is required"
4916 func_check_versions_result=false
4920 # Otherwise, anything that is not older is a match.
4921 func_lt_ver "$_G_reqver" "$_G_instver" || {
4923 '$_G_app' version == $_G_instver is too old
4924 '$_G_app' version >= $_G_reqver is required"
4925 func_check_versions_result=false
4935 # func_cleanup_gnulib
4936 # -------------------
4937 # Recursively delete everything below the path in the global variable
4939 func_cleanup_gnulib ()
4944 $RM -fr "$gnulib_path"
4949 # func_download_po_files SUBDIR DOMAIN
4950 # ------------------------------------
4951 func_download_po_files ()
4955 func_echo "getting translations into $1 for $2..."
4956 _G_cmd=`printf "$po_download_command_format" "$2" "$1"`
4961 # func_update_po_files PO_DIR DOMAIN
4962 # ----------------------------------
4963 # Mirror .po files to $po_dir/.reference and copy only the new
4964 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
4965 # Note po files that exist locally only are left in $po_dir but will
4966 # not be included in LINGUAS and hence will not be distributed.
4967 func_update_po_files ()
4971 # Directory containing primary .po files.
4972 # Overwrite them only when we're sure a .po file is new.
4976 # Mirror *.po files into this dir.
4977 # Usually contains *.s1 checksum files.
4978 _G_ref_po_dir=$_G_po_dir/.reference
4980 test -d "$_G_ref_po_dir" || mkdir $_G_ref_po_dir || return
4981 func_download_po_files $_G_ref_po_dir $_G_domain \
4982 && ls "$_G_ref_po_dir"/*.po 2>/dev/null \
4983 |$SED -e 's|.*/||' -e 's|\.po$||' > "$_G_po_dir/LINGUAS" || return
4985 # Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6+.
4986 func_find_tool SHA1SUM sha1sum gsha1sum shasum sha1
4988 test -n "$SHA1SUM" || func_fatal_error "\
4989 Please install GNU Coreutils, or 'export SHA1SUM=/path/to/sha1sum'."
4991 _G_langs=`cd $_G_ref_po_dir && echo *.po|$SED 's|\.po||g'`
4992 test '*' = "$_G_langs" && _G_langs=x
4993 for _G_po in $_G_langs; do
4994 case $_G_po in x) continue;; esac
4995 _G_new_po=$_G_ref_po_dir/$_G_po.po
4996 _G_cksum_file=$_G_ref_po_dir/$_G_po.s1
4997 if ! test -f "$_G_cksum_file" ||
4998 ! test -f "$_G_po_dir/$_G_po.po" ||
4999 ! $SHA1SUM -c "$_G_cksum_file" \
5000 < "$_G_new_po" > /dev/null; then
5001 echo "updated $_G_po_dir/$_G_po.po..."
5002 cp "$_G_new_po" "$_G_po_dir/$_G_po.po" \
5003 && $SHA1SUM < "$_G_new_po" > "$_G_cksum_file" || return
5010 ## --------------- ##
5011 ## Option parsing. ##
5012 ## --------------- ##
5014 # Hook in the functions to make sure our own options are parsed during
5015 # the option parsing loop.
5017 usage='$progpath [OPTION]...'
5019 # Short help message in response to '-h'. Add to this in 'bootstrap.conf'
5020 # if you accept any additional options.
5021 usage_message="Common Bootstrap Options:
5022 -c, --copy copy files instead of creating symbolic links.
5023 --debug enable verbose shell tracing
5024 -n, --dry-run print commands rather than running them
5025 -f, --force attempt to bootstrap even if the sources seem not
5026 to have been checked out.
5027 --gnulib-srcdir=DIRNAME
5028 specify a local directory where gnulib sources
5029 reside. Use this if you already have the gnulib
5030 sources on your machine, and don't want to waste
5031 your bandwidth downloading them again. Defaults to
5033 --no-warnings equivalent to '-Wnone'
5034 --skip-git do not fetch files from remote repositories
5035 --skip-po do not download po files.
5036 -v, --verbose verbosely report processing
5037 --version print version information and exit
5038 -W, --warnings=CATEGORY
5039 report the warnings falling in CATEGORY [all]
5040 -h, --help print short or long help message and exit
5043 # Additional text appended to 'usage_message' in response to '--help'.
5044 long_help_message=$long_help_message"
5045 'recommend' show warnings about missing recommended packages
5046 'settings' show warnings about missing '$progname.conf' settings
5047 'upgrade' show warnings about out-dated files
5049 If the file '$progname.conf' exists in the same directory as this
5050 script, its contents are read as shell variables to configure the
5053 For build prerequisites, environment variables like \$AUTOCONF and
5054 \$AMTAR are honored.
5056 Running without arguments will suffice in most cases.
5059 # Warning categories used by 'bootstrap', append others if you use them
5060 # in your 'bootstrap.conf'.
5061 warning_categories='recommend settings upgrade'
5064 # bootstrap_options_prep [ARG]...
5065 # -------------------------------
5066 # Preparation for options parsed by Bootstrap.
5067 bootstrap_options_prep ()
5072 opt_copy=${copy-'false'}
5075 opt_gnulib_srcdir=$GNULIB_SRCDIR
5079 # Pass back the list of options we consumed.
5080 func_quote_for_eval ${1+"$@"}
5081 bootstrap_options_prep_result=$func_quote_for_eval_result
5083 func_add_hook func_options_prep bootstrap_options_prep
5086 # bootstrap_parse_options [ARG]...
5087 # --------------------------------
5088 # Provide handling for Bootstrap specific options.
5089 bootstrap_parse_options ()
5093 # Perform our own loop to consume as many options as possible in
5095 while test $# -gt 0; do
5099 --dry-run|--dryrun|-n)
5101 --copy|-c) opt_copy=: ;;
5102 --force|-f) opt_force=: ;;
5105 test $# = 0 && func_missing_arg $_G_opt && break
5106 opt_gnulib_srcdir=$1
5110 --skip-git|--no-git)
5118 # Separate non-argument short options:
5120 func_split_short_opt "$_G_opt"
5121 set dummy "$func_split_short_opt_name" \
5122 "-$func_split_short_opt_arg" ${1+"$@"}
5126 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
5130 # save modified positional parameters for caller
5131 func_quote_for_eval ${1+"$@"}
5132 bootstrap_parse_options_result=$func_quote_for_eval_result
5134 func_add_hook func_parse_options bootstrap_parse_options
5137 # bootstrap_validate_options [ARG]...
5138 # -----------------------------------
5139 # Perform any sanity checks on option settings and/or unconsumed
5141 bootstrap_validate_options ()
5147 && func_fatal_help "too many arguments"
5149 # Pass back the (empty) list of unconsumed options.
5150 func_quote_for_eval ${1+"$@"}
5151 bootstrap_validate_options_result=$func_quote_for_eval_result
5153 func_add_hook func_validate_options bootstrap_validate_options
5156 ## -------------------------------------------------- ##
5157 ## Source package customisations in 'bootstrap.conf'. ##
5158 ## -------------------------------------------------- ##
5160 # Override the default configuration, if necessary.
5161 # Make sure that bootstrap.conf is sourced from the current directory
5162 # if we were invoked as "sh bootstrap".
5164 */*) test -r "$0.conf" && . "$0.conf" ;;
5165 *) test -r "$0.conf" && . ./"$0.conf" ;;
5169 ## ------------------------------- ##
5170 ## Actually perform the bootstrap. ##
5171 ## ------------------------------- ##
5173 func_bootstrap ${1+"$@"}
5176 exit ${exit_status-$EXIT_SUCCESS}
5179 # mode: shell-script
5181 # eval: (add-hook 'before-save-hook 'time-stamp)
5182 # time-stamp-pattern: "500/scriptversion=%:y-%02m-%02d.%02H; # UTC"
5183 # time-stamp-time-zone: "UTC"