"Fossies" - the Fresh Open Source Software Archive

Member "libtool-2.4.6/bootstrap" (20 Jan 2015, 150454 Bytes) of package /linux/misc/libtool-2.4.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "bootstrap": 2.4.5_vs_2.4.6.

    1 #! /bin/sh
    2 ## DO NOT EDIT - This file generated from build-aux/bootstrap.in
    3 ##               by inline-source v2014-01-03.01
    4 
    5 # Bootstrap an Autotooled package from checked-out sources.
    6 # Written by Gary V. Vaughan, 2010
    7 
    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.
   11 
   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.
   16 
   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.
   21 
   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/>.
   24 
   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.
   32 
   33 # Please report bugs or propose patches to bug-gnulib@gnu.org.
   34 
   35 
   36 ## ------ ##
   37 ## Usage. ##
   38 ## ------ ##
   39 
   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.
   47 #
   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
   52 # script with:
   53 #
   54 #   gl/build-aux/inline-source gl/build-aux/bootstrap.in > bootstrap
   55 #
   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.
   59 #
   60 # See gl/doc/bootstrap.texi for documentation on how to write
   61 # a bootstrap.conf to customize it for your project's
   62 # idiosyncracies.
   63 
   64 
   65 ## ================================================================== ##
   66 ##                                                                    ##
   67 ##     DO NOT EDIT THIS FILE, CUSTOMIZE IT USING A BOOTSTRAP.CONF     ##
   68 ##                                                                    ##
   69 ## ================================================================== ##
   70 
   71 ## ------------------------------- ##
   72 ## User overridable command paths. ##
   73 ## ------------------------------- ##
   74 
   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',
   79 # for example).
   80 #
   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
   84 # section.
   85 
   86 : ${ACLOCAL="aclocal"}
   87 : ${AUTOCONF="autoconf"}
   88 : ${AUTOHEADER="autoheader"}
   89 : ${AUTOM4TE="autom4te"}
   90 : ${AUTOHEADER="autoheader"}
   91 : ${AUTOMAKE="automake"}
   92 : ${AUTOPOINT="autopoint"}
   93 : ${AUTORECONF="autoreconf"}
   94 : ${CMP="cmp"}
   95 : ${CONFIG_SHELL="/bin/sh"}
   96 : ${DIFF="diff"}
   97 : ${GIT="git"}
   98 : ${LN_S="ln -s"}
   99 : ${RM="rm"}
  100 
  101 export ACLOCAL
  102 export AUTOCONF
  103 export AUTOHEADER
  104 export AUTOM4TE
  105 export AUTOHEADER
  106 export AUTOMAKE
  107 export AUTOPOINT
  108 export AUTORECONF
  109 export CONFIG_SHELL
  110 
  111 
  112 ## -------------- ##
  113 ## Configuration. ##
  114 ## -------------- ##
  115 
  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.
  120 buildreq=
  121 
  122 # Name of a file containing instructions on installing missing packages
  123 # required in 'buildreq'.
  124 buildreq_readme=README-hacking
  125 
  126 # These are extracted from AC_INIT in configure.ac, though you can
  127 # override those values in 'bootstrap.conf' if you prefer.
  128 build_aux=
  129 macro_dir=
  130 package=
  131 package_name=
  132 package_version=
  133 package_bugreport=
  134 
  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'.
  138 doc_base=
  139 gnulib_mk=
  140 gnulib_name=
  141 local_gl_dir=
  142 source_base=
  143 tests_base=
  144 
  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.
  148 gnulib_modules=
  149 
  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="
  153         build-aux/compile
  154         build-aux/install-sh
  155         build-aux/mdate-sh
  156         build-aux/texinfo.tex
  157         build-aux/depcomp
  158         build-aux/config.guess
  159         build-aux/config.sub
  160         doc/INSTALL
  161 "
  162 
  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.
  166 gnulib_path=
  167 gnulib_url=
  168 
  169 # Additional gnulib-tool options to use.
  170 gnulib_tool_options="
  171         --no-changelog
  172 "
  173 
  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.
  176 gnulib_precious="
  177         gnulib-tool.m4
  178 "
  179 
  180 # When truncating long commands for display, always allow at least this
  181 # many characters before truncating.
  182 min_cmd_len=160
  183 
  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
  188 # all symlinks.
  189 po_download_command_format=\
  190 "rsync --delete --exclude '*.s1' -Lrtvz \
  191 'translationproject.org::tp/latest/%s/' '%s'"
  192 
  193 # Other locale categories that need message catalogs.
  194 extra_locale_categories=
  195 
  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:
  200 #
  201 #    AM_GNU_GETTEXT_VERSION([0.16.1])
  202 xgettext_options="
  203         --flag=_:1:pass-c-format
  204         --flag=N_:1:pass-c-format
  205 "
  206 
  207 # Package copyright holder for gettext files.  Defaults to FSF if unset.
  208 copyright_holder=
  209 
  210 # File that should exist in the top directory of a checked out hierarchy,
  211 # but not in a distribution tarball.
  212 checkout_only_file=
  213 
  214 # Whether to use copies instead of symlinks by default (if set to true,
  215 # the --copy option has no effect).
  216 copy=false
  217 
  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
  223 # "auto".
  224 vc_ignore=
  225 
  226 
  227 ## ------------------- ##
  228 ## External Libraries. ##
  229 ## ------------------- ##
  230 
  231 # Source required external libraries:
  232 # Set a version string for this script.
  233 scriptversion=2015-01-20.17; # UTC
  234 
  235 # General shell script boiler plate, and helper functions.
  236 # Written by Gary V. Vaughan, 2004
  237 
  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.
  241 
  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.
  246 
  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.
  251 
  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.
  256 
  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/>.
  259 
  260 # Please report bugs or propose patches to gary@gnu.org.
  261 
  262 
  263 ## ------ ##
  264 ## Usage. ##
  265 ## ------ ##
  266 
  267 # Evaluate this file near the top of your script to gain access to
  268 # the functions and variables defined here:
  269 #
  270 #   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
  271 #
  272 # If you need to override any of the default environment variable
  273 # settings, do that before evaluating this file.
  274 
  275 
  276 ## -------------------- ##
  277 ## Shell normalisation. ##
  278 ## -------------------- ##
  279 
  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!
  282 
  283 DUALCASE=1; export DUALCASE # for MKS sh
  284 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
  285   emulate sh
  286   NULLCMD=:
  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+"$@"}'='"$@"'
  290   setopt NO_GLOB_SUBST
  291 else
  292   case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
  293 fi
  294 
  295 # NLS nuisances: We save the old values in case they are required later.
  296 _G_user_locale=
  297 _G_safe_locale=
  298 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  299 do
  300   eval "if test set = \"\${$_G_var+set}\"; then
  301           save_$_G_var=\$$_G_var
  302           $_G_var=C
  303       export $_G_var
  304       _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
  305       _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
  306     fi"
  307 done
  308 
  309 # CDPATH.
  310 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  311 
  312 # Make sure IFS has a sensible default
  313 sp=' '
  314 nl='
  315 '
  316 IFS="$sp    $nl"
  317 
  318 # There are apparently some retarded systems that use ';' as a PATH separator!
  319 if test "${PATH_SEPARATOR+set}" != set; then
  320   PATH_SEPARATOR=:
  321   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
  322     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
  323       PATH_SEPARATOR=';'
  324   }
  325 fi
  326 
  327 
  328 
  329 ## ------------------------- ##
  330 ## Locate command utilities. ##
  331 ## ------------------------- ##
  332 
  333 
  334 # func_executable_p FILE
  335 # ----------------------
  336 # Check that FILE is an executable regular file.
  337 func_executable_p ()
  338 {
  339     test -f "$1" && test -x "$1"
  340 }
  341 
  342 
  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
  348 # PROGS_LIST.
  349 #
  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.
  353 func_path_progs ()
  354 {
  355     _G_progs_list=$1
  356     _G_check_func=$2
  357     _G_PATH=${3-"$PATH"}
  358 
  359     _G_path_prog_max=0
  360     _G_path_prog_found=false
  361     _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
  362     for _G_dir in $_G_PATH; do
  363       IFS=$_G_save_IFS
  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
  373            ;;
  374           esac
  375           $_G_path_prog_found && break 3
  376         done
  377       done
  378     done
  379     IFS=$_G_save_IFS
  380     test -z "$func_path_progs_result" && {
  381       echo "no acceptable sed could be found in \$PATH" >&2
  382       exit 1
  383     }
  384 }
  385 
  386 
  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.
  391 
  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.
  394 test -z "$SED" && {
  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
  398   done
  399   echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
  400   _G_sed_script=
  401 
  402   func_check_prog_sed ()
  403   {
  404     _G_path_prog=$1
  405 
  406     _G_count=0
  407     printf 0123456789 >conftest.in
  408     while :
  409     do
  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
  421       fi
  422       # 10*(2^10) chars as input seems more than enough
  423       test 10 -lt "$_G_count" && break
  424     done
  425     rm -f conftest.in conftest.tmp conftest.nl conftest.out
  426   }
  427 
  428   func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
  429   rm -f conftest.sed
  430   SED=$func_path_progs_result
  431 }
  432 
  433 
  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.
  436 test -z "$GREP" && {
  437   func_check_prog_grep ()
  438   {
  439     _G_path_prog=$1
  440 
  441     _G_count=0
  442     _G_path_prog_max=0
  443     printf 0123456789 >conftest.in
  444     while :
  445     do
  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
  457       fi
  458       # 10*(2^10) chars as input seems more than enough
  459       test 10 -lt "$_G_count" && break
  460     done
  461     rm -f conftest.in conftest.tmp conftest.nl conftest.out
  462   }
  463 
  464   func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
  465   GREP=$func_path_progs_result
  466 }
  467 
  468 
  469 ## ------------------------------- ##
  470 ## User overridable command paths. ##
  471 ## ------------------------------- ##
  472 
  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.
  477 
  478 : ${CP="cp -f"}
  479 : ${ECHO="printf %s\n"}
  480 : ${EGREP="$GREP -E"}
  481 : ${FGREP="$GREP -F"}
  482 : ${LN_S="ln -s"}
  483 : ${MAKE="make"}
  484 : ${MKDIR="mkdir"}
  485 : ${MV="mv -f"}
  486 : ${RM="rm -f"}
  487 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
  488 
  489 
  490 ## -------------------- ##
  491 ## Useful sed snippets. ##
  492 ## -------------------- ##
  493 
  494 sed_dirname='s|/[^/]*$||'
  495 sed_basename='s|^.*/||'
  496 
  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'
  500 
  501 # Same as above, but do not quote variable references.
  502 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
  503 
  504 # Sed substitution that turns a string into a regex matching for the
  505 # string literally.
  506 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
  507 
  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'
  512 
  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 '$'.
  518 _G_bs='\\'
  519 _G_bs2='\\\\'
  520 _G_bs4='\\\\\\\\'
  521 _G_dollar='\$'
  522 sed_double_backslash="\
  523   s/$_G_bs4/&\\
  524 /g
  525   s/^$_G_bs2$_G_dollar/$_G_bs&/
  526   s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
  527   s/\n//g"
  528 
  529 
  530 ## ----------------- ##
  531 ## Global variables. ##
  532 ## ----------------- ##
  533 
  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.
  546 
  547 EXIT_SUCCESS=0
  548 EXIT_FAILURE=1
  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.
  551 
  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:
  555 #
  556 #    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
  557 debug_cmd=${debug_cmd-":"}
  558 exit_cmd=:
  559 
  560 # By convention, finish your script with:
  561 #
  562 #    exit $exit_status
  563 #
  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
  568 
  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
  573 # function.
  574 progpath=$0
  575 
  576 # The name of this program.
  577 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
  578 
  579 # Make sure we have an absolute progpath for reexecution:
  580 case $progpath in
  581   [\\/]*|[A-Za-z]:\\*) ;;
  582   *[\\/]*)
  583      progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
  584      progdir=`cd "$progdir" && pwd`
  585      progpath=$progdir/$progname
  586      ;;
  587   *)
  588      _G_IFS=$IFS
  589      IFS=${PATH_SEPARATOR-:}
  590      for progdir in $PATH; do
  591        IFS=$_G_IFS
  592        test -x "$progdir/$progname" && break
  593      done
  594      IFS=$_G_IFS
  595      test -n "$progdir" || progdir=`pwd`
  596      progpath=$progdir/$progname
  597      ;;
  598 esac
  599 
  600 
  601 ## ----------------- ##
  602 ## Standard options. ##
  603 ## ----------------- ##
  604 
  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.
  608 
  609 opt_dry_run=false
  610 opt_quiet=false
  611 opt_verbose=false
  612 
  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
  615 # code.
  616 warning_categories=
  617 
  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
  622 
  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
  627 
  628 
  629 ## -------------------- ##
  630 ## Resource management. ##
  631 ## -------------------- ##
  632 
  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.
  638 #
  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
  642 # callers.
  643 
  644 
  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 ()
  650 {
  651     $debug_cmd
  652 
  653     test -t 1 && {
  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"}
  658 
  659       if test 1 = "$USE_ANSI_COLORS"; then
  660         # Standard ANSI escape sequences
  661         tc_reset=''
  662         tc_bold='';   tc_standout=''
  663         tc_red='';   tc_green=''
  664         tc_blue='';  tc_cyan=''
  665       else
  666         # Otherwise trust the terminfo database after all.
  667         test -n "`tput sgr0 2>/dev/null`" && {
  668           tc_reset=`tput sgr0`
  669           test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
  670           tc_standout=$tc_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`
  676         }
  677       fi
  678     }
  679 
  680     require_term_colors=:
  681 }
  682 
  683 
  684 ## ----------------- ##
  685 ## Function library. ##
  686 ## ----------------- ##
  687 
  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.
  692 
  693 
  694 # func_append VAR VALUE
  695 # ---------------------
  696 # Append VALUE onto the existing contents of VAR.
  697 
  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
  700   # being used:
  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*) ;;
  707       *)
  708         : ${_G_HAVE_PLUSEQ_OP="yes"}
  709         ;;
  710     esac
  711   fi
  712 
  713   # _G_HAVE_PLUSEQ_OP
  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
  719 
  720 if test yes = "$_G_HAVE_PLUSEQ_OP"
  721 then
  722   # This is an XSI compatible shell, allowing a faster implementation...
  723   eval 'func_append ()
  724   {
  725     $debug_cmd
  726 
  727     eval "$1+=\$2"
  728   }'
  729 else
  730   # ...otherwise fall back to using expr, which is often a shell builtin.
  731   func_append ()
  732   {
  733     $debug_cmd
  734 
  735     eval "$1=\$$1\$2"
  736   }
  737 fi
  738 
  739 
  740 # func_append_quoted VAR VALUE
  741 # ----------------------------
  742 # Quote VALUE and append to the end of shell variable VAR, separated
  743 # by a space.
  744 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
  745   eval 'func_append_quoted ()
  746   {
  747     $debug_cmd
  748 
  749     func_quote_for_eval "$2"
  750     eval "$1+=\\ \$func_quote_for_eval_result"
  751   }'
  752 else
  753   func_append_quoted ()
  754   {
  755     $debug_cmd
  756 
  757     func_quote_for_eval "$2"
  758     eval "$1=\$$1\\ \$func_quote_for_eval_result"
  759   }
  760 fi
  761 
  762 
  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:
  767 #
  768 #   func_append_uniq options " --another-option option-argument"
  769 #
  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).
  773 func_append_uniq ()
  774 {
  775     $debug_cmd
  776 
  777     eval _G_current_value='`$ECHO $'$1'`'
  778     _G_delim=`expr "$2" : '\(.\)'`
  779 
  780     case $_G_delim$_G_current_value$_G_delim in
  781       *"$2$_G_delim"*) ;;
  782       *) func_append "$@" ;;
  783     esac
  784 }
  785 
  786 
  787 # func_arith TERM...
  788 # ------------------
  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
  793 
  794 if test yes = "$_G_HAVE_ARITH_OP"; then
  795   eval 'func_arith ()
  796   {
  797     $debug_cmd
  798 
  799     func_arith_result=$(( $* ))
  800   }'
  801 else
  802   func_arith ()
  803   {
  804     $debug_cmd
  805 
  806     func_arith_result=`expr "$@"`
  807   }
  808 fi
  809 
  810 
  811 # func_basename FILE
  812 # ------------------
  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##*/}'
  820   _d='case $1 in
  821         */*) func_dirname_result=${1%/*}$2 ;;
  822         *  ) func_dirname_result=$3        ;;
  823       esac'
  824 
  825 else
  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
  831       else
  832         func_append func_dirname_result "$2"
  833       fi'
  834 fi
  835 
  836 eval 'func_basename ()
  837 {
  838     $debug_cmd
  839 
  840     '"$_b"'
  841 }'
  842 
  843 
  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 ()
  849 {
  850     $debug_cmd
  851 
  852     '"$_d"'
  853 }'
  854 
  855 
  856 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
  857 # --------------------------------------------------------
  858 # Perform func_basename and func_dirname in a single function
  859 # call:
  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 ()
  869 {
  870     $debug_cmd
  871 
  872     '"$_b"'
  873     '"$_d"'
  874 }'
  875 
  876 
  877 # func_echo ARG...
  878 # ----------------
  879 # Echo program name prefixed message.
  880 func_echo ()
  881 {
  882     $debug_cmd
  883 
  884     _G_message=$*
  885 
  886     func_echo_IFS=$IFS
  887     IFS=$nl
  888     for _G_line in $_G_message; do
  889       IFS=$func_echo_IFS
  890       $ECHO "$progname: $_G_line"
  891     done
  892     IFS=$func_echo_IFS
  893 }
  894 
  895 
  896 # func_echo_all ARG...
  897 # --------------------
  898 # Invoke $ECHO with all args, space-separated.
  899 func_echo_all ()
  900 {
  901     $ECHO "$*"
  902 }
  903 
  904 
  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.
  909 func_echo_infix_1 ()
  910 {
  911     $debug_cmd
  912 
  913     $require_term_colors
  914 
  915     _G_infix=$1; shift
  916     _G_indent=$_G_infix
  917     _G_prefix="$progname: $_G_infix: "
  918     _G_message=$*
  919 
  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"
  922     do
  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"`
  926       }
  927     done
  928     _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
  929 
  930     func_echo_infix_1_IFS=$IFS
  931     IFS=$nl
  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
  935       _G_prefix=$_G_indent
  936     done
  937     IFS=$func_echo_infix_1_IFS
  938 }
  939 
  940 
  941 # func_error ARG...
  942 # -----------------
  943 # Echo program name prefixed message to standard error.
  944 func_error ()
  945 {
  946     $debug_cmd
  947 
  948     $require_term_colors
  949 
  950     func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
  951 }
  952 
  953 
  954 # func_fatal_error ARG...
  955 # -----------------------
  956 # Echo program name prefixed message to standard error, and exit.
  957 func_fatal_error ()
  958 {
  959     $debug_cmd
  960 
  961     func_error "$*"
  962     exit $EXIT_FAILURE
  963 }
  964 
  965 
  966 # func_grep EXPRESSION FILENAME
  967 # -----------------------------
  968 # Check whether EXPRESSION matches any line of FILENAME, without output.
  969 func_grep ()
  970 {
  971     $debug_cmd
  972 
  973     $GREP "$1" "$2" >/dev/null 2>&1
  974 }
  975 
  976 
  977 # func_len STRING
  978 # ---------------
  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" \
  982     && (eval 'x=a/b/c;
  983       test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
  984     && _G_HAVE_XSI_OPS=yes
  985 
  986 if test yes = "$_G_HAVE_XSI_OPS"; then
  987   eval 'func_len ()
  988   {
  989     $debug_cmd
  990 
  991     func_len_result=${#1}
  992   }'
  993 else
  994   func_len ()
  995   {
  996     $debug_cmd
  997 
  998     func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
  999   }
 1000 fi
 1001 
 1002 
 1003 # func_mkdir_p DIRECTORY-PATH
 1004 # ---------------------------
 1005 # Make sure the entire path to DIRECTORY-PATH is available.
 1006 func_mkdir_p ()
 1007 {
 1008     $debug_cmd
 1009 
 1010     _G_directory_path=$1
 1011     _G_dir_list=
 1012 
 1013     if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
 1014 
 1015       # Protect directory names starting with '-'
 1016       case $_G_directory_path in
 1017         -*) _G_directory_path=./$_G_directory_path ;;
 1018       esac
 1019 
 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
 1025 
 1026         # If the last portion added has no slash in it, the list is done
 1027         case $_G_directory_path in */*) ;; *) break ;; esac
 1028 
 1029         # ...otherwise throw away the child directory and loop
 1030         _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
 1031       done
 1032       _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
 1033 
 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 || :
 1041       done
 1042       IFS=$func_mkdir_p_IFS
 1043 
 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'"
 1047     fi
 1048 }
 1049 
 1050 
 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.
 1056 func_mktempdir ()
 1057 {
 1058     $debug_cmd
 1059 
 1060     _G_template=${TMPDIR-/tmp}/${1-$progname}
 1061 
 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-$$
 1065     else
 1066 
 1067       # If mktemp works, use that first and foremost
 1068       _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
 1069 
 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}$$
 1073 
 1074         func_mktempdir_umask=`umask`
 1075         umask 0077
 1076         $MKDIR "$_G_tmpdir"
 1077         umask $func_mktempdir_umask
 1078       fi
 1079 
 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'"
 1083     fi
 1084 
 1085     $ECHO "$_G_tmpdir"
 1086 }
 1087 
 1088 
 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 ()
 1095 {
 1096     $debug_cmd
 1097 
 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
 1102         s|/\./|/|g
 1103         t dotsl
 1104         s|/\.$|/|'
 1105     _G_collapseslashes='s|/\{1,\}|/|g'
 1106     _G_finalslash='s|/*$|/|'
 1107 
 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
 1113       "")
 1114         # Empty path, that just means $cwd.
 1115         func_stripname '' '/' "`pwd`"
 1116         func_normal_abspath_result=$func_stripname_result
 1117         return
 1118         ;;
 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.
 1122       ///*)
 1123         # Unusual form of absolute path, do nothing.
 1124         ;;
 1125       //*)
 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=/
 1130         ;;
 1131       /*)
 1132         # Absolute path, do nothing.
 1133         ;;
 1134       *)
 1135         # Relative path, prepend $cwd.
 1136         func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
 1137         ;;
 1138     esac
 1139 
 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"`
 1145     while :; do
 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=/
 1151         fi
 1152         break
 1153       fi
 1154       func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
 1155           -e "$_G_pathcar"`
 1156       func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
 1157           -e "$_G_pathcdr"`
 1158       # Figure out what to do with it
 1159       case $func_normal_abspath_tcomponent in
 1160         "")
 1161           # Trailing empty path component, ignore it.
 1162           ;;
 1163         ..)
 1164           # Parent dir; strip last assembled component from result.
 1165           func_dirname "$func_normal_abspath_result"
 1166           func_normal_abspath_result=$func_dirname_result
 1167           ;;
 1168         *)
 1169           # Actual path component, append it.
 1170           func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
 1171           ;;
 1172       esac
 1173     done
 1174     # Restore leading double-slash if one was found on entry.
 1175     func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
 1176 }
 1177 
 1178 
 1179 # func_notquiet ARG...
 1180 # --------------------
 1181 # Echo program name prefixed message only when not in quiet mode.
 1182 func_notquiet ()
 1183 {
 1184     $debug_cmd
 1185 
 1186     $opt_quiet || func_echo ${1+"$@"}
 1187 
 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
 1190     # work around that:
 1191     :
 1192 }
 1193 
 1194 
 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 ()
 1199 {
 1200     $debug_cmd
 1201 
 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
 1207 
 1208     # Ascend the tree starting from libdir
 1209     while :; do
 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=
 1215           break
 1216           ;;
 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=.
 1223           fi
 1224           break
 1225           ;;
 1226         *)
 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
 1233             break
 1234           fi
 1235           func_relative_path_result=../$func_relative_path_result
 1236           ;;
 1237       esac
 1238     done
 1239 
 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"
 1246     fi
 1247 
 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
 1252     fi
 1253 
 1254     test -n "$func_relative_path_result" || func_relative_path_result=.
 1255 
 1256     :
 1257 }
 1258 
 1259 
 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 ()
 1270 {
 1271     $debug_cmd
 1272 
 1273     func_quote_for_eval_unquoted_result=
 1274     func_quote_for_eval_result=
 1275     while test 0 -lt $#; do
 1276       case $1 in
 1277         *[\\\`\"\$]*)
 1278       _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
 1279         *)
 1280           _G_unquoted_arg=$1 ;;
 1281       esac
 1282       if test -n "$func_quote_for_eval_unquoted_result"; then
 1283     func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
 1284       else
 1285         func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
 1286       fi
 1287 
 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\"
 1296           ;;
 1297         *)
 1298           _G_quoted_arg=$_G_unquoted_arg
 1299       ;;
 1300       esac
 1301 
 1302       if test -n "$func_quote_for_eval_result"; then
 1303     func_append func_quote_for_eval_result " $_G_quoted_arg"
 1304       else
 1305         func_append func_quote_for_eval_result "$_G_quoted_arg"
 1306       fi
 1307       shift
 1308     done
 1309 }
 1310 
 1311 
 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 ()
 1317 {
 1318     $debug_cmd
 1319 
 1320     case $1 in
 1321       *[\\\`\"]*)
 1322     _G_arg=`$ECHO "$1" | $SED \
 1323         -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
 1324       *)
 1325         _G_arg=$1 ;;
 1326     esac
 1327 
 1328     case $_G_arg in
 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       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
 1334         _G_arg=\"$_G_arg\"
 1335         ;;
 1336     esac
 1337 
 1338     func_quote_for_expand_result=$_G_arg
 1339 }
 1340 
 1341 
 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 ()
 1350   {
 1351     $debug_cmd
 1352 
 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"}
 1358   }'
 1359 else
 1360   func_stripname ()
 1361   {
 1362     $debug_cmd
 1363 
 1364     case $2 in
 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\$%%"`;;
 1367     esac
 1368   }
 1369 fi
 1370 
 1371 
 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.
 1377 func_show_eval ()
 1378 {
 1379     $debug_cmd
 1380 
 1381     _G_cmd=$1
 1382     _G_fail_exp=${2-':'}
 1383 
 1384     func_quote_for_expand "$_G_cmd"
 1385     eval "func_notquiet $func_quote_for_expand_result"
 1386 
 1387     $opt_dry_run || {
 1388       eval "$_G_cmd"
 1389       _G_status=$?
 1390       if test 0 -ne "$_G_status"; then
 1391     eval "(exit $_G_status); $_G_fail_exp"
 1392       fi
 1393     }
 1394 }
 1395 
 1396 
 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 ()
 1403 {
 1404     $debug_cmd
 1405 
 1406     _G_cmd=$1
 1407     _G_fail_exp=${2-':'}
 1408 
 1409     $opt_quiet || {
 1410       func_quote_for_expand "$_G_cmd"
 1411       eval "func_echo $func_quote_for_expand_result"
 1412     }
 1413 
 1414     $opt_dry_run || {
 1415       eval "$_G_user_locale
 1416         $_G_cmd"
 1417       _G_status=$?
 1418       eval "$_G_safe_locale"
 1419       if test 0 -ne "$_G_status"; then
 1420     eval "(exit $_G_status); $_G_fail_exp"
 1421       fi
 1422     }
 1423 }
 1424 
 1425 
 1426 # func_tr_sh
 1427 # ----------
 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.
 1432 func_tr_sh ()
 1433 {
 1434     $debug_cmd
 1435 
 1436     case $1 in
 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'`
 1439       ;;
 1440     * )
 1441       func_tr_sh_result=$1
 1442       ;;
 1443     esac
 1444 }
 1445 
 1446 
 1447 # func_verbose ARG...
 1448 # -------------------
 1449 # Echo program name prefixed message in verbose mode only.
 1450 func_verbose ()
 1451 {
 1452     $debug_cmd
 1453 
 1454     $opt_verbose && func_echo "$*"
 1455 
 1456     :
 1457 }
 1458 
 1459 
 1460 # func_warn_and_continue ARG...
 1461 # -----------------------------
 1462 # Echo program name prefixed warning message to standard error.
 1463 func_warn_and_continue ()
 1464 {
 1465     $debug_cmd
 1466 
 1467     $require_term_colors
 1468 
 1469     func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
 1470 }
 1471 
 1472 
 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'.
 1479 func_warning ()
 1480 {
 1481     $debug_cmd
 1482 
 1483     # CATEGORY must be in the warning_categories list!
 1484     case " $warning_categories " in
 1485       *" $1 "*) ;;
 1486       *) func_internal_error "invalid warning category '$1'" ;;
 1487     esac
 1488 
 1489     _G_category=$1
 1490     shift
 1491 
 1492     case " $opt_warning_types " in
 1493       *" $_G_category "*) $warning_func ${1+"$@"} ;;
 1494     esac
 1495 }
 1496 
 1497 
 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.
 1507 func_sort_ver ()
 1508 {
 1509     $debug_cmd
 1510 
 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
 1513 }
 1514 
 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:
 1519 #
 1520 #  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
 1521 func_lt_ver ()
 1522 {
 1523     $debug_cmd
 1524 
 1525     test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
 1526 }
 1527 
 1528 
 1529 # Local variables:
 1530 # mode: shell-script
 1531 # sh-indentation: 2
 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"
 1535 # End:
 1536 #! /bin/sh
 1537 
 1538 # Set a version string for this script.
 1539 scriptversion=2014-01-07.03; # UTC
 1540 
 1541 # A portable, pluggable option parser for Bourne shell.
 1542 # Written by Gary V. Vaughan, 2010
 1543 
 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.
 1547 
 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.
 1552 
 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.
 1557 
 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/>.
 1560 
 1561 # Please report bugs or propose patches to gary@gnu.org.
 1562 
 1563 
 1564 ## ------ ##
 1565 ## Usage. ##
 1566 ## ------ ##
 1567 
 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
 1570 # of too.
 1571 #
 1572 # For the simplest scripts you might need only:
 1573 #
 1574 #   #!/bin/sh
 1575 #   . relative/path/to/funclib.sh
 1576 #   . relative/path/to/options-parser
 1577 #   scriptversion=1.0
 1578 #   func_options ${1+"$@"}
 1579 #   eval set dummy "$func_options_result"; shift
 1580 #   ...rest of your script...
 1581 #
 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; '.
 1585 #
 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.
 1589 #
 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
 1594 # '--verbose'.
 1595 #
 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.
 1600 
 1601 ## -------------- ##
 1602 ## Configuration. ##
 1603 ## -------------- ##
 1604 
 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
 1607 # option parser.
 1608 
 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]...'
 1615 
 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.
 1619 usage_message="\
 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
 1626 "
 1627 
 1628 # Additional text appended to 'usage_message' in response to '--help'.
 1629 long_help_message="
 1630 Warning categories include:
 1631        'all'          show all warnings
 1632        'none'         turn off all the warnings
 1633        'error'        warnings are treated as fatal errors"
 1634 
 1635 # Help message printed before fatal option parsing errors.
 1636 fatal_help="Try '\$progname --help' for more information."
 1637 
 1638 
 1639 
 1640 ## ------------------------- ##
 1641 ## Hook function management. ##
 1642 ## ------------------------- ##
 1643 
 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.
 1647 
 1648 # func_hookable FUNC_NAME
 1649 # -----------------------
 1650 # Declare that FUNC_NAME will run hooks added with
 1651 # 'func_add_hook FUNC_NAME ...'.
 1652 func_hookable ()
 1653 {
 1654     $debug_cmd
 1655 
 1656     func_append hookable_fns " $1"
 1657 }
 1658 
 1659 
 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'.
 1664 func_add_hook ()
 1665 {
 1666     $debug_cmd
 1667 
 1668     case " $hookable_fns " in
 1669       *" $1 "*) ;;
 1670       *) func_fatal_error "'$1' does not accept hook functions." ;;
 1671     esac
 1672 
 1673     eval func_append ${1}_hooks '" $2"'
 1674 }
 1675 
 1676 
 1677 # func_remove_hook FUNC_NAME HOOK_FUNC
 1678 # ------------------------------------
 1679 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
 1680 func_remove_hook ()
 1681 {
 1682     $debug_cmd
 1683 
 1684     eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
 1685 }
 1686 
 1687 
 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
 1694 # whitespace.
 1695 func_run_hooks ()
 1696 {
 1697     $debug_cmd
 1698 
 1699     case " $hookable_fns " in
 1700       *" $1 "*) ;;
 1701       *) func_fatal_error "'$1' does not support hook funcions.n" ;;
 1702     esac
 1703 
 1704     eval _G_hook_fns=\$$1_hooks; shift
 1705 
 1706     for _G_hook in $_G_hook_fns; do
 1707       eval $_G_hook '"$@"'
 1708 
 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
 1713     done
 1714 
 1715     func_quote_for_eval ${1+"$@"}
 1716     func_run_hooks_result=$func_quote_for_eval_result
 1717 }
 1718 
 1719 
 1720 
 1721 ## --------------- ##
 1722 ## Option parsing. ##
 1723 ## --------------- ##
 1724 
 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:
 1730 #
 1731 #    my_options_prep ()
 1732 #    {
 1733 #        $debug_cmd
 1734 #
 1735 #        # Extend the existing usage message.
 1736 #        usage_message=$usage_message'
 1737 #      -s, --silent       don'\''t print informational messages
 1738 #    '
 1739 #
 1740 #        func_quote_for_eval ${1+"$@"}
 1741 #        my_options_prep_result=$func_quote_for_eval_result
 1742 #    }
 1743 #    func_add_hook func_options_prep my_options_prep
 1744 #
 1745 #
 1746 #    my_silent_option ()
 1747 #    {
 1748 #        $debug_cmd
 1749 #
 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
 1754 #          opt=$1; shift
 1755 #          case $opt in
 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+"$@"}
 1761 #                         shift
 1762 #                         ;;
 1763 #            *)            set dummy "$_G_opt" "$*"; shift; break ;;
 1764 #          esac
 1765 #        done
 1766 #
 1767 #        func_quote_for_eval ${1+"$@"}
 1768 #        my_silent_option_result=$func_quote_for_eval_result
 1769 #    }
 1770 #    func_add_hook func_parse_options my_silent_option
 1771 #
 1772 #
 1773 #    my_option_validation ()
 1774 #    {
 1775 #        $debug_cmd
 1776 #
 1777 #        $opt_silent && $opt_verbose && func_fatal_help "\
 1778 #    '--silent' and '--verbose' options are mutually exclusive."
 1779 #
 1780 #        func_quote_for_eval ${1+"$@"}
 1781 #        my_option_validation_result=$func_quote_for_eval_result
 1782 #    }
 1783 #    func_add_hook func_validate_options my_option_validation
 1784 #
 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.
 1788 
 1789 
 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
 1795 func_options ()
 1796 {
 1797     $debug_cmd
 1798 
 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"}
 1804 
 1805     eval func_run_hooks func_options \
 1806         ${func_validate_options_result+"$func_validate_options_result"}
 1807 
 1808     # save modified positional parameters for caller
 1809     func_options_result=$func_run_hooks_result
 1810 }
 1811 
 1812 
 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
 1820 # returning.
 1821 func_hookable func_options_prep
 1822 func_options_prep ()
 1823 {
 1824     $debug_cmd
 1825 
 1826     # Option defaults:
 1827     opt_verbose=false
 1828     opt_warning_types=
 1829 
 1830     func_run_hooks func_options_prep ${1+"$@"}
 1831 
 1832     # save modified positional parameters for caller
 1833     func_options_prep_result=$func_run_hooks_result
 1834 }
 1835 
 1836 
 1837 # func_parse_options [ARG]...
 1838 # ---------------------------
 1839 # The main option parsing loop.
 1840 func_hookable func_parse_options
 1841 func_parse_options ()
 1842 {
 1843     $debug_cmd
 1844 
 1845     func_parse_options_result=
 1846 
 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+"$@"}
 1852 
 1853       # Adjust func_parse_options positional parameters to match
 1854       eval set dummy "$func_run_hooks_result"; shift
 1855 
 1856       # Break out of the loop if we already parsed every option.
 1857       test $# -gt 0 || break
 1858 
 1859       _G_opt=$1
 1860       shift
 1861       case $_G_opt in
 1862         --debug|-x)   debug_cmd='set -x'
 1863                       func_echo "enabling shell trace mode"
 1864                       $debug_cmd
 1865                       ;;
 1866 
 1867         --no-warnings|--no-warning|--no-warn)
 1868                       set dummy --warnings none ${1+"$@"}
 1869                       shift
 1870               ;;
 1871 
 1872         --warnings|--warning|-W)
 1873                       test $# = 0 && func_missing_arg $_G_opt && break
 1874                       case " $warning_categories $1" in
 1875                         *" $1 "*)
 1876                           # trailing space prevents matching last $1 above
 1877                           func_append_uniq opt_warning_types " $1"
 1878                           ;;
 1879                         *all)
 1880                           opt_warning_types=$warning_categories
 1881                           ;;
 1882                         *none)
 1883                           opt_warning_types=none
 1884                           warning_func=:
 1885                           ;;
 1886                         *error)
 1887                           opt_warning_types=$warning_categories
 1888                           warning_func=func_fatal_error
 1889                           ;;
 1890                         *)
 1891                           func_fatal_error \
 1892                              "unsupported warning category: '$1'"
 1893                           ;;
 1894                       esac
 1895                       shift
 1896                       ;;
 1897 
 1898         --verbose|-v) opt_verbose=: ;;
 1899         --version)    func_version ;;
 1900         -\?|-h)       func_usage ;;
 1901         --help)       func_help ;;
 1902 
 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+"$@"}
 1907                       shift
 1908                       ;;
 1909 
 1910        # Separate optargs to short options:
 1911         -W*)
 1912                       func_split_short_opt "$_G_opt"
 1913                       set dummy "$func_split_short_opt_name" \
 1914                           "$func_split_short_opt_arg" ${1+"$@"}
 1915                       shift
 1916                       ;;
 1917 
 1918         # Separate non-argument short options:
 1919         -\?*|-h*|-v*|-x*)
 1920                       func_split_short_opt "$_G_opt"
 1921                       set dummy "$func_split_short_opt_name" \
 1922                           "-$func_split_short_opt_arg" ${1+"$@"}
 1923                       shift
 1924                       ;;
 1925 
 1926         --)           break ;;
 1927         -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
 1928         *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
 1929       esac
 1930     done
 1931 
 1932     # save modified positional parameters for caller
 1933     func_quote_for_eval ${1+"$@"}
 1934     func_parse_options_result=$func_quote_for_eval_result
 1935 }
 1936 
 1937 
 1938 # func_validate_options [ARG]...
 1939 # ------------------------------
 1940 # Perform any sanity checks on option settings and/or unconsumed
 1941 # arguments.
 1942 func_hookable func_validate_options
 1943 func_validate_options ()
 1944 {
 1945     $debug_cmd
 1946 
 1947     # Display all warnings if -W was not given.
 1948     test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
 1949 
 1950     func_run_hooks func_validate_options ${1+"$@"}
 1951 
 1952     # Bail if the options were screwed!
 1953     $exit_cmd $EXIT_FAILURE
 1954 
 1955     # save modified positional parameters for caller
 1956     func_validate_options_result=$func_run_hooks_result
 1957 }
 1958 
 1959 
 1960 
 1961 ## ----------------- ##
 1962 ## Helper functions. ##
 1963 ## ----------------- ##
 1964 
 1965 # This section contains the helper functions used by the rest of the
 1966 # hookable option parser framework in ascii-betical order.
 1967 
 1968 
 1969 # func_fatal_help ARG...
 1970 # ----------------------
 1971 # Echo program name prefixed message to standard error, followed by
 1972 # a help hint, and exit.
 1973 func_fatal_help ()
 1974 {
 1975     $debug_cmd
 1976 
 1977     eval \$ECHO \""Usage: $usage"\"
 1978     eval \$ECHO \""$fatal_help"\"
 1979     func_error ${1+"$@"}
 1980     exit $EXIT_FAILURE
 1981 }
 1982 
 1983 
 1984 # func_help
 1985 # ---------
 1986 # Echo long help message to standard output and exit.
 1987 func_help ()
 1988 {
 1989     $debug_cmd
 1990 
 1991     func_usage_message
 1992     $ECHO "$long_help_message"
 1993     exit 0
 1994 }
 1995 
 1996 
 1997 # func_missing_arg ARGNAME
 1998 # ------------------------
 1999 # Echo program name prefixed message to standard error and set global
 2000 # exit_cmd.
 2001 func_missing_arg ()
 2002 {
 2003     $debug_cmd
 2004 
 2005     func_error "Missing argument for '$1'."
 2006     exit_cmd=exit
 2007 }
 2008 
 2009 
 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" \
 2015     && (eval 'x=a/b/c;
 2016       test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
 2017     && _G_HAVE_XSI_OPS=yes
 2018 
 2019 if test yes = "$_G_HAVE_XSI_OPS"
 2020 then
 2021   # This is an XSI compatible shell, allowing a faster implementation...
 2022   eval 'func_split_equals ()
 2023   {
 2024       $debug_cmd
 2025 
 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=
 2030   }'
 2031 else
 2032   # ...otherwise fall back to using expr, which is often a shell builtin.
 2033   func_split_equals ()
 2034   {
 2035       $debug_cmd
 2036 
 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[^=]*=\(.*\)$'`
 2041   }
 2042 fi #func_split_equals
 2043 
 2044 
 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"
 2050 then
 2051   # This is an XSI compatible shell, allowing a faster implementation...
 2052   eval 'func_split_short_opt ()
 2053   {
 2054       $debug_cmd
 2055 
 2056       func_split_short_opt_arg=${1#??}
 2057       func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
 2058   }'
 2059 else
 2060   # ...otherwise fall back to using expr, which is often a shell builtin.
 2061   func_split_short_opt ()
 2062   {
 2063       $debug_cmd
 2064 
 2065       func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
 2066       func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
 2067   }
 2068 fi #func_split_short_opt
 2069 
 2070 
 2071 # func_usage
 2072 # ----------
 2073 # Echo short help message to standard output and exit.
 2074 func_usage ()
 2075 {
 2076     $debug_cmd
 2077 
 2078     func_usage_message
 2079     $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
 2080     exit 0
 2081 }
 2082 
 2083 
 2084 # func_usage_message
 2085 # ------------------
 2086 # Echo short help message to standard output.
 2087 func_usage_message ()
 2088 {
 2089     $debug_cmd
 2090 
 2091     eval \$ECHO \""Usage: $usage"\"
 2092     echo
 2093     $SED -n 's|^# ||
 2094         /^Written by/{
 2095           x;p;x
 2096         }
 2097     h
 2098     /^Written by/q' < "$progpath"
 2099     echo
 2100     eval \$ECHO \""$usage_message"\"
 2101 }
 2102 
 2103 
 2104 # func_version
 2105 # ------------
 2106 # Echo version message to standard output and exit.
 2107 func_version ()
 2108 {
 2109     $debug_cmd
 2110 
 2111     printf '%s\n' "$progname $scriptversion"
 2112     $SED -n '
 2113         /(C)/!b go
 2114         :more
 2115         /\./!{
 2116           N
 2117           s|\n# | |
 2118           b more
 2119         }
 2120         :go
 2121         /^# Written by /,/# warranty; / {
 2122           s|^# ||
 2123           s|^# *$||
 2124           s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
 2125           p
 2126         }
 2127         /^# Written by / {
 2128           s|^# ||
 2129           p
 2130         }
 2131         /^warranty; /q' < "$progpath"
 2132 
 2133     exit $?
 2134 }
 2135 
 2136 
 2137 # Local variables:
 2138 # mode: shell-script
 2139 # sh-indentation: 2
 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"
 2143 # End:
 2144 #! /bin/sh
 2145 
 2146 # Extract macro arguments from autotools input with GNU M4.
 2147 # Written by Gary V. Vaughan, 2010
 2148 #
 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.
 2152 
 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
 2156 
 2157 # Set a version string.
 2158 scriptversion=2015-01-20.17; # UTC
 2159 
 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.
 2164 
 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.
 2169 
 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/>.
 2172 
 2173 # Please report bugs or propose patches to gary@gnu.org.
 2174 
 2175 
 2176 ## ------ ##
 2177 ## Usage. ##
 2178 ## ------ ##
 2179 
 2180 # Run './extract-trace --help' for help with using this script from the
 2181 # command line.
 2182 #
 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.
 2187 
 2188 
 2189 
 2190 ## ----------------- ##
 2191 ## Helper functions. ##
 2192 ## ----------------- ##
 2193 
 2194 # This section contains the helper functions used by the rest of
 2195 # 'extract-trace'.
 2196 
 2197 
 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 ()
 2203 {
 2204     $debug_cmd
 2205 
 2206     _G_sed_no_comment='
 2207       s|#.*$||
 2208       s|^dnl .*$||
 2209       s| dnl .*$||'
 2210     _G_ac_init=
 2211 
 2212     # If we were passed a genuine file, make sure it calls AC_INIT.
 2213     test -f "$1" \
 2214       && _G_ac_init=`$SED "$_G_sed_no_comment" "$1" |$GREP AC_INIT`
 2215 
 2216     # Otherwise it is not a genuine Autoconf input file.
 2217     test -n "$_G_ac_init"
 2218     _G_status=$?
 2219 
 2220     test 0 -ne "$_G_status" \
 2221       && func_verbose "'$1' not using Autoconf"
 2222 
 2223     (exit $_G_status)
 2224 }
 2225 
 2226 
 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
 2235 # status.
 2236 func_tool_version_output ()
 2237 {
 2238     $debug_cmd
 2239 
 2240     _G_cmd=$1
 2241     _G_fatal_error_msg=$2
 2242 
 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
 2252     _G_status=$?
 2253 
 2254     test 0 -ne "$_G_status" && test -n "$_G_fatal_error_msg" \
 2255         && func_fatal_error "$_G_fatal_error_msg"
 2256 
 2257     (exit $_G_status)
 2258 }
 2259 
 2260 
 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 ()
 2267 {
 2268     $debug_cmd
 2269 
 2270     _G_verout=`func_tool_version_output "$@"`
 2271     _G_status=$?
 2272 
 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][^ ]*\)'`
 2278     fi
 2279 
 2280     if test -n "$_G_vernum"; then
 2281       printf '%s\n' "$_G_vernum"
 2282     else
 2283       printf '%s\n' "$_G_verout"
 2284     fi
 2285 
 2286     (exit $_G_status)
 2287 }
 2288 
 2289 
 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,
 2295 # die otherwise.
 2296 func_find_tool ()
 2297 {
 2298     $debug_cmd
 2299 
 2300     _G_find_tool_envvar=$1
 2301     shift
 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: "
 2306     else
 2307       _G_find_tool_res=
 2308       _G_bestver=
 2309       for _G_prog
 2310       do
 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
 2319         ,)
 2320           # first non--version responsive prog sticks!
 2321               test -n "$_G_progpath" || _G_find_tool_res=$_G_progpath
 2322               ;;
 2323             ,*)
 2324           # first --version responsive prog beats non--version responsive!
 2325           _G_find_tool_res=$_G_progpath
 2326           _G_bestver=$_G_curver
 2327           ;;
 2328         *,*)
 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" \
 2332         || {
 2333              _G_find_tool_res=$_G_progpath
 2334              _G_bestver=$_G_curver
 2335                }
 2336           ;;
 2337         esac
 2338           }
 2339     done
 2340     IFS=$_G_find_tool_save_IFS
 2341       done
 2342     fi
 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'"
 2346 
 2347       # Make sure the result is exported to the environment for children
 2348       # to use.
 2349       eval "$_G_find_tool_envvar=\$_G_find_tool_res"
 2350       eval "export $_G_find_tool_envvar"
 2351     else
 2352       func_error "\
 2353 One of these is required:
 2354        $_G_find_tool_names"
 2355     fi
 2356 }
 2357 
 2358 
 2359 
 2360 ## -------------------- ##
 2361 ## Resource management. ##
 2362 ## -------------------- ##
 2363 
 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
 2371 # most, once.
 2372 #
 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
 2376 # callers.
 2377 
 2378 
 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 ()
 2386 {
 2387     $debug_cmd
 2388 
 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'"
 2395 
 2396     require_configure_ac=:
 2397 }
 2398 
 2399 
 2400 # require_gnu_m4
 2401 # --------------
 2402 # Search for GNU M4, and export it in $M4.
 2403 require_gnu_m4=func_require_gnu_m4
 2404 func_require_gnu_m4 ()
 2405 {
 2406     $debug_cmd
 2407 
 2408     test -n "$M4" || {
 2409       # Find the first m4 binary that responds to --version.
 2410       func_find_tool M4 gm4 gnum4 m4
 2411     }
 2412 
 2413     test -n "$M4" || func_fatal_error "\
 2414 Please install GNU M4, or 'export M4=/path/to/gnu/m4'."
 2415 
 2416     func_verbose "export M4='$M4'"
 2417 
 2418     # Make sure the search result is visible to subshells
 2419     export M4
 2420 
 2421     require_gnu_m4=:
 2422 }
 2423 
 2424 
 2425 ## --------------- ##
 2426 ## Core functions. ##
 2427 ## --------------- ##
 2428 
 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.
 2432 
 2433 
 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 ()
 2440 {
 2441     $debug_cmd
 2442 
 2443     $require_configure_ac
 2444     $require_gnu_m4
 2445 
 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
 2449     test $# -gt 0 || {
 2450       set dummy $configure_ac
 2451       shift
 2452     }
 2453 
 2454     # Generate an error if the first file is missing
 2455     <"$1"
 2456 
 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.
 2462     #
 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):
 2466     #
 2467     #    autom4te --language=Autoconf --trace=$my_macro:\$% "$@"
 2468     #
 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.
 2474     _G_mini='
 2475         # Initialisation.
 2476         m4_changequote([,])
 2477         m4_define([m4_copy],   [m4_define([$2], m4_defn([$1]))])
 2478         m4_define([m4_rename], [m4_copy([$1], [$2])m4_undefine([$1])])
 2479 
 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])
 2486 
 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])
 2494 
 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($@)))])
 2507 
 2508         # "autoconf.mini" - things from autoconf macros we care about.
 2509         m4_copy([m4_defun], [AC_DEFUN])
 2510 
 2511         # Dummy definitions for the macros we want to trace.
 2512         # AM_INIT_AUTOMAKE at least produces no trace without this.
 2513     '
 2514 
 2515     _G_save=$IFS
 2516     IFS=,
 2517     for _G_macro in $_G_macros; do
 2518       IFS=$_G_save
 2519       func_append _G_mini "AC_DEFUN([$_G_macro])$nl"
 2520     done
 2521     IFS=$_G_save
 2522 
 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 .*$||;'
 2528 
 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.
 2532     _G_save=$IFS
 2533     IFS=,
 2534     for _G_macro in $_G_macros; do
 2535       IFS=$_G_save
 2536       func_append _G_transform '
 2537         /^m4trace: -1- '"$_G_macro"'/ {
 2538           s|^m4trace: -1- '"$_G_macro"'[([]*||
 2539           s|], [[]|:|g
 2540           s|[])]*$|:|
 2541           s|\(.\):$|\1|
 2542           p
 2543         }'
 2544     done
 2545     IFS=$_G_save
 2546 
 2547     # Save the command pipeline results for further use by callers of
 2548     # this function.
 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"`
 2552 }
 2553 
 2554 
 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 ()
 2561 {
 2562     $debug_cmd
 2563 
 2564     func_extract_trace ${1+"$@"}
 2565     func_extract_trace_first_result=`$ECHO "$func_extract_trace_result" \
 2566       |$SED -e 's|:.*$||g' -e 1q`
 2567 }
 2568 
 2569 
 2570 # func_main [ARG]...
 2571 # ------------------
 2572 func_main ()
 2573 {
 2574     $debug_cmd
 2575 
 2576     # Configuration.
 2577     usage='$progname MACRO_NAME FILE [...]'
 2578 
 2579     long_help_message='
 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,
 2583 GNU M4.
 2584 
 2585 The arguments are returned separated by colons, with each traced call
 2586 on a separate line.'
 2587 
 2588     # Option processing.
 2589     func_options "$@"
 2590     eval set dummy "$func_options_result"; shift
 2591 
 2592     # Validate remaining non-option arguments.
 2593     test $# -gt 1 \
 2594         || func_fatal_help "not enough arguments"
 2595 
 2596     # Pass non-option arguments to extraction function.
 2597     func_extract_trace "$@"
 2598 
 2599     # Display results.
 2600     test -n "$func_extract_trace_result" \
 2601         && $ECHO "$func_extract_trace_result"
 2602 
 2603     # The End.
 2604     exit $EXIT_SUCCESS
 2605 }
 2606 
 2607 
 2608 ## --------------------------- ##
 2609 ## Actually perform the trace. ##
 2610 ## --------------------------- ##
 2611 
 2612 # Only call 'func_main' if this script was called directly.
 2613 test extract-trace = "$progname" && func_main "$@"
 2614 
 2615 # Local variables:
 2616 # mode: shell-script
 2617 # sh-indentation: 2
 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"
 2621 # End:
 2622 
 2623 # Set a version string for *this* script.
 2624 scriptversion=2015-01-20.17; # UTC
 2625 
 2626 
 2627 ## ------------------- ##
 2628 ## Hookable functions. ##
 2629 ## ------------------- ##
 2630 
 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'.
 2636 #
 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.
 2640 
 2641 
 2642 # func_bootstrap [ARG]...
 2643 # -----------------------
 2644 # All the functions called inside func_bootstrap are hookable. See the
 2645 # the individual implementations for details.
 2646 func_bootstrap ()
 2647 {
 2648     $debug_cmd
 2649 
 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
 2654 
 2655     # Initialisation.
 2656     func_init
 2657 
 2658     # Option processing.
 2659     eval func_options "$_G_saved_positional_parameters"
 2660 
 2661     # Post-option preparation.
 2662     func_prep
 2663 
 2664     # Reconfigure the package.
 2665     func_reconfigure
 2666 
 2667     # Ensure .version is up-to-date.
 2668     func_update_dotversion
 2669 
 2670     # Finalisation.
 2671     func_fini
 2672 }
 2673 
 2674 
 2675 # func_init
 2676 # ---------
 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
 2682 func_init ()
 2683 {
 2684     $debug_cmd
 2685 
 2686     func_run_hooks func_init
 2687 }
 2688 
 2689 
 2690 # func_prep
 2691 # ---------
 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'.
 2695 #
 2696 # All the functions called inside func_prep are hookable. See the
 2697 # individual implementations for details.
 2698 func_hookable func_prep
 2699 func_prep ()
 2700 {
 2701     $debug_cmd
 2702 
 2703     $require_buildtools_uptodate
 2704     $require_checkout_only_file
 2705 
 2706     $require_gnulib_merge_changelog
 2707 
 2708     # Report the results of SED and GREP searches from funclib.sh.
 2709     func_verbose "GREP='$GREP'"
 2710     func_verbose "SED='$SED'"
 2711 
 2712     # fetch update files from the translation project
 2713     func_update_translations
 2714 
 2715     func_run_hooks func_prep
 2716 }
 2717 
 2718 
 2719 # func_update_translations
 2720 # ------------------------
 2721 # Update package po files and translations.
 2722 func_hookable func_update_translations
 2723 func_update_translations ()
 2724 {
 2725     $debug_cmd
 2726 
 2727     $opt_skip_po || {
 2728       test -d po && {
 2729         $require_package
 2730 
 2731         func_update_po_files po $package || exit $?
 2732       }
 2733 
 2734       func_run_hooks func_update_translations
 2735     }
 2736 }
 2737 
 2738 
 2739 # func_reconfigure
 2740 # ----------------
 2741 # Reconfigure the current package by running the appropriate autotools in a
 2742 # suitable order.
 2743 func_hookable func_reconfigure
 2744 func_reconfigure ()
 2745 {
 2746     $debug_cmd
 2747 
 2748     $require_automake_options
 2749 
 2750     # Automake (without 'foreign' option) requires that NEWS & README exist.
 2751     case " $automake_options " in
 2752       " foreign ") ;;
 2753       *)
 2754         func_ensure_NEWS
 2755         func_ensure_README
 2756         ;;
 2757     esac
 2758 
 2759     # Ensure ChangeLog presence.
 2760     if test -n "$gnulib_modules"; then
 2761       func_ifcontains "$gnulib_modules" gitlog-to-changelog \
 2762         func_ensure_changelog
 2763     else
 2764       $require_gnulib_cache
 2765       if $SED -n '/^gl_MODULES(\[/,/^])$/p' $gnulib_cache 2>/dev/null |
 2766          func_grep_q gitlog-to-changelog
 2767       then
 2768         func_ensure_changelog
 2769       fi
 2770     fi
 2771 
 2772     # Released 'autopoint' has the tendency to install macros that have
 2773     # been obsoleted in current 'gnulib', so run this before 'gnulib-tool'.
 2774     func_autopoint
 2775 
 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.
 2779     func_libtoolize
 2780 
 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.
 2784     func_gnulib_tool
 2785 
 2786     func_autoreconf
 2787 
 2788     func_run_hooks func_reconfigure
 2789 }
 2790 
 2791 
 2792 # func_gnulib_tool
 2793 # ----------------
 2794 # Run 'gnulib-tool' to fetch gnulib modules into the current package.
 2795 #
 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:
 2799 #
 2800 #   func_gnulib_tool () { :; }
 2801 #
 2802 # (although the function returns immediately if $gnulib_tool is set to
 2803 # true in any case).
 2804 func_hookable func_gnulib_tool
 2805 func_gnulib_tool ()
 2806 {
 2807     $debug_cmd
 2808 
 2809     $require_gnulib_tool
 2810     $require_libtoolize
 2811 
 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"
 2819 
 2820       if test -n "$gnulib_modules"; then
 2821         $require_gnulib_cache
 2822         $require_gnulib_tool_base_options
 2823 
 2824         gnulib_mode=--import
 2825 
 2826         # Try not to pick up any stale values from 'gnulib-cache.m4'.
 2827         rm -f "$gnulib_cache"
 2828 
 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"
 2836         }
 2837       else
 2838 
 2839         # 'gnulib_modules' and others are cached in 'gnulib-cache.m4':
 2840         # Use 'gnulib --update' to fetch gnulib modules.
 2841         gnulib_mode=--update
 2842       fi
 2843 
 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"
 2850             else
 2851               func_append_uniq gnulib_tool_all_options " --libtool"
 2852             fi
 2853             ;;
 2854       esac
 2855 
 2856       $opt_copy || func_append_uniq gnulib_tool_all_options " --symlink"
 2857 
 2858       func_append_uniq gnulib_tool_all_options " $gnulib_mode"
 2859       func_append gnulib_tool_all_options " $gnulib_modules"
 2860 
 2861       # The embedded echo is to squash whitespace before display.
 2862       gnulib_cmd=`echo $gnulib_tool $gnulib_tool_all_options`
 2863 
 2864       func_show_eval "$gnulib_cmd" 'exit $?'
 2865 
 2866       # Use 'gnulib-tool --copy-file' to install non-module files.
 2867       func_install_gnulib_non_module_files
 2868     }
 2869 
 2870     func_run_hooks func_gnulib_tool
 2871 }
 2872 
 2873 
 2874 # func_fini
 2875 # ---------
 2876 # Function to perform all finalisation for the bootstrap process.
 2877 func_hookable func_fini
 2878 func_fini ()
 2879 {
 2880     $debug_cmd
 2881 
 2882     func_gettext_configuration
 2883     func_clean_dangling_symlinks
 2884     func_clean_unused_macros
 2885     func_skip_po_recommendation
 2886 
 2887     func_run_hooks func_fini
 2888 
 2889     $require_bootstrap_uptodate
 2890 
 2891     func_echo "Done.  Now you can run './configure'."
 2892 }
 2893 
 2894 
 2895 # func_gettext_configuration
 2896 # --------------------------
 2897 # Edit configuration values into po/Makevars.
 2898 func_hookable func_gettext_configuration
 2899 func_gettext_configuration ()
 2900 {
 2901     $debug_cmd
 2902 
 2903     $require_autopoint
 2904 
 2905     test true = "$AUTOPOINT" || {
 2906       $require_copyright_holder
 2907       $require_extra_locale_categories
 2908       $require_package_bugreport
 2909 
 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 '
 2918           $b
 2919           s|$| \\\\\\\\\\\\|'`
 2920 
 2921       # Create gettext configuration.
 2922       func_echo "Creating po/Makevars from po/Makevars.template ..."
 2923       $RM -f po/Makevars
 2924       $SED '
 2925         /^EXTRA_LOCALE_CATEGORIES *=/s|=.*|= '"$extra_locale_categories"'|
 2926         /^COPYRIGHT_HOLDER *=/s|=.*|= '"$copyright_holder"'|
 2927         /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$package_bugreport"'|
 2928         /^XGETTEXT_OPTIONS *=/{
 2929           s|$| \\|
 2930           a\
 2931              '"$_G_xgettext_options"' \\\
 2932              $${end_of_xgettext_options+}
 2933         }
 2934       ' po/Makevars.template >po/Makevars || exit 1
 2935     }
 2936 
 2937     func_run_hooks func_gettext_configuration
 2938 }
 2939 
 2940 
 2941 
 2942 ## --------------- ##
 2943 ## Core functions. ##
 2944 ## --------------- ##
 2945 
 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'.
 2949 
 2950 
 2951 # func_autopoint
 2952 # --------------
 2953 # If this package uses gettext, then run 'autopoint'.
 2954 func_autopoint ()
 2955 {
 2956     $debug_cmd
 2957 
 2958     $require_autopoint
 2959 
 2960     test true = "$AUTOPOINT" \
 2961         || func_show_eval "$AUTOPOINT --force" 'exit $?'
 2962 }
 2963 
 2964 
 2965 # func_libtoolize
 2966 # ---------------
 2967 # If this package uses libtool, then run 'libtoolize'.
 2968 func_libtoolize ()
 2969 {
 2970     $debug_cmd
 2971 
 2972     $require_libtoolize
 2973 
 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 $?'
 2980     }
 2981 }
 2982 
 2983 
 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 ()
 2990 {
 2991     $debug_cmd
 2992 
 2993     $require_gnulib_tool
 2994     $require_patch
 2995 
 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."
 3008     else
 3009       $require_gnulib_copy_cmd
 3010 
 3011       $gnulib_copy_cmd $1 $2 2>/dev/null || {
 3012         $require_gnulib_path
 3013 
 3014         func_error "'$gnulib_path/$1' does not exist"
 3015         return 1
 3016       }
 3017     fi
 3018 }
 3019 
 3020 
 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 ()
 3025 {
 3026     $debug_cmd
 3027 
 3028     $require_build_aux
 3029     $require_gnulib_tool
 3030 
 3031     test -n "$gnulib_non_module_files" && {
 3032       maybe_exit_cmd=:
 3033 
 3034       for file in $gnulib_non_module_files; do
 3035         case $file in
 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."
 3042             ;;
 3043           build-aux/*) dest=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
 3044           *) dest=$file;;
 3045         esac
 3046 
 3047         # Be sure to show all copying errors before bailing out
 3048     test -z "$dest" \
 3049         || func_gnulib_tool_copy_file "$file" "$dest" \
 3050         || maybe_exit_cmd="exit $EXIT_FAILURE"
 3051       done
 3052 
 3053       $maybe_exit_cmd
 3054     }
 3055 }
 3056 
 3057 
 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 ()
 3063 {
 3064     $debug_cmd
 3065 
 3066     test -f ChangeLog && mv -f ChangeLog ChangeLog~
 3067 
 3068     cat >ChangeLog <<'EOT'
 3069 ## ---------------------- ##
 3070 ## DO NOT EDIT THIS FILE! ##
 3071 ## ---------------------- ##
 3072 
 3073 ChangeLog is generated by gitlog-to-changelog.
 3074 EOT
 3075 
 3076     _G_message="creating dummy 'ChangeLog'"
 3077     test -f ChangeLog~ \
 3078       && func_append _G_message ' (backup in ChangeLog~)'
 3079     func_verbose "$_G_message"
 3080 
 3081     return 0
 3082 }
 3083 
 3084 
 3085 # func_ensure_NEWS
 3086 # ----------------
 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.
 3090 func_ensure_NEWS ()
 3091 {
 3092     $debug_cmd
 3093 
 3094     test -f NEWS || {
 3095       _G_NEWS=
 3096       for _G_news in NEWS.txt NEWS.md NEWS.rst; do
 3097         test -f "$_G_news" && break
 3098       done
 3099 
 3100       test -f "$_G_news" && $LN_S $_G_news NEWS
 3101       func_verbose "$LN_S $_G_news NEWS"
 3102     }
 3103 
 3104     return 0
 3105 }
 3106 
 3107 
 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 ()
 3114 {
 3115     $debug_cmd
 3116 
 3117     test -f README || {
 3118       _G_README=
 3119       for _G_readme in README.txt README.md README.rst; do
 3120         test -f "$_G_readme" && break
 3121       done
 3122 
 3123       test -f "$_G_readme" && $LN_S $_G_readme README
 3124       func_verbose "$LN_S $_G_readme README"
 3125     }
 3126 
 3127     return 0
 3128 }
 3129 
 3130 
 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.
 3137 #
 3138 # Projects with multiple trees to reconfigure can hook another call to
 3139 # this function onto func_reconfigure:
 3140 #
 3141 #    my_autoreconf_foo ()
 3142 #    {
 3143 #        func_autoreconf foo
 3144 #    }
 3145 #    func_add_hook func_reconfigure my_autoreconf_foo
 3146 func_autoreconf ()
 3147 {
 3148     $debug_cmd
 3149 
 3150     $require_autoheader
 3151     $require_build_aux  # automake and others put files in here
 3152     $require_macro_dir  # aclocal and others put files in here
 3153 
 3154     # We ran these manually already, and autoreconf won't exec ':'
 3155     save_AUTOPOINT=$AUTOPOINT; AUTOPOINT=true
 3156     save_LIBTOOLIZE=$LIBTOOLIZE; LIBTOOLIZE=true
 3157 
 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 $?'
 3163 
 3164     AUTOPOINT=$save_AUTOPOINT
 3165     LIBTOOLIZE=$save_LIBTOOLIZE
 3166 }
 3167 
 3168 
 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 ()
 3174 {
 3175     $debug_cmd
 3176 
 3177     $require_configure_ac
 3178 
 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':
 3184 $2"
 3185       fi
 3186 
 3187       func_fatal_error "$_G_error_msg"
 3188     }
 3189 }
 3190 
 3191 
 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 ()
 3203 {
 3204     $debug_cmd
 3205 
 3206     $require_macro_dir
 3207     $require_source_base
 3208 
 3209     func_verbose "cleaning dangling symlinks"
 3210 
 3211     find "$macro_dir" "$source_base" \
 3212         -depth \( -name '*.m4' -o -name '*.[ch]' \) \
 3213         -type l -xtype l -delete > /dev/null 2>&1
 3214 }
 3215 
 3216 
 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 ()
 3226 {
 3227     $debug_cmd
 3228 
 3229     $require_gnulib_path
 3230     $require_macro_dir
 3231 
 3232     test -n "$gnulib_path" && test -f aclocal.m4 && {
 3233       aclocal_m4s=`find . -name aclocal.m4 -print`
 3234 
 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
 3238 
 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" || {
 3242 
 3243               # ...and there is an identical file in gnulib...
 3244               if func_cmp_s "$gnulib_path/m4/$file" "$macro_dir/$file"; then
 3245 
 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
 3249                   *" $file "*) ;;
 3250                   *) rm -f "$macro_dir/$file"
 3251                      func_verbose \
 3252                        "removing unused gnulib file '$macro_dir/$file'"
 3253                 esac
 3254               fi
 3255         }
 3256       done
 3257     }
 3258 }
 3259 
 3260 
 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 ()
 3266 {
 3267     $debug_cmd
 3268 
 3269     test ! -d po \
 3270         || $opt_skip_po \
 3271         || func_warning recommend "\
 3272 If your pofiles are up-to-date, you can rerun bootstrap
 3273 as '$progname --skip-po' to avoid redownloading."
 3274 }
 3275 
 3276 
 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 ()
 3282 {
 3283     $debug_cmd
 3284 
 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~)"
 3290       }
 3291       func_verbose "updating .version"
 3292 
 3293       $build_aux/git-version-gen dummy-arg > .version
 3294     }
 3295 }
 3296 
 3297 
 3298 
 3299 ## -------------------- ##
 3300 ## Resource management. ##
 3301 ## -------------------- ##
 3302 
 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
 3310 # most, once.
 3311 
 3312 
 3313 # require_checkout_only_file
 3314 # --------------------------
 3315 # Bail out  if this package only bootstraps properly from a repository
 3316 # checkout.
 3317 require_checkout_only_file=func_require_checkout_only_file
 3318 func_require_checkout_only_file ()
 3319 {
 3320     $debug_cmd
 3321 
 3322     $opt_force || {
 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."
 3327     }
 3328 
 3329     require_checkout_only_file=:
 3330 }
 3331 
 3332 
 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 ()
 3339 {
 3340     $debug_cmd
 3341 
 3342     $require_makefile_am
 3343 
 3344     _G_sed_extract_aclocal_amflags='s|#.*$||
 3345         /^[  ]*ACLOCAL_AMFLAGS[  ]*=/ {
 3346             s|^.*=[  ]*\(.*\)|aclocal_amflags="\1"|
 3347             p
 3348         }'
 3349 
 3350     _G_aclocal_flags_cmd=`$SED -n "$_G_sed_extract_aclocal_amflags" \
 3351         "$makefile_am"`
 3352     eval "$_G_aclocal_flags_cmd"
 3353 
 3354     func_verbose "ACLOCAL_AMFLAGS='$aclocal_amflags'"
 3355 
 3356     require_aclocal_amflags=:
 3357 }
 3358 
 3359 
 3360 # require_autoheader
 3361 # ------------------
 3362 # Skip autoheader if it's not needed.
 3363 require_autoheader=func_require_autoheader
 3364 func_require_autoheader ()
 3365 {
 3366     $debug_cmd
 3367 
 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
 3372 
 3373       test -n "$func_extract_trace_result" || {
 3374         AUTOHEADER=true
 3375 
 3376         func_verbose "export AUTOHEADER='$AUTOHEADER'"
 3377 
 3378         # Make sure the search result is visible to subshells
 3379         export AUTOHEADER
 3380       }
 3381     }
 3382 
 3383     require_autoheader=:
 3384 }
 3385 
 3386 
 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 ()
 3392 {
 3393     $debug_cmd
 3394 
 3395     func_extract_trace AM_INIT_AUTOMAKE
 3396     automake_options=$func_extract_trace_result
 3397 
 3398     require_automake_options=:
 3399 }
 3400 
 3401 
 3402 # require_autopoint
 3403 # -----------------
 3404 # Skip autopoint if it's not needed.
 3405 require_autopoint=func_require_autopoint
 3406 func_require_autopoint ()
 3407 {
 3408     $debug_cmd
 3409 
 3410     test true = "$AUTOPOINT" || {
 3411       func_extract_trace AM_GNU_GETTEXT_VERSION
 3412 
 3413       test -n "$func_extract_trace_result" || {
 3414         AUTOPOINT=true
 3415 
 3416         func_verbose "export AUTOPOINT='$AUTOPOINT'"
 3417 
 3418         # Make sure the search result is visible to subshells
 3419         export AUTOPOINT
 3420       }
 3421     }
 3422 
 3423     require_autopoint=:
 3424 }
 3425 
 3426 
 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 ()
 3433 {
 3434     $debug_cmd
 3435 
 3436     $require_build_aux
 3437 
 3438     _G_bootstrap_sources="
 3439       $build_aux/bootstrap.in
 3440       $build_aux/extract-trace
 3441       $build_aux/funclib.sh
 3442       $build_aux/options-parser
 3443     "
 3444 
 3445     _G_missing_bootstrap_sources=false
 3446     for _G_src in $_G_bootstrap_sources; do
 3447       test -f "$_G_src" || _G_missing_bootstrap_sources=:
 3448     done
 3449 
 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
 3454 updates available."
 3455     else
 3456       rm -f bootstrap.new
 3457       $build_aux/inline-source $build_aux/bootstrap.in > bootstrap.new
 3458 
 3459       if func_cmp_s "$progpath" bootstrap.new; then
 3460         rm -f bootstrap.new
 3461     func_verbose "bootstrap script up to date"
 3462       else
 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
 3469     ./$progname
 3470 
 3471 Or you can disable this check permanently by adding the
 3472 following to 'bootstrap.conf':
 3473     require_bootstrap_uptodate=:"
 3474       fi
 3475     fi
 3476 
 3477     require_bootstrap_uptodate=:
 3478 }
 3479 
 3480 
 3481 # require_build_aux
 3482 # -----------------
 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 ()
 3487 {
 3488     $debug_cmd
 3489 
 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])"
 3495 
 3496       func_verbose "build_aux='$build_aux'"
 3497     }
 3498 
 3499     $require_vc_ignore_files
 3500 
 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'"
 3505 
 3506       test -n "$vc_ignore_files" \
 3507           || func_insert_if_absent "$build_aux" $vc_ignore_files
 3508     fi
 3509 
 3510     require_build_aux=:
 3511 }
 3512 
 3513 
 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 ()
 3519 {
 3520     $debug_cmd
 3521 
 3522     $require_macro_dir
 3523 
 3524     test -f "$macro_dir/autobuild.m4" \
 3525         || printf '%s\n' "$buildreq" |func_grep_q '^[    ]*autobuild' \
 3526         || {
 3527       func_extract_trace AB_INIT
 3528       test -n "$func_extract_trace_result" && {
 3529         func_append buildreq 'autobuild - http://josefsson.org/autobuild/
 3530 '
 3531         func_verbose "auto-adding 'autobuild' to build requirements"
 3532       }
 3533     }
 3534 
 3535     require_buildreq_autobuild=:
 3536 }
 3537 
 3538 
 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
 3546   b=$tool
 3547   v=require_buildreq_${tool}
 3548   f=func_$v
 3549   case $tool in
 3550     autoconf) m=AC_PREREQ ;;
 3551     libtoolize) m=LT_PREREQ; b=libtool ;;
 3552     autopoint) m=AM_GNU_GETTEXT_VERSION b=gettext ;;
 3553   esac
 3554 
 3555   eval $v'='$f'
 3556   '$f' ()
 3557   {
 3558     $debug_cmd
 3559 
 3560     # The following is ignored if undefined, but might be necessary
 3561     # in order for `func_find_tool` to run.
 3562     ${require_'$tool'-:}
 3563 
 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'
 3570 "
 3571         func_verbose \
 3572             "auto-adding '\'$tool'-$_G_version'\'' to build requirements"
 3573       }
 3574     }
 3575 
 3576     '$v'=:
 3577   }
 3578 '
 3579 done
 3580 
 3581 
 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 ()
 3588 {
 3589     $debug_cmd
 3590 
 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
 3594 
 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=-
 3600 
 3601         func_append buildreq "\
 3602             automake $automake_version http://www.gnu.org/s/automake
 3603 "
 3604         func_verbose \
 3605             "auto-adding 'automake-$automake_version' to build requirements"
 3606       }
 3607     }
 3608 
 3609     require_buildreq_automake=:
 3610 }
 3611 
 3612 
 3613 # require_buildreq_patch
 3614 # ----------------------
 3615 # Automatically add a patch build-requirement if there are diff files
 3616 # in $local_gl_dir.
 3617 require_buildreq_patch=func_require_buildreq_patch
 3618 func_require_buildreq_patch ()
 3619 {
 3620     $debug_cmd
 3621 
 3622     $require_local_gl_dir
 3623 
 3624     # This ensures PATCH is set appropriately by the time
 3625     # func_check_versions enforces $buildreq.
 3626     $require_patch
 3627 
 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 :
 3634       else
 3635           func_append buildreq 'patch - http://www.gnu.org/s/patch
 3636 '
 3637       fi
 3638     }
 3639 
 3640     require_buildreq_patch=:
 3641 }
 3642 
 3643 
 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 ()
 3650 {
 3651     $debug_cmd
 3652 
 3653     $require_buildreq_autobuild
 3654     $require_buildreq_autoconf
 3655     $require_buildreq_automake
 3656     $require_buildreq_libtoolize
 3657     $require_buildreq_autopoint
 3658     $require_buildreq_patch
 3659 
 3660     test -n "$buildreq" && {
 3661       _G_error_hdr=
 3662 
 3663       func_check_versions $buildreq
 3664       $func_check_versions_result || {
 3665         test -n "$buildreq_readme" \
 3666             && test -f "$buildreq_readme" \
 3667             && _G_error_hdr="\
 3668 $buildreq_readme explains how to obtain these prerequisite programs:
 3669 "
 3670         func_strtable 0 11 12 36 \
 3671             "Program" "Min_version" "Homepage" $buildreq
 3672         func_fatal_error "$_G_error_hdr$func_strtable_result"
 3673       }
 3674     }
 3675 
 3676     require_buildtools_uptodate=:
 3677 }
 3678 
 3679 
 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 ()
 3685 {
 3686     $debug_cmd
 3687 
 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'."
 3693     }
 3694 
 3695     require_copyright_holder=:
 3696 }
 3697 
 3698 
 3699 # require_doc_base
 3700 # ----------------
 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 ()
 3705 {
 3706     $debug_cmd
 3707 
 3708     $require_gnulib_cache
 3709 
 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
 3713 
 3714       test -n "$doc_base" && func_verbose "doc_base='$doc_base'"
 3715     }
 3716 
 3717     require_doc_base=:
 3718 }
 3719 
 3720 
 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 ()
 3726 {
 3727     $debug_cmd
 3728 
 3729     $require_git
 3730 
 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`
 3734 
 3735       test -n "$_G_path" || {
 3736         $require_vc_ignore_files
 3737 
 3738         func_verbose "creating '.gitmodules'"
 3739 
 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
 3744 
 3745         {
 3746           echo '[submodule "gnulib"]'
 3747           echo "    path = $gnulib_path"
 3748           echo "    url = $gnulib_url"
 3749         } >> .gitmodules
 3750 
 3751         test -n "$vc_ignore_files" \
 3752           || func_insert_if_absent ".gitmodules" $vc_ignore_files
 3753       }
 3754     }
 3755 
 3756     require_dotgitmodules=:
 3757 }
 3758 
 3759 
 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 ()
 3765 {
 3766     $debug_cmd
 3767 
 3768     # Defaults to empty, so run with whatever value may have been set in
 3769     # 'bootstrap.conf'.
 3770     require_extra_locale_categories=:
 3771 }
 3772 
 3773 
 3774 # require_git
 3775 # -----------
 3776 # Ignore git if it's not available, or we're not in a git checkout tree.
 3777 require_git=func_require_git
 3778 func_require_git ()
 3779 {
 3780     $debug_cmd
 3781 
 3782     $opt_skip_git && GIT=true
 3783 
 3784     test true = "$GIT" || {
 3785       if test -d .git/.; then
 3786         ($GIT --version) >/dev/null 2>&1 || GIT=true
 3787       fi
 3788     }
 3789 
 3790     func_verbose "GIT='$GIT'"
 3791 
 3792     require_git=:
 3793 }
 3794 
 3795 
 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 ()
 3802 {
 3803     $debug_cmd
 3804 
 3805     $require_macro_dir
 3806 
 3807     test -n "$gnulib_cache" \
 3808       || gnulib_cache=$macro_dir/gnulib-cache.m4
 3809 
 3810     func_verbose "found '$gnulib_cache'"
 3811 
 3812     require_gnulib_cache=:
 3813 }
 3814 
 3815 
 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 ()
 3821 {
 3822     $debug_cmd
 3823 
 3824     $require_gnulib_tool
 3825     $require_gnulib_tool_base_options
 3826 
 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"
 3830 
 3831     require_gnulib_copy_cmd=:
 3832 }
 3833 
 3834 
 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 ()
 3840 {
 3841     $debug_cmd
 3842 
 3843     test -f ChangeLog && {
 3844       $require_git
 3845 
 3846       func_grep_q '^\(/\|\)ChangeLog$' .gitignore || test true = "$GIT" || {
 3847         if $GIT config merge.merge-changelog.driver >/dev/null; then
 3848           :
 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'
 3853         else
 3854           func_warning recommend \
 3855               "Consider installing git-merge-changelog from gnulib."
 3856         fi
 3857       }
 3858     }
 3859 
 3860     require_gnulib_merge_changelog=:
 3861 }
 3862 
 3863 
 3864 # require_gnulib_mk
 3865 # -----------------
 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 ()
 3870 {
 3871     $debug_cmd
 3872 
 3873     $require_gnulib_cache
 3874 
 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
 3878 
 3879       test -n "$gnulib_mk" && func_verbose "gnulib_mk='$gnulib_mk'"
 3880     }
 3881 
 3882     require_gnulib_mk=:
 3883 }
 3884 
 3885 
 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 ()
 3892 {
 3893     $debug_cmd
 3894 
 3895     $require_gnulib_cache
 3896 
 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
 3900 
 3901       test -n "$gnulib_name" && func_verbose "gnulib_name='$gnulib_name'"
 3902     }
 3903 
 3904     require_gnulib_name=:
 3905 }
 3906 
 3907 
 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 ()
 3915 {
 3916     $debug_cmd
 3917 
 3918     $require_git
 3919 
 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
 3927     }
 3928 
 3929 
 3930     $require_dotgitmodules
 3931 
 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".$/,${
 3936                                    /[    ]*path *= */{
 3937                          s|[   ]*||g;s|^[^=]*=||;p
 3938                        }
 3939                          }
 3940                  d' .gitmodules |$SED 1q`
 3941       test -n "$gnulib_url" \
 3942         || gnulib_url=`$SED -e '/^.submodule "gnulib".$/,${
 3943                                   /[     ]*url *= */{
 3944                         s|[   ]*||g;s|^[^=]*=||;p
 3945                       }
 3946                         }
 3947                 d' .gitmodules |$SED 1q`
 3948 
 3949       func_verbose "gnulib_path='$gnulib_path'"
 3950       func_verbose "gnulib_url='$gnulib_url'"
 3951     }
 3952 
 3953     require_gnulib_path=:
 3954     require_gnulib_url=:
 3955 }
 3956 
 3957 
 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 ()
 3963 {
 3964     $debug_cmd
 3965 
 3966     $require_git
 3967 
 3968     if test true = "$GIT"; then
 3969       func_warning recommend \
 3970           "No 'git' found; imported gnulib modules may be outdated."
 3971     else
 3972       $require_gnulib_path
 3973       $require_gnulib_url
 3974 
 3975       if test -f .gitmodules && test -f "$gnulib_path/gnulib-tool"; then
 3976         : All present and correct.
 3977 
 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."
 3984 
 3985       # Without --gnulib-srcdir, and no existing checked out submodule, we
 3986       # create a new shallow clone of the remote gnulib repository.
 3987       else
 3988         trap func_cleanup_gnulib 1 2 13 15
 3989 
 3990         shallow=
 3991         $GIT clone -h 2>&1 |func_grep_q -- --depth \
 3992             && shallow='--depth 365'
 3993 
 3994         func_show_eval "$GIT clone $shallow '$gnulib_url' '$gnulib_path'" \
 3995           func_cleanup_gnulib
 3996 
 3997     # FIXME: Solaris /bin/sh will try to execute '-' if any of
 3998     #        these signals are caught after this.
 3999         trap - 1 2 13 15
 4000       fi
 4001 
 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."
 4006     fi
 4007 
 4008     require_gnulib_submodule=:
 4009 }
 4010 
 4011 
 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 ()
 4019 {
 4020     $debug_cmd
 4021 
 4022     test true = "$gnulib_tool" || {
 4023       $require_gnulib_submodule
 4024       $require_gnulib_path
 4025 
 4026       test -n "$gnulib_tool" \
 4027         || gnulib_tool=$gnulib_path/gnulib-tool
 4028 
 4029       test -x "$gnulib_tool" || {
 4030         gnulib_tool=true
 4031         func_warning recommend \
 4032             "No 'gnulib-tool' found; gnulib modules may be missing."
 4033       }
 4034 
 4035       test true = "$gnulib_tool" \
 4036           || func_verbose "found '$gnulib_tool'"
 4037     }
 4038 
 4039     require_gnulib_tool=:
 4040 }
 4041 
 4042 
 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 ()
 4049 {
 4050     $debug_cmd
 4051 
 4052     $require_gnulib_tool
 4053 
 4054     gnulib_tool_base_options=
 4055 
 4056     test true = "$gnulib_tool" || {
 4057       # 'gnulib_modules' and others are maintained in 'bootstrap.conf':
 4058       # Use 'gnulib --import' to fetch gnulib modules.
 4059       $require_build_aux
 4060       test -n "$build_aux" \
 4061           && func_append_uniq gnulib_tool_base_options " --aux-dir=$build_aux"
 4062       $require_macro_dir
 4063       test -n "$macro_dir" \
 4064           && func_append_uniq gnulib_tool_base_options " --m4-base=$macro_dir"
 4065       $require_doc_base
 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"
 4077     }
 4078 
 4079     require_gnulib_tool_base_options=:
 4080 }
 4081 
 4082 
 4083 # require_libtoolize
 4084 # ------------------
 4085 # Skip libtoolize if it's not needed.
 4086 require_libtoolize=func_require_libtoolize
 4087 func_require_libtoolize ()
 4088 {
 4089     $debug_cmd
 4090 
 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
 4099     }
 4100 
 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
 4106     }
 4107 
 4108     test -n "$LIBTOOLIZE" || func_fatal_error "\
 4109 Please install GNU Libtool, or 'export LIBTOOLIZE=/path/to/libtoolize'."
 4110 
 4111     func_verbose "export LIBTOOLIZE='$LIBTOOLIZE'"
 4112 
 4113     # Make sure the search result is visible to subshells
 4114     export LIBTOOLIZE
 4115 
 4116     require_libtoolize=:
 4117 }
 4118 
 4119 
 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 ()
 4126 {
 4127     $debug_cmd
 4128 
 4129     $require_gnulib_cache
 4130 
 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
 4134 
 4135       test -n "$local_gl_dir" && func_verbose "local_gl_dir='$local_gl_dir'"
 4136     }
 4137 
 4138     require_local_gl_dir=:
 4139 }
 4140 
 4141 
 4142 # require_macro_dir
 4143 # -----------------
 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 ()
 4148 {
 4149     $debug_cmd
 4150 
 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\([^   ]*\)'`
 4157     }
 4158     test -n "$macro_dir" || {
 4159       func_extract_trace_first AC_CONFIG_MACRO_DIR
 4160       macro_dir=$func_extract_trace_first_result
 4161     }
 4162 
 4163     # Otherwise we might find it in 'Makefile.am'.
 4164     test -n "$macro_dir" || {
 4165       $require_aclocal_amflags
 4166 
 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 ;;
 4174         esac
 4175       done
 4176     }
 4177 
 4178     func_verbose "macro_dir='$macro_dir'"
 4179 
 4180     func_check_configuration macro_dir \
 4181         "AC_CONFIG_MACRO_DIRS([name of a directory for configure m4 files])"
 4182 
 4183     $require_vc_ignore_files
 4184 
 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"
 4189 
 4190       test -n "$vc_ignore_files" \
 4191         || func_insert_if_absent "$macro_dir" $vc_ignore_files
 4192     fi
 4193 
 4194     require_macro_dir=:
 4195 }
 4196 
 4197 
 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 ()
 4203 {
 4204     $debug_cmd
 4205 
 4206     test -n "$makefile_am" \
 4207       || makefile_am=Makefile.am
 4208 
 4209     <"$makefile_am"
 4210 
 4211     func_verbose "found '$makefile_am'"
 4212 
 4213     require_makefile_am=:
 4214 }
 4215 
 4216 
 4217 # require_package
 4218 # ---------------
 4219 # Ensure that '$package' contains a sensible default value.
 4220 require_package=func_require_package
 4221 func_require_package ()
 4222 {
 4223     $debug_cmd
 4224 
 4225     test -n "$package" || {
 4226       $require_package_name
 4227 
 4228       package=`echo "$package_name" \
 4229         |$SED -e 's/GNU //' \
 4230           -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
 4231     }
 4232 
 4233     func_verbose "package='$package'"
 4234 
 4235     require_package=:
 4236 }
 4237 
 4238 
 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 ()
 4245 {
 4246     $debug_cmd
 4247 
 4248     func_extract_trace AC_INIT
 4249 
 4250     save_ifs=$IFS
 4251     IFS=:
 4252     set dummy $func_extract_trace_result
 4253     IFS=$save_ifs
 4254     shift
 4255 
 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'"
 4260 
 4261     require_package_bugreport=:
 4262 }
 4263 
 4264 
 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 ()
 4271 {
 4272     $debug_cmd
 4273 
 4274     func_extract_trace AC_INIT
 4275 
 4276     save_ifs=$IFS
 4277     IFS=:
 4278     set dummy $func_extract_trace_result
 4279     IFS=$save_ifs
 4280     shift
 4281 
 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'"
 4286 
 4287     require_package_name=:
 4288 }
 4289 
 4290 
 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 ()
 4301 {
 4302     $debug_cmd
 4303 
 4304     func_extract_trace AC_INIT
 4305 
 4306     save_ifs=$IFS
 4307     IFS=:
 4308     set dummy $func_extract_trace_result
 4309     IFS=$save_ifs
 4310     shift
 4311 
 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 "*)
 4317       func_fatal_error "\
 4318 cannot \$require_package_version in bootstrap.conf before
 4319 func_gnulib_tool has installed the 'git-version-gen' script."
 4320       ;;
 4321     *)
 4322           func_check_configuration package_version \
 4323             "AC_INIT([name of your package], [package version number])"
 4324       ;;
 4325       esac
 4326     }
 4327     func_verbose "package_version='$package_version'"
 4328 
 4329     require_package_version=:
 4330 }
 4331 
 4332 
 4333 # require_patch
 4334 # -------------
 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 ()
 4339 {
 4340     $debug_cmd
 4341 
 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
 4346     }
 4347 
 4348     test -n "$PATCH" || func_fatal_error "\
 4349 Please install GNU Patch, or 'export PATCH=/path/to/gnu/patch'."
 4350 
 4351     func_verbose "export PATCH='$PATCH'"
 4352 
 4353     # Make sure the search result is visible to subshells
 4354     export PATCH
 4355 
 4356     require_patch=:
 4357 }
 4358 
 4359 
 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 ()
 4366 {
 4367     $debug_cmd
 4368 
 4369     $require_gnulib_cache
 4370 
 4371     test -f "$gnulib_cache" && test -z "$source_base" && {
 4372       func_extract_trace_first "gl_SOURCE_BASE" "$gnulib_cache"
 4373 
 4374       source_base=$func_extract_trace_first_result
 4375 
 4376       func_verbose "source_base='$source_base'"
 4377     }
 4378 
 4379     require_source_base=:
 4380 }
 4381 
 4382 
 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 ()
 4389 {
 4390     $debug_cmd
 4391 
 4392     test -n "$vc_ignore" || vc_ignore=auto
 4393 
 4394     if test auto = "$vc_ignore" && test -z "$vc_ignore_files"; then
 4395       vc_ignore_files=
 4396       test -d .git && vc_ignore_files=.gitignore
 4397       test -d CVS && vc_ignore_files="$vc_ignore_files .cvsignore"
 4398     else
 4399       vc_ignore_files=$vc_ignore
 4400     fi
 4401 
 4402     func_verbose "vc_ignore_files='$vc_ignore_files'"
 4403 
 4404     require_vc_ignore_files=:
 4405 }
 4406 
 4407 
 4408 ## ----------------- ##
 4409 ## Helper functions. ##
 4410 ## ----------------- ##
 4411 
 4412 # This section contains the helper functions used by the rest of 'bootstrap'.
 4413 
 4414 # func_len STRING
 4415 # ---------------
 4416 # STRING may not start with a hyphen.
 4417 if (eval 'x=123; test x${#x} = "x3"') 2>/dev/null
 4418 then
 4419   # This is an XSI compatible shell, allowing a faster implementation...
 4420   eval 'func_len ()
 4421   {
 4422     $debug_cmd
 4423 
 4424     func_len_result=${#1}
 4425   }'
 4426 else
 4427   # ...otherwise fall back to using expr, which is often a shell builtin.
 4428   func_len ()
 4429   {
 4430     $debug_cmd
 4431 
 4432     func_len_result=`expr "$1" : ".*" 2>/dev/null || echo 0`
 4433   }
 4434 fi
 4435 
 4436 
 4437 # func_unset VAR
 4438 # --------------
 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).
 4445 func_unset ()
 4446 {
 4447     { eval $1=; unset $1; }
 4448 }
 4449 unset=func_unset
 4450 
 4451 
 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.
 4456 func_cmp_s ()
 4457 {
 4458     $debug_cmd
 4459 
 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
 4463 }
 4464 
 4465 
 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.
 4470 func_grep_q ()
 4471 {
 4472     $debug_cmd
 4473 
 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
 4477 }
 4478 
 4479 
 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.
 4484 func_ifcontains ()
 4485 {
 4486     $debug_cmd
 4487 
 4488     _G_wslist=$1
 4489     _G_member=$2
 4490     _G_yes_cmd=$3
 4491     _G_no_cmd=${4-":"}
 4492 
 4493     _G_found=false
 4494     for _G_item in $_G_wslist; do
 4495       test "x$_G_item" = "x$_G_member" && {
 4496         _G_found=:
 4497     break
 4498       }
 4499     done
 4500     if $_G_found; then
 4501       eval "$_G_yes_cmd"
 4502       _G_status=$?
 4503     else
 4504       eval "$_G_no_cmd"
 4505       _G_status=$?
 4506     fi
 4507 
 4508     test 0 -eq "$_G_status" || exit $_G_status
 4509 }
 4510 
 4511 
 4512 # func_strpad STR WIDTH CHAR
 4513 # --------------------------
 4514 # Trim STR, or pad with CHAR to force a total length of WIDTH.
 4515 func_strpad ()
 4516 {
 4517     $debug_cmd
 4518 
 4519     _G_width=`expr "$2" - 1`
 4520     func_strpad_result=`$ECHO "$1" |$SED '
 4521         :a
 4522         s|^.\{0,'"$_G_width"'\}$|&'"$3"'|
 4523         ta
 4524     '`
 4525 }
 4526 
 4527 
 4528 # func_strrpad STR WIDTH CHAR
 4529 # ---------------------------
 4530 # Trim STR, or right-justify-pad with CHAR to force a total length of
 4531 # WIDTH.
 4532 func_strrpad ()
 4533 {
 4534     $debug_cmd
 4535 
 4536     _G_width=`expr "$2" - 1`
 4537     func_strrpad_result=`$ECHO "$1" |$SED '
 4538         :a
 4539         s|^.\{0,'"$_G_width"'\}$|'"$3"'&|
 4540         ta
 4541     '`
 4542 }
 4543 
 4544 
 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().
 4550 func_strrow ()
 4551 {
 4552     $debug_cmd
 4553 
 4554     func_strrow_linelen=$1; shift
 4555 
 4556     _G_row=
 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"
 4561       shift; shift
 4562     done
 4563 
 4564     func_strrpad "$_G_row" $func_strrow_linelen " "
 4565     func_strrow_result=$func_strrpad_result
 4566 }
 4567 
 4568 
 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.
 4581 #
 4582 # For example an unindented 3 column table with 2 rows of data would be
 4583 # generated by this call:
 4584 #
 4585 #    func_strtable 3 20 10 25 \
 4586 #        Header1 Header2 Header3 \
 4587 #        Row1Col1 Row1Col2 Row1Col3 \
 4588 #        Row2Col1 Row2Col2 Row2Col3
 4589 #
 4590 # returning the following string:
 4591 #
 4592 # "   Header1             Header2   Header3
 4593 #     -------------------------------------------------------
 4594 #     Row1Col1            Row1Col2  Row1Col3
 4595 #     Row2Col1            Row2Col2  Row2Col3
 4596 #     -------------------------------------------------------"
 4597 func_strtable ()
 4598 {
 4599     $debug_cmd
 4600 
 4601     # Save the indent value, we'll need it for each row we render.
 4602     _G_indent=$1; shift
 4603 
 4604     # Collect remaining numeric args into a list for reuse between
 4605     # members of each row when we call func_strrow later.
 4606     _G_widths=$1; shift
 4607     while test 0 -lt `expr "$1" : '[1-9][0-9]*$'`; do
 4608       func_append _G_widths " $1"; shift
 4609     done
 4610 
 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
 4617     done
 4618     func_strrow $_G_header
 4619 
 4620     # Strip off the indent, and make a divider with '-' chars, then
 4621     # reindent.
 4622     _G_divider=`$ECHO "$func_strrow_result" \
 4623         |$SED 's|[^ ]|-|g
 4624             :a
 4625             s|- |--|g
 4626             ta
 4627         '`
 4628 
 4629     # Append the header and divider to the running result.
 4630     func_append func_strtable_result "\
 4631 $func_strrow_result
 4632 $_G_divider
 4633 "
 4634 
 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
 4638       _G_row=$_G_indent
 4639       for _G_width in $_G_widths; do
 4640         func_append _G_row " $1 $_G_width"; shift
 4641       done
 4642       func_strrow $_G_row
 4643       func_append func_strtable_result "\
 4644 $func_strrow_result
 4645 "
 4646     done
 4647 
 4648     # Mark the end of the table with a final divider line.
 4649     func_append func_strtable_result "$_G_divider"
 4650 }
 4651 
 4652 
 4653 # func_internal_error ARG...
 4654 # --------------------------
 4655 # Echo program name prefixed message to standard error, and exit.
 4656 func_internal_error ()
 4657 {
 4658     func_fatal_error "\
 4659 INTERNAL: " ${1+"$@"} "
 4660           Please report this bug to 'bug-gnulib@gnu.org'
 4661           in as much detail as possible."
 4662 }
 4663 
 4664 
 4665 # func_permissions_error FILE-OR-DIRECTORY
 4666 # ----------------------------------------
 4667 # Echo program name prefixed permissions error message to standard
 4668 # error, and exit.
 4669 func_permissions_error ()
 4670 {
 4671     $debug_cmd
 4672 
 4673     func_fatal_error "Failed to create '$1', check permissions."
 4674 }
 4675 
 4676 
 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.
 4682 func_show_eval ()
 4683 {
 4684     $debug_cmd
 4685 
 4686     $require_term_colors
 4687 
 4688     _G_cmd=$1
 4689     _G_fail_exp=${2-':'}
 4690 
 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"
 4695     }
 4696 
 4697     ${opt_dry_run-'false'} || {
 4698       eval "$_G_cmd"
 4699       _G_status=$?
 4700       test 0 -eq "$_G_status" || eval "(exit $_G_status); $_G_fail_exp"
 4701     }
 4702 }
 4703 
 4704 
 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-
 4709 # option ARG.
 4710 func_truncate_cmd ()
 4711 {
 4712     $debug_cmd
 4713 
 4714     _G_last_arg_opt_p=false
 4715     func_truncate_cmd_result=
 4716 
 4717     set dummy "$@"; shift
 4718 
 4719     while test $# -gt 0; do
 4720       _G_opt=$1; shift
 4721 
 4722       test -n "$func_truncate_cmd_result" \
 4723           && func_append func_truncate_cmd_result ' '
 4724       func_append func_truncate_cmd_result "$_G_opt"
 4725 
 4726       func_len "x$func_truncate_cmd_result"
 4727 
 4728       case $_G_opt in
 4729         -*) _G_last_arg_opt_p=: ;;
 4730         *)  $_G_last_arg_opt_p \
 4731                 || test "$min_cmd_len" -gt "$func_len_result" \
 4732                 || break
 4733             _G_last_arg_opt_p=false
 4734             ;;
 4735       esac
 4736     done
 4737 
 4738     test $# -gt 0 && func_append func_truncate_cmd_result "..."
 4739 }
 4740 
 4741 
 4742 # func_gitignore_entries FILE...
 4743 # ------------------------------
 4744 # Strip blank and comment lines to leave significant entries.
 4745 func_gitignore_entries ()
 4746 {
 4747     $debug_cmd
 4748 
 4749     $SED -e '/^#/d' -e '/^$/d' "$@"
 4750 }
 4751 
 4752 
 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 ()
 4761 {
 4762     $debug_cmd
 4763 
 4764     str=$1
 4765     shift
 4766 
 4767     for file
 4768     do
 4769       test -f "$file" || touch "$file"
 4770 
 4771       duplicate_entries=`func_gitignore_entries "$file" |sort |uniq -d`
 4772       test -n "$duplicate_entries" \
 4773           && func_error "duplicate entries in $file: " $duplicate_entries
 4774 
 4775       func_grep_q "^$str\$" "$file" \
 4776           || func_verbose "inserting '$str' into '$file'"
 4777 
 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"
 4784     done
 4785 }
 4786 
 4787 
 4788 # func_get_version APP
 4789 # --------------------
 4790 # echo the version number (if any) of APP, which is looked up along your
 4791 # PATH.
 4792 func_get_version ()
 4793 {
 4794     $debug_cmd
 4795 
 4796     _G_app=$1
 4797 
 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|
 4802           t done
 4803 
 4804           # extract version at start of line
 4805           s|^\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1|
 4806           t done
 4807 
 4808           d
 4809 
 4810           :done
 4811           # the following essentially does s|5.005|5.5|
 4812           s|\.0*\([1-9]\)|.\1|g
 4813           p
 4814           q' \
 4815     |$SED '/^[   ]*#.*$/d'`
 4816 
 4817     func_tool_version_output $_G_app >/dev/null
 4818     _G_status=$?
 4819 
 4820     test 0 -ne "$_G_status" \
 4821       || $_G_app --version 2>&1 |$SED -n "$sed_get_version"
 4822 
 4823     (exit $_G_status)
 4824 }
 4825 
 4826 
 4827 # func_check_tool APP
 4828 # -------------------
 4829 # Search PATH for an executable at APP.
 4830 func_check_tool ()
 4831 {
 4832     $debug_cmd
 4833 
 4834     func_check_tool_result=
 4835 
 4836     case $1 in
 4837     *[\\/]*)
 4838       test -x "$1" && func_check_tool_result=$1
 4839       ;;
 4840     *)
 4841       save_IFS=$IFS
 4842       IFS=${PATH_SEPARATOR-:}
 4843       for _G_check_tool_path in $PATH; do
 4844         IFS=$save_IFS
 4845     if test -x "$_G_check_tool_path/$1"; then
 4846       func_check_tool_result=$_G_check_tool_path/$1
 4847       break
 4848     fi
 4849       done
 4850       IFS=$save_IFS
 4851       ;;
 4852     esac
 4853 }
 4854 
 4855 
 4856 # func_check_versions APP1 VER1 URL1 ...[APPN VERN URLN]
 4857 # ------------------------------------------------------
 4858 func_check_versions ()
 4859 {
 4860     $debug_cmd
 4861 
 4862     func_check_versions_result=:
 4863 
 4864     while test $# -gt 0; do
 4865       _G_app=$1; shift
 4866       _G_reqver=$1; shift
 4867       _G_url=$1; shift
 4868 
 4869       # Diagnose bad buildreq formatting.
 4870       case $_G_url in
 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'."
 4877         ;;
 4878       esac
 4879 
 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}"
 4884 
 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
 4892     else
 4893       func_verbose "found '$func_check_tool_result' for $_G_appvar."
 4894     fi
 4895       else
 4896         _G_instver=`func_get_version $_G_app`
 4897 
 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
 4903 
 4904         # Fail if a newer version than what we have is required.
 4905         else
 4906           func_verbose "found '$_G_app' version $_G_instver."
 4907 
 4908       case $_G_reqver in
 4909             =*)
 4910               # If $buildreq version starts with '=', version must
 4911           # match the installed program exactly.
 4912           test "x$_G_reqver" = "x=$_G_instver" || {
 4913             func_error "\
 4914   '$_G_app' version == $_G_instver is too old
 4915   'exactly $_G_app-$_G_reqver is required"
 4916                 func_check_versions_result=false
 4917               }
 4918           ;;
 4919         *)
 4920               # Otherwise, anything that is not older is a match.
 4921               func_lt_ver "$_G_reqver" "$_G_instver" || {
 4922                 func_error "\
 4923   '$_G_app' version == $_G_instver is too old
 4924   '$_G_app' version >= $_G_reqver is required"
 4925             func_check_versions_result=false
 4926               }
 4927           ;;
 4928       esac
 4929         fi
 4930       fi
 4931     done
 4932 }
 4933 
 4934 
 4935 # func_cleanup_gnulib
 4936 # -------------------
 4937 # Recursively delete everything below the path in the global variable
 4938 # GNULIB_PATH.
 4939 func_cleanup_gnulib ()
 4940 {
 4941     $debug_cmd
 4942 
 4943     _G_status=$?
 4944     $RM -fr "$gnulib_path"
 4945     exit $_G_status
 4946 }
 4947 
 4948 
 4949 # func_download_po_files SUBDIR DOMAIN
 4950 # ------------------------------------
 4951 func_download_po_files ()
 4952 {
 4953     $debug_cmd
 4954 
 4955     func_echo "getting translations into $1 for $2..."
 4956     _G_cmd=`printf "$po_download_command_format" "$2" "$1"`
 4957     eval "$_G_cmd"
 4958 }
 4959 
 4960 
 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 ()
 4968 {
 4969     $debug_cmd
 4970 
 4971     # Directory containing primary .po files.
 4972     # Overwrite them only when we're sure a .po file is new.
 4973     _G_po_dir=$1
 4974     _G_domain=$2
 4975 
 4976     # Mirror *.po files into this dir.
 4977     # Usually contains *.s1 checksum files.
 4978     _G_ref_po_dir=$_G_po_dir/.reference
 4979 
 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
 4984 
 4985     # Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6+.
 4986     func_find_tool SHA1SUM sha1sum gsha1sum shasum sha1
 4987 
 4988     test -n "$SHA1SUM" || func_fatal_error "\
 4989 Please install GNU Coreutils, or 'export SHA1SUM=/path/to/sha1sum'."
 4990 
 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
 5004       fi
 5005     done
 5006 }
 5007 
 5008 
 5009 
 5010 ## --------------- ##
 5011 ## Option parsing. ##
 5012 ## --------------- ##
 5013 
 5014 # Hook in the functions to make sure our own options are parsed during
 5015 # the option parsing loop.
 5016 
 5017 usage='$progpath [OPTION]...'
 5018 
 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
 5032                       \$GNULIB_SRCDIR.
 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
 5041 "
 5042 
 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
 5048 
 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
 5051 bootstrap.
 5052 
 5053 For build prerequisites, environment variables like \$AUTOCONF and
 5054 \$AMTAR are honored.
 5055 
 5056 Running without arguments will suffice in most cases.
 5057 "
 5058 
 5059 # Warning categories used by 'bootstrap', append others if you use them
 5060 # in your 'bootstrap.conf'.
 5061 warning_categories='recommend settings upgrade'
 5062 
 5063 
 5064 # bootstrap_options_prep [ARG]...
 5065 # -------------------------------
 5066 # Preparation for options parsed by Bootstrap.
 5067 bootstrap_options_prep ()
 5068 {
 5069     $debug_cmd
 5070 
 5071     # Option defaults:
 5072     opt_copy=${copy-'false'}
 5073     opt_dry_run=false
 5074     opt_force=false
 5075     opt_gnulib_srcdir=$GNULIB_SRCDIR
 5076     opt_skip_git=false
 5077     opt_skip_po=false
 5078 
 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
 5082 }
 5083 func_add_hook func_options_prep bootstrap_options_prep
 5084 
 5085 
 5086 # bootstrap_parse_options [ARG]...
 5087 # --------------------------------
 5088 # Provide handling for Bootstrap specific options.
 5089 bootstrap_parse_options ()
 5090 {
 5091     $debug_cmd
 5092 
 5093     # Perform our own loop to consume as many options as possible in
 5094     # each iteration.
 5095     while test $# -gt 0; do
 5096       _G_opt=$1
 5097       shift
 5098       case $_G_opt in
 5099         --dry-run|--dryrun|-n)
 5100                       opt_dry_run=: ;;
 5101         --copy|-c)    opt_copy=: ;;
 5102         --force|-f)   opt_force=: ;;
 5103 
 5104         --gnulib-srcdir)
 5105                       test $# = 0 && func_missing_arg $_G_opt && break
 5106                       opt_gnulib_srcdir=$1
 5107                       shift
 5108                       ;;
 5109 
 5110         --skip-git|--no-git)
 5111                       opt_skip_git=:
 5112                       ;;
 5113 
 5114         --skip-po|--no-po)
 5115                       opt_skip_po=:
 5116                       ;;
 5117 
 5118         # Separate non-argument short options:
 5119         -c*|-f*|-n*)
 5120                       func_split_short_opt "$_G_opt"
 5121                       set dummy "$func_split_short_opt_name" \
 5122                           "-$func_split_short_opt_arg" ${1+"$@"}
 5123                       shift
 5124                       ;;
 5125 
 5126         *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
 5127       esac
 5128     done
 5129 
 5130     # save modified positional parameters for caller
 5131     func_quote_for_eval ${1+"$@"}
 5132     bootstrap_parse_options_result=$func_quote_for_eval_result
 5133 }
 5134 func_add_hook func_parse_options bootstrap_parse_options
 5135 
 5136 
 5137 # bootstrap_validate_options [ARG]...
 5138 # -----------------------------------
 5139 # Perform any sanity checks on option settings and/or unconsumed
 5140 # arguments.
 5141 bootstrap_validate_options ()
 5142 {
 5143     $debug_cmd
 5144 
 5145     # Validate options.
 5146     test $# -gt 0 \
 5147         && func_fatal_help "too many arguments"
 5148 
 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
 5152 }
 5153 func_add_hook func_validate_options bootstrap_validate_options
 5154 
 5155 
 5156 ## -------------------------------------------------- ##
 5157 ## Source package customisations in 'bootstrap.conf'. ##
 5158 ## -------------------------------------------------- ##
 5159 
 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".
 5163 case $0 in
 5164   */*) test -r "$0.conf" && . "$0.conf" ;;
 5165   *) test -r "$0.conf" && . ./"$0.conf" ;;
 5166 esac
 5167 
 5168 
 5169 ## ------------------------------- ##
 5170 ## Actually perform the bootstrap. ##
 5171 ## ------------------------------- ##
 5172 
 5173 func_bootstrap ${1+"$@"}
 5174 
 5175 # The End.
 5176 exit ${exit_status-$EXIT_SUCCESS}
 5177 
 5178 # Local variables:
 5179 # mode: shell-script
 5180 # sh-indentation: 2
 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"
 5184 # End: