| 1 | #! /bin/sh |
| 2 | # Print a version string. |
| 3 | scriptversion=2011-08-19.18; # UTC |
| 4 | |
| 5 | # Bootstrap this package from checked-out sources. |
| 6 | # Written by Gary V. Vaughan, 2010 |
| 7 | |
| 8 | # Copyright (C) 2010 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 [email protected]. |
| 34 | |
| 35 | |
| 36 | ## ================================================================== ## |
| 37 | ## ## |
| 38 | ## DO NOT EDIT THIS FILE, CUSTOMIZE IT USING A BOOTSTRAP.CONF ## |
| 39 | ## ## |
| 40 | ## ================================================================== ## |
| 41 | |
| 42 | ## ------------------------------- ## |
| 43 | ## User overridable command paths. ## |
| 44 | ## ------------------------------- ## |
| 45 | |
| 46 | # All uppercase denotes values stored in the environment. These |
| 47 | # variables should generally be overridden by the user - however, we do |
| 48 | # set them to `true' in some parts of this script to prevent them being |
| 49 | # called at the wrong time by other tools that we call (`autoreconf', |
| 50 | # for example). |
| 51 | # |
| 52 | # We also allow `LIBTOOLIZE' and `M4' to be overridden, and export the |
| 53 | # result for child processes, but they are handled by the function |
| 54 | # `func_find_tool' and not defaulted in this section. |
| 55 | |
| 56 | : "${ACLOCAL=aclocal}" |
| 57 | : "${AUTOCONF=autoconf}" |
| 58 | : "${AUTOHEADER=autoheader}" |
| 59 | : "${AUTOM4TE=autom4te}" |
| 60 | : "${AUTOHEADER=autoheader}" |
| 61 | : "${AUTOMAKE=automake}" |
| 62 | : "${AUTOPOINT=autopoint}" |
| 63 | : "${AUTORECONF=autoreconf}" |
| 64 | : "${CMP=cmp}" |
| 65 | : "${CONFIG_SHELL=/bin/sh}" |
| 66 | : "${DIFF=diff}" |
| 67 | : "${EGREP=egrep}" |
| 68 | : "${FGREP=fgrep}" |
| 69 | : "${GIT=git}" |
| 70 | : "${GREP=grep}" |
| 71 | : "${LN_S=ln -s}" |
| 72 | : "${RM=rm}" |
| 73 | : "${SED=sed}" |
| 74 | |
| 75 | export ACLOCAL |
| 76 | export AUTOCONF |
| 77 | export AUTOHEADER |
| 78 | export AUTOM4TE |
| 79 | export AUTOHEADER |
| 80 | export AUTOMAKE |
| 81 | export AUTOPOINT |
| 82 | export AUTORECONF |
| 83 | |
| 84 | |
| 85 | ## -------------- ## |
| 86 | ## Configuration. ## |
| 87 | ## -------------- ## |
| 88 | |
| 89 | # Short help message in response to `-h'. Add to this in `bootstrap.conf' |
| 90 | # if you accept any additional options. |
| 91 | usage_message="Bootstrap this package from the checked-out sources. |
| 92 | |
| 93 | Common Bootstrap Options: |
| 94 | -c, --copy copy files instead of creating symbolic links. |
| 95 | --debug enable verbose shell tracing |
| 96 | -n, --dry-run print commands rather than running them |
| 97 | -f, --force attempt to bootstrap even if the sources seem not to have |
| 98 | been checked out. |
| 99 | --gnulib-srcdir=DIRNAME |
| 100 | specify a local directory where gnulib sources reside. |
| 101 | Use this if you already have the gnulib sources on your |
| 102 | machine, and don't want to waste your bandwidth |
| 103 | downloading them again. Defaults to \$GNULIB_SRCDIR. |
| 104 | --skip-git do not fetch files from remote repositories |
| 105 | --skip-po do not download po files. |
| 106 | -v, --verbose verbosely report processing |
| 107 | --version print version information and exit |
| 108 | -W, --warnings=CATEGORY |
| 109 | report the warnings falling in CATEGORY [all] |
| 110 | -h, --help print short or long help message and exit |
| 111 | " |
| 112 | |
| 113 | # Warning categories used by `bootstrap', append others if you use them |
| 114 | # in your `bootstrap.conf'. |
| 115 | warning_categories="recommend settings upgrade" |
| 116 | |
| 117 | # Additional text appended to `usage_message' in response to `--help'. |
| 118 | long_help_message=" |
| 119 | Warning categories include: |
| 120 | \`all' show all warnings |
| 121 | \`none' turn off all the warnings |
| 122 | \`error' warnings are treated as fatal errors |
| 123 | \`recommend' show warnings about missing recommended packages |
| 124 | \`settings' show warnings about missing \`bootstrap.conf' settings |
| 125 | \`upgrade' show warnings about out-dated files |
| 126 | |
| 127 | If the file $progpath.conf exists in the same directory as this script, its |
| 128 | contents are read as shell variables to configure the bootstrap. |
| 129 | |
| 130 | For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR |
| 131 | are honored. |
| 132 | |
| 133 | Running without arguments will suffice in most cases. |
| 134 | " |
| 135 | |
| 136 | # A newline delimited list of triples of programs (that respond to |
| 137 | # --version), the minimum version numbers required (or just `-' in the |
| 138 | # version field if any version will be sufficient) and homepage URLs |
| 139 | # to help locate missing packages. |
| 140 | buildreq= |
| 141 | |
| 142 | # Name of a file containing instructions on installing missing packages |
| 143 | # required in `buildreq'. |
| 144 | buildreq_readme=README-hacking |
| 145 | |
| 146 | # These are extracted from AC_INIT in configure.ac, though you can |
| 147 | # override those values in `bootstrap.conf' if you prefer. |
| 148 | build_aux= |
| 149 | macro_dir= |
| 150 | package= |
| 151 | package_name= |
| 152 | package_version= |
| 153 | package_bugreport= |
| 154 | |
| 155 | # These are extracted from `gnulib-cache.m4', or else fall-back |
| 156 | # automatically on the gnulib defaults; unless you set the values |
| 157 | # manually in `bootstrap.conf'. |
| 158 | doc_base= |
| 159 | gnulib_mk= |
| 160 | gnulib_name= |
| 161 | local_gl_dir= |
| 162 | source_base= |
| 163 | tests_base= |
| 164 | |
| 165 | # The list of gnulib modules required at `gnulib-tool' time. If you |
| 166 | # check `gnulib-cache.m4' into your repository, then this list will be |
| 167 | # extracted automatically. |
| 168 | gnulib_modules= |
| 169 | |
| 170 | # Extra gnulib files that are not in modules, which override files of |
| 171 | # the same name installed by other bootstrap tools. |
| 172 | gnulib_non_module_files=" |
| 173 | build-aux/compile |
| 174 | build-aux/install-sh |
| 175 | build-aux/missing |
| 176 | build-aux/mdate-sh |
| 177 | build-aux/texinfo.tex |
| 178 | build-aux/depcomp |
| 179 | build-aux/config.guess |
| 180 | build-aux/config.sub |
| 181 | doc/INSTALL |
| 182 | " |
| 183 | |
| 184 | # Relative path to the local gnulib submodule, and url to the upstream |
| 185 | # git repository. If you have a gnulib entry in your .gitmodules file, |
| 186 | # these values are ignored. |
| 187 | gnulib_path= |
| 188 | gnulib_url= |
| 189 | |
| 190 | # Additional gnulib-tool options to use. |
| 191 | gnulib_tool_options=" |
| 192 | --no-changelog |
| 193 | " |
| 194 | |
| 195 | # bootstrap removes any macro-files that are not included by aclocal.m4, |
| 196 | # except for files listed in this variable which are always kept. |
| 197 | gnulib_precious=" |
| 198 | gnulib-tool.m4 |
| 199 | " |
| 200 | |
| 201 | # When truncating long commands for display, always allow at least this |
| 202 | # many characters before truncating. |
| 203 | min_cmd_len=160 |
| 204 | |
| 205 | # The command to download all .po files for a specified domain into |
| 206 | # a specified directory. Fill in the first %s is the domain name, and |
| 207 | # the second with the destination directory. Use rsync's -L and -r |
| 208 | # options because the latest/%s directory and the .po files within are |
| 209 | # all symlinks. |
| 210 | po_download_command_format=\ |
| 211 | "rsync --delete --exclude '*.s1' -Lrtvz \ |
| 212 | 'translationproject.org::tp/latest/%s/' '%s'" |
| 213 | |
| 214 | # Other locale categories that need message catalogs. |
| 215 | extra_locale_categories= |
| 216 | |
| 217 | # Additional xgettext options to use. Gnulib might provide you with an |
| 218 | # extensive list of additional options to append to this, but gettext |
| 219 | # 0.16.1 and newer appends them automaticaly, so you can safely ignore |
| 220 | # the complaints from `gnulib-tool' if your $configure_ac states: |
| 221 | # |
| 222 | # AM_GNU_GETTEXT_VERSION([0.16.1]) |
| 223 | xgettext_options=" |
| 224 | --flag=_:1:pass-c-format |
| 225 | --flag=N_:1:pass-c-format |
| 226 | " |
| 227 | |
| 228 | # Package copyright holder for gettext files. Defaults to FSF if unset. |
| 229 | copyright_holder= |
| 230 | |
| 231 | # File that should exist in the top directory of a checked out hierarchy, |
| 232 | # but not in a distribution tarball. |
| 233 | checkout_only_file= |
| 234 | |
| 235 | # Whether to use copies instead of symlinks by default (if set to true, |
| 236 | # the --copy option has no effect). |
| 237 | copy=false |
| 238 | |
| 239 | # Set this to ".cvsignore .gitignore" in `bootstrap.conf' if you want |
| 240 | # those files to be generated in directories like `lib/', `m4/', and `po/', |
| 241 | # or set it to "auto" to make this script select which to use based |
| 242 | # on which version control system (if any) is used in the source directory. |
| 243 | # Or set it to "none" to ignore VCS ignore files entirely. Default is |
| 244 | # "auto". |
| 245 | vc_ignore= |
| 246 | |
| 247 | |
| 248 | ## -------------------- ## |
| 249 | ## Shell normalisation. ## |
| 250 | ## -------------------- ## |
| 251 | |
| 252 | # NLS nuisances. |
| 253 | LANGUAGE=C |
| 254 | export LANGUAGE |
| 255 | |
| 256 | # Ensure file names are sorted consistently across platforms. |
| 257 | LC_ALL=C |
| 258 | export LC_ALL |
| 259 | |
| 260 | # CDPATH. |
| 261 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH |
| 262 | |
| 263 | |
| 264 | ## ------------------------- ## |
| 265 | ## Hook function management. ## |
| 266 | ## ------------------------- ## |
| 267 | |
| 268 | # This section contains functions for adding, removing, and running hooks |
| 269 | # to the main code. A hook is just a named list of of function, that can |
| 270 | # be run in order later on. |
| 271 | |
| 272 | |
| 273 | # func_append VAR VALUE |
| 274 | # --------------------- |
| 275 | # Append VALUE onto the existing contents of VAR. |
| 276 | if (eval 'x=a; x+=" b"; test "x$x" = "xa b"') 2>/dev/null |
| 277 | then |
| 278 | # This is an XSI compatible shell, allowing a faster implementation... |
| 279 | eval 'func_append () |
| 280 | { |
| 281 | $debug_cmd |
| 282 | |
| 283 | eval "$1+=\$2" |
| 284 | }' |
| 285 | else |
| 286 | # ...otherwise fall back to using expr, which is often a shell builtin. |
| 287 | func_append () |
| 288 | { |
| 289 | $debug_cmd |
| 290 | |
| 291 | eval "$1=\$$1\$2" |
| 292 | } |
| 293 | fi |
| 294 | |
| 295 | |
| 296 | # func_hookable FUNC_NAME |
| 297 | # ----------------------- |
| 298 | # Declare that FUNC_NAME will run hooks added with |
| 299 | # `func_add_hook FUNC_NAME ...'. |
| 300 | func_hookable () |
| 301 | { |
| 302 | $debug_cmd |
| 303 | |
| 304 | func_append hookable_funcs " $1" |
| 305 | } |
| 306 | |
| 307 | |
| 308 | # func_add_hook FUNC_NAME HOOK_FUNC |
| 309 | # --------------------------------- |
| 310 | # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must |
| 311 | # first have been declared "hookable" by a coll to `func_hookable'. |
| 312 | func_add_hook () |
| 313 | { |
| 314 | $debug_cmd |
| 315 | |
| 316 | case " $hookable_funcs " in |
| 317 | *" $1 "*) ;; |
| 318 | *) func_fatal_error "Error: \`$1' does not accept hook functions." ;; |
| 319 | esac |
| 320 | |
| 321 | eval func_append ${1}_hooks '" $2"' |
| 322 | } |
| 323 | |
| 324 | |
| 325 | # func_remove_hook FUNC_NAME HOOK_FUNC |
| 326 | # ------------------------------------ |
| 327 | # Remove HOOK_FUNC from the list of functions called by FUNC_NAME. |
| 328 | func_remove_hook () |
| 329 | { |
| 330 | $debug_cmd |
| 331 | |
| 332 | eval ${1}_hooks='`echo "\$'$1'_hooks" |$SED "s| '$2'||"`' |
| 333 | } |
| 334 | |
| 335 | |
| 336 | # func_run_hooks FUNC_NAME [ARG]... |
| 337 | # --------------------------------- |
| 338 | # Run all hook functions registered to FUNC_NAME. |
| 339 | func_run_hooks () |
| 340 | { |
| 341 | $debug_cmd |
| 342 | |
| 343 | case " $hookable_funcs " in |
| 344 | *" $1 "*) ;; |
| 345 | *) func_fatal_error "Error: \`$1' does not support hook funcions.n" ;; |
| 346 | esac |
| 347 | |
| 348 | eval hook_funcs="\$$1_hooks" |
| 349 | |
| 350 | # shift away the first argument (FUNC_NAME) |
| 351 | shift |
| 352 | func_run_hooks_result=${1+"$@"} |
| 353 | |
| 354 | for hook_func in $hook_funcs; do |
| 355 | eval $hook_func '"$@"' |
| 356 | |
| 357 | # store returned options list back into positional |
| 358 | # parameters for next `cmd' execution. |
| 359 | eval set dummy "$func_run_hooks_result"; shift |
| 360 | done |
| 361 | } |
| 362 | |
| 363 | |
| 364 | ## ------------------- ## |
| 365 | ## Hookable functions. ## |
| 366 | ## ------------------- ## |
| 367 | |
| 368 | # After `bootstrap.conf' has been sourced, execution proceeds by calling |
| 369 | # `func_bootstrap'. Where a function is decorated with `func_hookable |
| 370 | # func_name', you will find a matching `func_run_hooks func_name' which |
| 371 | # executes all functions added with `func_add_hook func_name my_func'. |
| 372 | # |
| 373 | # You might notice that many of these functions begin with a series of |
| 374 | # `$require_foo' lines. See the docu-comments at the start of the |
| 375 | # `Resource management' section for a description of what these are. |
| 376 | |
| 377 | |
| 378 | # func_bootstrap [ARG]... |
| 379 | # ----------------------- |
| 380 | # All the functions called inside func_bootstrap are hookable. See the |
| 381 | # the individual implementations for details. |
| 382 | func_bootstrap () |
| 383 | { |
| 384 | $debug_cmd |
| 385 | |
| 386 | # Save the current positional parameters to prevent them being |
| 387 | # corrupted by calls to `set' in `func_init'. |
| 388 | func_quote_for_eval ${1+"$@"} |
| 389 | my_saved_positional_parameters="$func_quote_for_eval_result" |
| 390 | |
| 391 | # initialisation |
| 392 | func_init |
| 393 | |
| 394 | # option processing |
| 395 | eval func_options "$my_saved_positional_parameters" |
| 396 | |
| 397 | # post-option preparation |
| 398 | func_prep |
| 399 | |
| 400 | # reconfigure the package |
| 401 | func_reconfigure |
| 402 | |
| 403 | # finalisation |
| 404 | func_fini |
| 405 | } |
| 406 | |
| 407 | |
| 408 | # func_init |
| 409 | # --------- |
| 410 | # Any early initialisations can be hooked to this function. Consider |
| 411 | # whether you can hook onto `func_prep' instead, because if you hook |
| 412 | # any slow to execute code in here, it will also add to the time before |
| 413 | # `./bootstrap --version' can respond. |
| 414 | func_hookable func_init |
| 415 | func_init () |
| 416 | { |
| 417 | $debug_cmd |
| 418 | |
| 419 | func_run_hooks func_init |
| 420 | } |
| 421 | |
| 422 | |
| 423 | # func_options [ARG]... |
| 424 | # --------------------- |
| 425 | # All the functions called inside func_options are hookable. See the |
| 426 | # individual implementations for details. |
| 427 | func_hookable func_options |
| 428 | func_options () |
| 429 | { |
| 430 | $debug_cmd |
| 431 | |
| 432 | func_options_prep ${1+"$@"} |
| 433 | eval func_parse_options \ |
| 434 | ${func_options_prep_result+"$func_options_prep_result"} |
| 435 | eval func_validate_options \ |
| 436 | ${func_parse_options+"$func_parse_options_result"} |
| 437 | |
| 438 | eval func_run_hooks func_options \ |
| 439 | ${func_validate_options_result+"$func_validate_options_result"} |
| 440 | |
| 441 | # save modified positional parameters for caller |
| 442 | func_options_result="$func_run_hooks_result" |
| 443 | } |
| 444 | |
| 445 | |
| 446 | # func_options_prep [ARG]... |
| 447 | # -------------------------- |
| 448 | # All initialisations required before starting the option parse loop. |
| 449 | # Note that when calling hook functions, we pass through the list of |
| 450 | # positional parameters. If a hook function modifies that list, and |
| 451 | # needs to propogate that back to rest of this script, then the complete |
| 452 | # modified list must be put in `func_run_hooks_result' before |
| 453 | # returning. |
| 454 | func_hookable func_options_prep |
| 455 | func_options_prep () |
| 456 | { |
| 457 | $debug_cmd |
| 458 | |
| 459 | warning_func=func_error |
| 460 | |
| 461 | # Option defaults: |
| 462 | opt_copy=${copy-false} |
| 463 | opt_dry_run=false |
| 464 | opt_force=false |
| 465 | opt_gnulib_srcdir="$GNULIB_SRCDIR" |
| 466 | opt_skip_git=false |
| 467 | opt_skip_po=false |
| 468 | opt_warning= |
| 469 | opt_verbose=false |
| 470 | |
| 471 | func_run_hooks func_options_prep ${1+"$@"} |
| 472 | |
| 473 | # save modified positional parameters for caller |
| 474 | func_options_prep_result="$func_run_hooks_result" |
| 475 | } |
| 476 | |
| 477 | |
| 478 | # func_parse_options [ARG]... |
| 479 | # --------------------------- |
| 480 | # The main option parsing loop. |
| 481 | # |
| 482 | # In order to add your own option parsing hooks, you must accept the |
| 483 | # full positional parameter list in your hook function, remove any |
| 484 | # options that you action, and then pass back the remaining unprocessed |
| 485 | # options in `func_run_hooks_result', escaped suitably for `eval'. Like |
| 486 | # this: |
| 487 | # |
| 488 | # my_silent_option () |
| 489 | # { |
| 490 | # $debug_cmd |
| 491 | # |
| 492 | # case $1 in |
| 493 | # --silent|-s) opt_silent=:; shift ;; |
| 494 | # esac |
| 495 | # |
| 496 | # func_quote_for_eval ${1+"$@"} |
| 497 | # func_run_hooks_result="$func_quote_for_eval_result" |
| 498 | # } |
| 499 | # func_add_hook func_parse_options my_silent_option |
| 500 | # |
| 501 | func_hookable func_parse_options |
| 502 | func_parse_options () |
| 503 | { |
| 504 | $debug_cmd |
| 505 | |
| 506 | func_parse_options_result= |
| 507 | |
| 508 | # this just eases exit handling |
| 509 | while test $# -gt 0; do |
| 510 | |
| 511 | # Defer to hook functions for initial option parsing, so they |
| 512 | # get priority in the event of reusing an option name. |
| 513 | func_run_hooks func_parse_options ${1+"$@"} |
| 514 | |
| 515 | # Adjust func_parse_options positional parameters to match |
| 516 | eval set dummy "$func_run_hooks_result"; shift |
| 517 | |
| 518 | opt="$1" |
| 519 | shift |
| 520 | case $opt in |
| 521 | --debug|-x) debug_cmd='set -x' |
| 522 | func_echo "enabling shell trace mode" |
| 523 | $debug_cmd |
| 524 | ;; |
| 525 | --dry-run|--dryrun|-n) |
| 526 | opt_dry_run=: ;; |
| 527 | --copy|-c) opt_copy=: ;; |
| 528 | --force|-f) opt_force=: ;; |
| 529 | |
| 530 | --gnulib-srcdir) |
| 531 | test $# = 0 && func_missing_arg $opt && break |
| 532 | opt_gnulib_srcdir="$1" |
| 533 | shift |
| 534 | ;; |
| 535 | |
| 536 | --skip-git) opt_skip_git=: ;; |
| 537 | --skip-po) opt_skip_po=: ;; |
| 538 | --verbose|-v) opt_verbose=: ;; |
| 539 | |
| 540 | --warnings|--warning|-W) |
| 541 | test $# = 0 && func_missing_arg $opt && break |
| 542 | case " $1 " in |
| 543 | " all ") |
| 544 | opt_warning=" $warning_categories" |
| 545 | ;; |
| 546 | " none ") |
| 547 | opt_warning=" none" |
| 548 | warning_func=: |
| 549 | ;; |
| 550 | " error ") |
| 551 | warning_func=func_fatal_error |
| 552 | ;; |
| 553 | *" $warning_categories "*) |
| 554 | func_append_u opt_warning " $1" |
| 555 | ;; |
| 556 | *) |
| 557 | func_fatal_error \ |
| 558 | "Error: unsupported warning category: \`$1'" |
| 559 | ;; |
| 560 | esac |
| 561 | shift |
| 562 | ;; |
| 563 | |
| 564 | --version) func_version ;; |
| 565 | -\?|-h) func_usage ;; |
| 566 | --help) func_help ;; |
| 567 | |
| 568 | # Separate optargs to long options: |
| 569 | --*=*) |
| 570 | func_split_equals "$opt" |
| 571 | set dummy "$func_split_equals_lhs" \ |
| 572 | "$func_split_equals_rhs" ${1+"$@"} |
| 573 | shift |
| 574 | ;; |
| 575 | |
| 576 | # Separate optargs to short options: |
| 577 | -W*) |
| 578 | func_split_short_opt "$opt" |
| 579 | set dummy "$func_split_short_opt_name" \ |
| 580 | "$func_split_short_opt_arg" ${1+"$@"} |
| 581 | shift |
| 582 | ;; |
| 583 | |
| 584 | # Separate non-argument short options: |
| 585 | -\?*|-h*|-c*|-f*|-n*|-v*|-x*) |
| 586 | func_split_short_opt "$opt" |
| 587 | set dummy "$func_split_short_opt_name" \ |
| 588 | "-$func_split_short_opt_arg" ${1+"$@"} |
| 589 | shift |
| 590 | ;; |
| 591 | |
| 592 | --) set dummy "$opt"; shift; break ;; |
| 593 | -*) func_fatal_help "unrecognised option: \`$opt'" ;; |
| 594 | *) set dummy "$opt"; shift; break ;; |
| 595 | esac |
| 596 | done |
| 597 | |
| 598 | # save modified positional parameters for caller |
| 599 | func_quote_for_eval ${1+"$@"} |
| 600 | func_parse_options_result="$func_quote_for_eval_result" |
| 601 | } |
| 602 | |
| 603 | |
| 604 | # func_validate_options [ARG]... |
| 605 | # ------------------------------ |
| 606 | # Perform any sanity checks on option settings and/or unconsumed |
| 607 | # arguments. |
| 608 | func_hookable func_validate_options |
| 609 | func_validate_options () |
| 610 | { |
| 611 | $debug_cmd |
| 612 | |
| 613 | # display all warnings if -W was not given |
| 614 | test -n "$opt_warning" || opt_warning="$warning_categories" |
| 615 | |
| 616 | func_run_hooks func_validate_options ${1+"$@"} |
| 617 | |
| 618 | # Validate options. |
| 619 | test $# -gt 0 \ |
| 620 | && func_fatal_help "too many arguments" |
| 621 | |
| 622 | # Bail if the options were screwed! |
| 623 | $exit_cmd $EXIT_FAILURE |
| 624 | |
| 625 | # save modified positional parameters for caller |
| 626 | func_quote_for_eval ${1+"$@"} |
| 627 | func_validate_options_result="$func_quote_for_eval_result" |
| 628 | } |
| 629 | |
| 630 | |
| 631 | # func_prep |
| 632 | # --------- |
| 633 | # Function to perform preparation for remaining bootstrap process. If |
| 634 | # your hooked code relies on the outcome of `func_options' hook it here |
| 635 | # rather than to `func_init'. |
| 636 | # |
| 637 | # All the functions called inside func_prep are hookable. See the |
| 638 | # individual implementations for details. |
| 639 | func_hookable func_prep |
| 640 | func_prep () |
| 641 | { |
| 642 | $debug_cmd |
| 643 | |
| 644 | $require_bootstrap_uptodate |
| 645 | $require_buildtools_uptodate |
| 646 | $require_checkout_only_file |
| 647 | |
| 648 | $require_gnulib_merge_changelog |
| 649 | |
| 650 | # fetch update files from the translation project |
| 651 | func_update_translations |
| 652 | |
| 653 | func_run_hooks func_prep |
| 654 | } |
| 655 | |
| 656 | |
| 657 | # func_update_translations |
| 658 | # ------------------------ |
| 659 | # Update package po files and translations. |
| 660 | func_hookable func_update_translations |
| 661 | func_update_translations () |
| 662 | { |
| 663 | $debug_cmd |
| 664 | |
| 665 | $opt_skip_po || { |
| 666 | test -d po && { |
| 667 | $require_package |
| 668 | |
| 669 | func_update_po_files po $package || exit $? |
| 670 | } |
| 671 | |
| 672 | func_run_hooks func_update_translations |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | |
| 677 | # func_reconfigure |
| 678 | # ---------------- |
| 679 | # Reconfigure the current package by running the appropriate autotools in a |
| 680 | # suitable order. |
| 681 | func_hookable func_reconfigure |
| 682 | func_reconfigure () |
| 683 | { |
| 684 | $debug_cmd |
| 685 | |
| 686 | # Released `autopoint' has the tendency to install macros that have |
| 687 | # been obsoleted in current `gnulib., so run this before `gnulib-tool'. |
| 688 | func_autopoint |
| 689 | |
| 690 | # Autoreconf runs `aclocal' before `libtoolize', which causes spurious |
| 691 | # warnings if the initial `aclocal' is confused by the libtoolized |
| 692 | # (or worse: out-of-date) macro directory. |
| 693 | func_libtoolize |
| 694 | |
| 695 | # If you need to do anything after `gnulib-tool' is done, but before |
| 696 | # `autoreconf' runs, you don't need to override this whole function, |
| 697 | # because `func_gnulib_tool' is hookable. |
| 698 | func_gnulib_tool |
| 699 | |
| 700 | func_autoreconf |
| 701 | |
| 702 | func_run_hooks func_reconfigure |
| 703 | } |
| 704 | |
| 705 | |
| 706 | # func_gnulib_tool |
| 707 | # ---------------- |
| 708 | # Run `gnulib-tool' to fetch gnulib modules into the current package. |
| 709 | # |
| 710 | # It's assumed that since you are using gnulib's `bootstrap' script, |
| 711 | # you're also using gnulib elsewhere in your package. If not, then |
| 712 | # you can replace this function in `bootstrap.conf' with: |
| 713 | # |
| 714 | # func_gnulib_tool () { :; } |
| 715 | # |
| 716 | # (although the function returns immediately if $gnulib_tool is set to |
| 717 | # true in any case). |
| 718 | func_hookable func_gnulib_tool |
| 719 | func_gnulib_tool () |
| 720 | { |
| 721 | $debug_cmd |
| 722 | |
| 723 | $require_gnulib_tool |
| 724 | $require_libtoolize |
| 725 | |
| 726 | test true = "$gnulib_tool" || { |
| 727 | if test -n "$gnulib_modules"; then |
| 728 | $require_gnulib_cache |
| 729 | $require_build_aux |
| 730 | $require_macro_dir |
| 731 | |
| 732 | # Try not to pick up any stale values from `gnulib-cache.m4'. |
| 733 | rm -f "$gnulib_cache" |
| 734 | |
| 735 | gnulib_mode="--import" |
| 736 | |
| 737 | # `gnulib_modules' and others are maintained in `bootstrap.conf`: |
| 738 | # Use `gnulib --import` to fetch gnulib modules. |
| 739 | test -n "$build_aux" \ |
| 740 | && func_append_u gnulib_tool_options " --aux-dir=$build_aux" |
| 741 | test -n "$macro_dir" \ |
| 742 | && func_append_u gnulib_tool_options " --m4-base=$macro_dir" |
| 743 | test -n "$doc_base" \ |
| 744 | && func_append_u gnulib_tool_options " --doc-base=$doc_base" |
| 745 | test -n "$gnulib_name" \ |
| 746 | && func_append_u gnulib_tool_options " --lib=$gnulib_name" |
| 747 | test -n "$local_gl_dir" \ |
| 748 | && func_append_u gnulib_tool_options " --local-dir=$local_gl_dir" |
| 749 | test -n "$source_base" \ |
| 750 | && func_append_u gnulib_tool_options " --source-base=$source_base" |
| 751 | test -n "$gnulib_mk" \ |
| 752 | && func_append_u gnulib_tool_options " --makefile-name=$gnulib_mk" |
| 753 | test -n "$tests_base" && { |
| 754 | func_append_u gnulib_tool_options " --tests-base=$tests_base" |
| 755 | func_append_u gnulib_tool_options " --with-tests" |
| 756 | } |
| 757 | else |
| 758 | |
| 759 | # `gnulib_modules' and others are cached in `gnulib-cache.m4': |
| 760 | # Use `gnulib --update' to fetch gnulib modules. |
| 761 | gnulib_mode="--update" |
| 762 | fi |
| 763 | |
| 764 | # Add a sensible default libtool option to gnulib_tool_options. |
| 765 | case " $gnulib_tool_options " in |
| 766 | *" --no-libtool "*|*" --libtool "*) ;; |
| 767 | *) if test true = "$LIBTOOLIZE"; then |
| 768 | func_append_u gnulib_tool_options " --no-libtool" |
| 769 | else |
| 770 | func_append_u gnulib_tool_options " --libtool" |
| 771 | fi |
| 772 | ;; |
| 773 | esac |
| 774 | |
| 775 | $opt_copy || func_append_u gnulib_tool_options " --symbolic" |
| 776 | |
| 777 | func_append_u gnulib_tool_options " $gnulib_mode" |
| 778 | func_append gnulib_tool_options " $gnulib_modules" |
| 779 | |
| 780 | # The embedded echo is to squash whitespace before display. |
| 781 | gnulib_cmd=`echo $gnulib_tool $gnulib_tool_options` |
| 782 | |
| 783 | func_show_eval "$gnulib_cmd" 'exit $?' |
| 784 | } |
| 785 | |
| 786 | func_run_hooks func_gnulib_tool |
| 787 | } |
| 788 | |
| 789 | |
| 790 | # func_fini |
| 791 | # --------- |
| 792 | # Function to perform all finalisation for the bootstrap process. |
| 793 | func_hookable func_fini |
| 794 | func_fini () |
| 795 | { |
| 796 | $debug_cmd |
| 797 | |
| 798 | func_install_gnulib_non_module_files |
| 799 | func_gettext_configuration |
| 800 | func_clean_dangling_symlinks |
| 801 | func_clean_unused_macros |
| 802 | func_skip_po_recommendation |
| 803 | |
| 804 | func_run_hooks func_fini |
| 805 | |
| 806 | func_echo "Done. Now you can run './configure'." |
| 807 | } |
| 808 | |
| 809 | |
| 810 | # func_gettext_configuration |
| 811 | # -------------------------- |
| 812 | # Edit configuration values into po/Makevars. |
| 813 | func_hookable func_gettext_configuration |
| 814 | func_gettext_configuration () |
| 815 | { |
| 816 | $debug_cmd |
| 817 | |
| 818 | $require_autopoint |
| 819 | |
| 820 | test true = "$AUTOPOINT" || { |
| 821 | $require_copyright_holder |
| 822 | $require_extra_locale_categories |
| 823 | $require_package_bugreport |
| 824 | |
| 825 | # Escape xgettext options for sed Makevars generation below. |
| 826 | # We have to delete blank lines in a separate script so that we don't |
| 827 | # append \\\ to the penultimate line, and then delete the last empty |
| 828 | # line, which messes up the variable substitution later in this |
| 829 | # function. Note that adding a literal \\\ requires double escaping |
| 830 | # here, once for the execution subshell, and again for the assignment, |
| 831 | # which is why there are actually 12 (!!) backslashes in the script. |
| 832 | my_xgettext_options=`echo "$xgettext_options$nl" |$SED '/^$/d' |$SED ' |
| 833 | $b |
| 834 | s|$| \\\\\\\\\\\\|'` |
| 835 | |
| 836 | # Create gettext configuration. |
| 837 | func_echo "Creating po/Makevars from po/Makevars.template ..." |
| 838 | $RM -f po/Makevars |
| 839 | $SED ' |
| 840 | /^EXTRA_LOCALE_CATEGORIES *=/s|=.*|= '"$extra_locale_categories"'| |
| 841 | /^COPYRIGHT_HOLDER *=/s|=.*|= '"$copyright_holder"'| |
| 842 | /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$package_bugreport"'| |
| 843 | /^XGETTEXT_OPTIONS *=/{ |
| 844 | s|$| \\| |
| 845 | a\ |
| 846 | '"$my_xgettext_options"' \\\ |
| 847 | $${end_of_xgettext_options+} |
| 848 | } |
| 849 | ' po/Makevars.template >po/Makevars || exit 1 |
| 850 | } |
| 851 | |
| 852 | func_run_hooks func_gettext_configuration |
| 853 | } |
| 854 | |
| 855 | |
| 856 | |
| 857 | ## --------------- ## |
| 858 | ## Core functions. ## |
| 859 | ## --------------- ## |
| 860 | |
| 861 | # This section contains the main functions called from the `Hookable |
| 862 | # functions' (shown above), and are the ones you're most likely |
| 863 | # to want to replace with your own implementations in `bootstrap.conf'. |
| 864 | |
| 865 | |
| 866 | # func_autopoint |
| 867 | # -------------- |
| 868 | # If this package uses gettext, then run `autopoint'. |
| 869 | func_autopoint () |
| 870 | { |
| 871 | $debug_cmd |
| 872 | |
| 873 | $require_autopoint |
| 874 | |
| 875 | test true = "$AUTOPOINT" \ |
| 876 | || func_show_eval "$AUTOPOINT --force" 'exit $?' |
| 877 | } |
| 878 | |
| 879 | |
| 880 | # func_libtoolize |
| 881 | # --------------- |
| 882 | # If this package uses libtool, then run `libtoolize'. |
| 883 | func_libtoolize () |
| 884 | { |
| 885 | $debug_cmd |
| 886 | |
| 887 | $require_libtoolize |
| 888 | |
| 889 | test true = "$LIBTOOLIZE" || { |
| 890 | my_libtoolize_options= |
| 891 | $opt_copy && func_append my_libtoolize_options " --copy" |
| 892 | $opt_force && func_append my_libtoolize_options " --force" |
| 893 | $opt_verbose || func_append my_libtoolize_options " --quiet" |
| 894 | func_show_eval "$LIBTOOLIZE$my_libtoolize_options" 'exit $?' |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | |
| 899 | # func_autoreconf |
| 900 | # --------------- |
| 901 | # Being careful not to re-run `autopoint' or `libtoolize', and not to |
| 902 | # try to run `autopoint', `libtoolize' or `autoheader' on packages that |
| 903 | # don't use them, defer to `autoreconf' for execution of the remaining |
| 904 | # autotools to bootstrap this package. |
| 905 | func_autoreconf () |
| 906 | { |
| 907 | $debug_cmd |
| 908 | |
| 909 | $require_autoheader |
| 910 | $require_build_aux # automake and others put files in here |
| 911 | $require_macro_dir # aclocal and others put files in here |
| 912 | |
| 913 | # We ran these manually already, and autoreconf won't exec `:' |
| 914 | save_AUTOPOINT="$AUTOPOINT"; AUTOPOINT=true |
| 915 | save_LIBTOOLIZE="$LIBTOOLIZE"; LIBTOOLIZE=true |
| 916 | |
| 917 | my_autoreconf_options= |
| 918 | $opt_copy || func_append my_autoreconf_options " --symlink" |
| 919 | $opt_force && func_append my_autoreconf_options " --force" |
| 920 | $opt_verbose && func_append my_autoreconf_options " --verbose" |
| 921 | func_show_eval "$AUTORECONF$my_autoreconf_options --install" 'exit $?' |
| 922 | |
| 923 | AUTOPOINT="$save_AUTOPOINT" |
| 924 | LIBTOOLIZE="$save_LIBTOOLIZE" |
| 925 | } |
| 926 | |
| 927 | |
| 928 | # func_install_gnulib_non_module_files |
| 929 | # ------------------------------------ |
| 930 | # Get additional non-module files from gnulib, overriding existing files. |
| 931 | func_install_gnulib_non_module_files () |
| 932 | { |
| 933 | $debug_cmd |
| 934 | |
| 935 | $require_build_aux |
| 936 | $require_gnulib_path |
| 937 | |
| 938 | test -n "$gnulib_non_module_files" && { |
| 939 | if test -n "$gnulib_path"; then |
| 940 | maybe_exit_cmd=: |
| 941 | |
| 942 | for file in $gnulib_non_module_files; do |
| 943 | case $file in |
| 944 | */COPYING*) dest=COPYING;; |
| 945 | */INSTALL) dest=INSTALL;; |
| 946 | build-aux/*) dest=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;; |
| 947 | *) dest=$file;; |
| 948 | esac |
| 949 | |
| 950 | # Be sure to show all copying errors before bailing out |
| 951 | if test -f "$gnulib_path/$file"; then |
| 952 | func_symlink_to_dir "$gnulib_path" $file $dest |
| 953 | else |
| 954 | func_error "Error: \`$gnulib_path/$file' does not exist" |
| 955 | maybe_exit_cmd="exit $EXIT_FAILURE" |
| 956 | fi |
| 957 | done |
| 958 | |
| 959 | $maybe_exit_cmd |
| 960 | else |
| 961 | func_warning recommend "\ |
| 962 | Unable to link \`\$gnulib_non_module_files', please provide the |
| 963 | location of a complete \`gnulib' tree by setting \`gnulib_path' in |
| 964 | your \`bootstrap.conf' or with the \`--gnulib-srcdir' option - or |
| 965 | else specify the location of your \`git' binary by setting \`GIT' |
| 966 | in the environment so that a fresh \`gnulib' submodule can be cloned." |
| 967 | fi |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | |
| 972 | # func_check_configuration VARNAME [CONFIGURE_MACRO] |
| 973 | # -------------------------------------------------- |
| 974 | func_check_configuration () |
| 975 | { |
| 976 | $debug_cmd |
| 977 | |
| 978 | $require_configure_ac |
| 979 | |
| 980 | eval 'test -n "$'$1'"' || { |
| 981 | my_error_msg="Error: please set \`$1' in \`bootstrap.conf'" |
| 982 | test -n "$2" \ |
| 983 | && func_append my_error_msg " |
| 984 | or add the following (or similar) to your \`$configure_ac': |
| 985 | $2" |
| 986 | |
| 987 | func_fatal_error "$my_error_msg" |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | |
| 992 | # func_clean_dangling_symlinks |
| 993 | # ---------------------------- |
| 994 | # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some |
| 995 | # gnulib-populated directories. Such .m4 files would cause aclocal to |
| 996 | # fail. The following requires GNU find 4.2.3 or newer. Considering |
| 997 | # the usual portability constraints of this script, that may seem a very |
| 998 | # demanding requirement, but it should be ok. Ignore any failure, |
| 999 | # which is fine, since this is only a convenience to help developers |
| 1000 | # avoid the relatively unusual case in which a symlinked-to .m4 file is |
| 1001 | # git-removed from gnulib between successive runs of this script. |
| 1002 | func_clean_dangling_symlinks () |
| 1003 | { |
| 1004 | $debug_cmd |
| 1005 | |
| 1006 | $require_macro_dir |
| 1007 | $require_source_base |
| 1008 | |
| 1009 | func_verbose "cleaning dangling symlinks" |
| 1010 | |
| 1011 | find "$macro_dir" "$source_base" \ |
| 1012 | -depth \( -name '*.m4' -o -name '*.[ch]' \) \ |
| 1013 | -type l -xtype l -delete > /dev/null 2>&1 |
| 1014 | } |
| 1015 | |
| 1016 | |
| 1017 | # func_clean_unused_macros |
| 1018 | # ------------------------ |
| 1019 | # Autopoint can result in over-zealously adding macros into $macro_dir |
| 1020 | # even though they are not actually used, for example tests to help |
| 1021 | # build the `intl' directory even though you have specified |
| 1022 | # `AM_GNU_GETTEXT([external])' in your configure.ac. This function |
| 1023 | # looks removes any macro files that can be found in gnulib, but |
| 1024 | # are not `m4_include'd by `aclocal.m4'. |
| 1025 | func_clean_unused_macros () |
| 1026 | { |
| 1027 | $debug_cmd |
| 1028 | |
| 1029 | $require_gnulib_path |
| 1030 | $require_macro_dir |
| 1031 | |
| 1032 | test -n "$gnulib_path" && test -f aclocal.m4 && { |
| 1033 | aclocal_m4s=`find . -name aclocal.m4 -print` |
| 1034 | |
| 1035 | # We use `ls|grep' instead of `ls *.m4' to avoid exceeding |
| 1036 | # command line length limits in some shells. |
| 1037 | for file in `cd $macro_dir && ls -1 |grep '\.m4$'`; do |
| 1038 | |
| 1039 | # Remove a macro file when aclocal.m4 does not m4_include it... |
| 1040 | func_grep_q 'm4_include([[]'$macro_dir/$file'])' $aclocal_m4s \ |
| 1041 | || test ! -f $gnulib_path/m4/$file || { |
| 1042 | |
| 1043 | # ...and there is an identical file in gnulib... |
| 1044 | if func_cmp_s $gnulib_path/m4/$file $macro_dir/$file; then |
| 1045 | |
| 1046 | # ...and it's not in the precious list (`echo' is needed |
| 1047 | # here to squash whitespace for the match expression). |
| 1048 | case " "`echo $gnulib_precious`" " in |
| 1049 | *" $file "*) ;; |
| 1050 | *) rm -f $macro_dir/$file |
| 1051 | func_verbose \ |
| 1052 | "removing unused gnulib file \`$macro_dir/$file'" |
| 1053 | esac |
| 1054 | fi |
| 1055 | } |
| 1056 | done |
| 1057 | } |
| 1058 | } |
| 1059 | |
| 1060 | |
| 1061 | # func_skip_po_recommendation |
| 1062 | # --------------------------- |
| 1063 | # If there is a po directory, and `--skip-po' wasn't passed, let the |
| 1064 | # user know that they can use `--skip-po' on subsequent invocations. |
| 1065 | func_skip_po_recommendation () |
| 1066 | { |
| 1067 | test ! -d po \ |
| 1068 | || $opt_skip_po \ |
| 1069 | || func_warning recommend "\ |
| 1070 | If your pofiles are up-to-date, you can rerun bootstrap |
| 1071 | as \`$progname --skip-po' to avoid redownloading." |
| 1072 | } |
| 1073 | |
| 1074 | |
| 1075 | ## -------------------- ## |
| 1076 | ## Resource management. ## |
| 1077 | ## -------------------- ## |
| 1078 | |
| 1079 | # This section contains definitions for functions that each ensure a |
| 1080 | # particular resource (a file, or a non-empty configuration variable for |
| 1081 | # example) is available, and if appropriate to extract default values |
| 1082 | # from pertinent package files. Where a variable already has a non- |
| 1083 | # empty value (as set by the package's `bootstrap.conf'), that value is |
| 1084 | # used in preference to deriving the default. Call them using their |
| 1085 | # associated `require_*' variable to ensure that they are executed, at |
| 1086 | # most, once. |
| 1087 | |
| 1088 | |
| 1089 | # require_checkout_only_file |
| 1090 | # -------------------------- |
| 1091 | # Bail out if this package only bootstraps properly from a repository |
| 1092 | # checkout. |
| 1093 | require_checkout_only_file=func_require_checkout_only_file |
| 1094 | func_require_checkout_only_file () |
| 1095 | { |
| 1096 | $debug_cmd |
| 1097 | |
| 1098 | test -n "$checkout_only_file" && test ! -f "$checkout_only_file" \ |
| 1099 | && func_fatal_error "\ |
| 1100 | Error: Bootstrapping from a non-checked-out distribution is risky." |
| 1101 | |
| 1102 | require_checkout_only_file=: |
| 1103 | } |
| 1104 | |
| 1105 | |
| 1106 | # require_aclocal_amflags |
| 1107 | # ----------------------- |
| 1108 | # Ensure `$aclocal_amflags' has a sensible default, extracted from |
| 1109 | # `Makefile.am' if necessary. |
| 1110 | require_aclocal_amflags=func_require_aclocal_amflags |
| 1111 | func_require_aclocal_amflags () |
| 1112 | { |
| 1113 | $debug_cmd |
| 1114 | |
| 1115 | $require_makefile_am |
| 1116 | |
| 1117 | my_sed_extract_aclocal_amflags='s|#.*$|| |
| 1118 | /^[ ]*ACLOCAL_AMFLAGS[ ]*=/ { |
| 1119 | s|^.*=[ ]*\(.*\)|aclocal_amflags="\1"| |
| 1120 | p |
| 1121 | }' |
| 1122 | |
| 1123 | my_aclocal_flags_cmd=`$SED -n "$my_sed_extract_aclocal_amflags" \ |
| 1124 | "$makefile_am"` |
| 1125 | eval "$my_aclocal_flags_cmd" |
| 1126 | |
| 1127 | func_verbose "ACLOCAL_AMFLAGS='$aclocal_amflags'" |
| 1128 | |
| 1129 | require_aclocal_amflags=: |
| 1130 | } |
| 1131 | |
| 1132 | |
| 1133 | # require_autobuild_buildreq |
| 1134 | # -------------------------- |
| 1135 | # Try to find whether the bootstrap requires autobuild. |
| 1136 | require_autobuild_buildreq=func_require_autobuild_buildreq |
| 1137 | func_require_autobuild_buildreq () |
| 1138 | { |
| 1139 | $debug_cmd |
| 1140 | |
| 1141 | printf "$buildreq"| func_grep_q '^[ ]*autobuild' || { |
| 1142 | $require_configure_ac |
| 1143 | |
| 1144 | func_extract_trace AB_INIT |
| 1145 | test -n "$func_extract_trace_result" && { |
| 1146 | func_append buildreq 'autobuild - http://josefsson.org/autobuild/ |
| 1147 | ' |
| 1148 | func_verbose "auto-adding \`autobuild' to build requirements" |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | require_autobuild_buildreq=: |
| 1153 | } |
| 1154 | |
| 1155 | |
| 1156 | # require_autoconf_buildreq |
| 1157 | # require_gettext_buildreq |
| 1158 | # require_libtoolize_buildreq |
| 1159 | # --------------------------- |
| 1160 | # Try to find the minimum compatible version of autoconf/libtool |
| 1161 | # required to bootstrap successfully, and add it to `$buildreq'. |
| 1162 | for tool in autoconf libtoolize gettext; do |
| 1163 | b=$tool |
| 1164 | v=require_${tool}_buildreq |
| 1165 | f=func_$v |
| 1166 | case $tool in |
| 1167 | autoconf) m=AC_PREREQ ;; |
| 1168 | libtoolize) m=LT_PREREQ; b=libtool ;; |
| 1169 | gettext) m=AM_GNU_GETTEXT_VERSION ;; |
| 1170 | esac |
| 1171 | |
| 1172 | eval $v'='$f' |
| 1173 | '$f' () |
| 1174 | { |
| 1175 | $debug_cmd |
| 1176 | |
| 1177 | # The following is ignored if undefined, but might be necessary |
| 1178 | # in order for `func_find_tool` to run. |
| 1179 | ${require_'$tool'-:} |
| 1180 | |
| 1181 | printf "$buildreq" | func_grep_q '\''^[ ]*'$tool\'' || { |
| 1182 | $require_configure_ac |
| 1183 | |
| 1184 | func_extract_trace '$m' |
| 1185 | my_version="$func_extract_trace_result" |
| 1186 | test -n "$my_version" && { |
| 1187 | func_append buildreq "\ |
| 1188 | '$tool' $my_version http://www.gnu.org/s/'$b' |
| 1189 | " |
| 1190 | func_verbose \ |
| 1191 | "auto-adding \`'$tool'-$my_version'\'' to build requirements" |
| 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | '$v'=: |
| 1196 | } |
| 1197 | ' |
| 1198 | done |
| 1199 | |
| 1200 | |
| 1201 | # require_autoheader |
| 1202 | # ------------------ |
| 1203 | # Skip autoheader if it's not needed. |
| 1204 | require_autoheader=func_require_autoheader |
| 1205 | func_require_autoheader () |
| 1206 | { |
| 1207 | $debug_cmd |
| 1208 | |
| 1209 | test true = "$AUTOHEADER" || { |
| 1210 | func_extract_trace AC_CONFIG_HEADERS |
| 1211 | test -n "$func_extract_trace_result" \ |
| 1212 | || func_extract_trace AC_CONFIG_HEADER |
| 1213 | |
| 1214 | test -n "$func_extract_trace_result" || { |
| 1215 | AUTOHEADER=true |
| 1216 | |
| 1217 | func_verbose "export AUTOHEADER='$AUTOHEADER'" |
| 1218 | |
| 1219 | # Make sure the search result is visible to subshells |
| 1220 | export AUTOHEADER |
| 1221 | } |
| 1222 | } |
| 1223 | |
| 1224 | require_autoheader=: |
| 1225 | } |
| 1226 | |
| 1227 | |
| 1228 | # require_automake_buildreq |
| 1229 | # ------------------------- |
| 1230 | # Try to find the minimum compatible version of automake required to |
| 1231 | # bootstrap successfully, and add it to `$buildreq'. |
| 1232 | require_automake_buildreq=func_require_automake_buildreq |
| 1233 | func_require_automake_buildreq () |
| 1234 | { |
| 1235 | $debug_cmd |
| 1236 | |
| 1237 | # if automake is not already listed in $buildreq... |
| 1238 | printf "$buildreq"| func_grep_q automake || { |
| 1239 | func_extract_trace AM_INIT_AUTOMAKE |
| 1240 | |
| 1241 | # ...and AM_INIT_AUTOMAKE is declared... |
| 1242 | test -n "$func_extract_trace_result" && { |
| 1243 | automake_version=`echo "$func_extract_trace_result" \ |
| 1244 | |$SED 's|[^0-9]*||; s| .*$||'` |
| 1245 | test -n "$automake_version" || automake_version="-" |
| 1246 | |
| 1247 | func_append buildreq "\ |
| 1248 | automake $automake_version http://www.gnu.org/s/automake |
| 1249 | " |
| 1250 | func_verbose \ |
| 1251 | "auto-adding \`automake-$automake_version' to build requirements" |
| 1252 | } |
| 1253 | } |
| 1254 | |
| 1255 | require_automake_buildreq=: |
| 1256 | } |
| 1257 | |
| 1258 | |
| 1259 | # require_autopoint |
| 1260 | # ----------------- |
| 1261 | # Skip autopoint if it's not needed. |
| 1262 | require_autopoint=func_require_autopoint |
| 1263 | func_require_autopoint () |
| 1264 | { |
| 1265 | $debug_cmd |
| 1266 | |
| 1267 | test true = "$AUTOPOINT" || { |
| 1268 | func_extract_trace AM_GNU_GETTEXT_VERSION |
| 1269 | |
| 1270 | test -n "$func_extract_trace_result" || { |
| 1271 | AUTOPOINT=true |
| 1272 | |
| 1273 | func_verbose "export AUTOPOINT='$AUTOPOINT'" |
| 1274 | |
| 1275 | # Make sure the search result is visible to subshells |
| 1276 | export AUTOPOINT |
| 1277 | } |
| 1278 | } |
| 1279 | |
| 1280 | require_autopoint=: |
| 1281 | } |
| 1282 | |
| 1283 | |
| 1284 | # func_require_bootstrap_uptodate |
| 1285 | # ------------------------------- |
| 1286 | # Complain if the version of bootstrap in the gnulib directory differs |
| 1287 | # from the one we are running. |
| 1288 | require_bootstrap_uptodate=func_require_bootstrap_uptodate |
| 1289 | func_require_bootstrap_uptodate () |
| 1290 | { |
| 1291 | $debug_cmd |
| 1292 | |
| 1293 | $require_gnulib_path |
| 1294 | |
| 1295 | test x = x"$gnulib_path" \ |
| 1296 | || func_cmp_s $progpath $gnulib_path/build-aux/bootstrap \ |
| 1297 | || func_warning upgrade "\ |
| 1298 | \`$progpath' differs from \`./$gnulib_path/build-aux/bootstrap', |
| 1299 | please consider adopting the canonical version from gnulib." |
| 1300 | |
| 1301 | require_bootstrap_uptodate=: |
| 1302 | } |
| 1303 | |
| 1304 | |
| 1305 | # require_build_aux |
| 1306 | # ----------------- |
| 1307 | # Ensure that `$build_aux' is set, and if it doesn't already point to an |
| 1308 | # existing directory, create one. |
| 1309 | require_build_aux=func_require_build_aux |
| 1310 | func_require_build_aux () |
| 1311 | { |
| 1312 | $debug_cmd |
| 1313 | |
| 1314 | test -n "$build_aux" || { |
| 1315 | $require_configure_ac |
| 1316 | |
| 1317 | func_extract_trace AC_CONFIG_AUX_DIR |
| 1318 | build_aux="$func_extract_trace_result" |
| 1319 | func_check_configuration build_aux \ |
| 1320 | "AC_CONFIG_AUX_DIR([name of a directory for build scripts])" |
| 1321 | |
| 1322 | func_verbose "build_aux='$build_aux'" |
| 1323 | } |
| 1324 | |
| 1325 | $require_vc_ignore_files |
| 1326 | |
| 1327 | # If the build_aux directory doesn't exist, create it now, and mark it |
| 1328 | # as ignored for the VCS. |
| 1329 | if test ! -d "$build_aux"; then |
| 1330 | func_show_eval "mkdir '$build_aux'" |
| 1331 | |
| 1332 | test -n "$vc_ignore_files" \ |
| 1333 | || func_insert_sorted_if_absent "$build_aux" $vc_ignore_files |
| 1334 | fi |
| 1335 | |
| 1336 | require_build_aux=: |
| 1337 | } |
| 1338 | |
| 1339 | |
| 1340 | # func_require_buildtools_uptodate |
| 1341 | # -------------------------------- |
| 1342 | # Ensure all the packages listed in BUILDREQS are available on the build |
| 1343 | # machine at the minimum versions or better. |
| 1344 | require_buildtools_uptodate=func_require_buildtools_uptodate |
| 1345 | func_require_buildtools_uptodate () |
| 1346 | { |
| 1347 | $debug_cmd |
| 1348 | |
| 1349 | $require_autobuild_buildreq |
| 1350 | $require_autoconf_buildreq |
| 1351 | $require_automake_buildreq |
| 1352 | $require_libtoolize_buildreq |
| 1353 | $require_gettext_buildreq |
| 1354 | |
| 1355 | test -n "$buildreq" && { |
| 1356 | func_check_versions $buildreq |
| 1357 | $func_check_versions_result || { |
| 1358 | test -n "$buildreq_readme" \ |
| 1359 | && test -f "$buildreq_readme" \ |
| 1360 | && func_error "\ |
| 1361 | Error: $buildreq_readme explains how to obtain these prerequisite programs: |
| 1362 | " |
| 1363 | func_strtable 7 11 12 36 \ |
| 1364 | "Program" "Min_version" "Homepage" $buildreq |
| 1365 | func_fatal_error "$func_strtable_result" |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | require_buildtools_uptodate=: |
| 1370 | } |
| 1371 | |
| 1372 | |
| 1373 | # require_configure_ac |
| 1374 | # -------------------- |
| 1375 | # Ensure that there is a `configure.ac' or `configure.in' file in the |
| 1376 | # current directory, and that `$configure_ac' contains its name. |
| 1377 | require_configure_ac=func_require_configure_ac |
| 1378 | func_require_configure_ac () |
| 1379 | { |
| 1380 | $debug_cmd |
| 1381 | |
| 1382 | test -n "$configure_ac" || { |
| 1383 | for configure_ac in configure.ac configure.in; do |
| 1384 | test -f $configure_ac && break |
| 1385 | done |
| 1386 | |
| 1387 | <$configure_ac |
| 1388 | } |
| 1389 | |
| 1390 | func_verbose "found \`$configure_ac'" |
| 1391 | |
| 1392 | require_configure_ac=: |
| 1393 | } |
| 1394 | |
| 1395 | |
| 1396 | # require_copyright_holder |
| 1397 | # ------------------------ |
| 1398 | # Ensure there is a sensible non-empty default value in `$copyright_holder'. |
| 1399 | require_copyright_holder=func_require_copyright_holder |
| 1400 | func_require_copyright_holder () |
| 1401 | { |
| 1402 | $debug_cmd |
| 1403 | |
| 1404 | test -n "$copyright_holder" || { |
| 1405 | copyright_holder='Free Software Foundation, Inc.' |
| 1406 | func_warning settings "\ |
| 1407 | Please set copyright_holder explicitly in \`bootstrap.conf'; |
| 1408 | defaulting to \`$copyright_holder'." |
| 1409 | } |
| 1410 | |
| 1411 | require_copyright_holder=: |
| 1412 | } |
| 1413 | |
| 1414 | |
| 1415 | # require_dotgitmodules |
| 1416 | # --------------------- |
| 1417 | # Ensure we have a `.gitmodules' file, with appropriate `gnulib' settings. |
| 1418 | require_dotgitmodules=func_require_dotgitmodules |
| 1419 | func_require_dotgitmodules () |
| 1420 | { |
| 1421 | $debug_cmd |
| 1422 | |
| 1423 | $require_git |
| 1424 | |
| 1425 | test true = "$GIT" || { |
| 1426 | # A gnulib entry in .gitmodules always takes precedence. |
| 1427 | my_path="`$GIT config --file .gitmodules submodule.gnulib.path 2>/dev/null`" |
| 1428 | |
| 1429 | test -n "$my_path" || { |
| 1430 | $require_vc_ignore_files |
| 1431 | |
| 1432 | func_verbose "creating \`.gitmodules'" |
| 1433 | |
| 1434 | # If the .gitmodules file doesn't exist, create it now, and mark |
| 1435 | # it as ignored for the VCS. |
| 1436 | test -n "$gnulib_path" || gnulib_path=gnulib |
| 1437 | test -n "$gnulib_url" || gnulib_url=git://git.sv.gnu.org/gnulib |
| 1438 | |
| 1439 | { |
| 1440 | echo '[submodule "gnulib"]' |
| 1441 | echo " path = $gnulib_path" |
| 1442 | echo " url = $gnulib_url" |
| 1443 | } >> .gitmodules |
| 1444 | |
| 1445 | test -n "$vc_ignore_files" \ |
| 1446 | || func_insert_sorted_if_absent ".gitmodules" $vc_ignore_files |
| 1447 | } |
| 1448 | } |
| 1449 | |
| 1450 | require_dotgitmodules=: |
| 1451 | } |
| 1452 | |
| 1453 | |
| 1454 | # require_extra_locale_categories |
| 1455 | # ------------------------------- |
| 1456 | # Ensure there is a default value in `$extra_locale_categories' |
| 1457 | require_extra_locale_categories=func_require_extra_locale_categories |
| 1458 | func_require_extra_locale_categories () |
| 1459 | { |
| 1460 | $debug_cmd |
| 1461 | |
| 1462 | # Defaults to empty, so run with whatever value may have been set in |
| 1463 | # `bootstrap.conf'. |
| 1464 | require_extra_locale_categories=: |
| 1465 | } |
| 1466 | |
| 1467 | |
| 1468 | # require_git |
| 1469 | # ----------- |
| 1470 | # Ignore git if it's not available, or we're not in a git checkout tree. |
| 1471 | require_git=func_require_git |
| 1472 | func_require_git () |
| 1473 | { |
| 1474 | $debug_cmd |
| 1475 | |
| 1476 | $opt_skip_git && GIT=true |
| 1477 | |
| 1478 | test true = "$GIT" || { |
| 1479 | if test -f .gitignore && ($GIT --version) >/dev/null 2>&1; then :; else |
| 1480 | GIT=true |
| 1481 | fi |
| 1482 | } |
| 1483 | |
| 1484 | func_verbose "GIT='$GIT'" |
| 1485 | |
| 1486 | require_git=: |
| 1487 | } |
| 1488 | |
| 1489 | |
| 1490 | # require_gnu_m4 |
| 1491 | # -------------- |
| 1492 | # Search for GNU M4, and export it in $M4. |
| 1493 | require_gnu_m4=func_require_gnu_m4 |
| 1494 | func_require_gnu_m4 () |
| 1495 | { |
| 1496 | $debug_cmd |
| 1497 | |
| 1498 | test -n "$M4" || { |
| 1499 | # Find the first m4 binary that responds to --version. |
| 1500 | func_find_tool M4 gm4 gnum4 m4 |
| 1501 | } |
| 1502 | |
| 1503 | test -n "$M4" || func_fatal_error "\ |
| 1504 | Error: Please install GNU M4, or \`export M4=/path/to/gnu/m4'." |
| 1505 | |
| 1506 | func_verbose "export M4='$M4'" |
| 1507 | |
| 1508 | # Make sure the search result is visible to subshells |
| 1509 | export M4 |
| 1510 | |
| 1511 | require_gnu_m4=: |
| 1512 | } |
| 1513 | |
| 1514 | |
| 1515 | # require_gnulib_cache |
| 1516 | # -------------------- |
| 1517 | # Ensure there is a non-empty default for `$gnulib_cache', and that it |
| 1518 | # names an existing file. |
| 1519 | require_gnulib_cache=func_require_gnulib_cache |
| 1520 | func_require_gnulib_cache () |
| 1521 | { |
| 1522 | $debug_cmd |
| 1523 | |
| 1524 | $require_macro_dir |
| 1525 | |
| 1526 | test -n "$gnulib_cache" \ |
| 1527 | || gnulib_cache="$macro_dir/gnulib-cache.m4" |
| 1528 | |
| 1529 | func_verbose "found \`$gnulib_cache'" |
| 1530 | |
| 1531 | require_gnulib_cache=: |
| 1532 | } |
| 1533 | |
| 1534 | |
| 1535 | # require_gnulib_files_already_present |
| 1536 | # ------------------------------------ |
| 1537 | # If we have no means to update imported gnulib files, then try to |
| 1538 | # ensure at least that this tree already has files from a previous |
| 1539 | # `gnulib-tool' run. |
| 1540 | require_gnulib_files_already_present=func_require_gnulib_files_already_present |
| 1541 | func_require_gnulib_files_already_present () |
| 1542 | { |
| 1543 | $debug_cmd |
| 1544 | |
| 1545 | $require_build_aux |
| 1546 | $require_macro_dir |
| 1547 | $require_gnulib_mk |
| 1548 | $require_source_base |
| 1549 | |
| 1550 | # As a heuristic, only bail out if any of the following |
| 1551 | # are missing. |
| 1552 | my_gnulib_files_already_present=" |
| 1553 | $build_aux/install-sh |
| 1554 | $macro_dir/00gnulib.m4 |
| 1555 | $source_base/${gnulib_mk:-Makefile.am} |
| 1556 | " |
| 1557 | |
| 1558 | $opt_dry_run || { |
| 1559 | for my_file in $my_gnulib_files_already_present; do |
| 1560 | test -f "$my_file" || func_fatal_error "\ |
| 1561 | Error: Can't find, copy or download required gnulib files, |
| 1562 | please provide the location of a complete \`gnulib' tree |
| 1563 | by setting \`gnulib_path' in your \`bootstrap.conf' or |
| 1564 | with the \`--gnulib-srcdir' option - or else specify the |
| 1565 | location of your \`git' binary by setting \`GIT' in the |
| 1566 | environment so that a fresh \`gnulib' submodule can be |
| 1567 | cloned." |
| 1568 | done |
| 1569 | } |
| 1570 | |
| 1571 | require_gnulib_files_already_present=: |
| 1572 | } |
| 1573 | |
| 1574 | |
| 1575 | # require_gnulib_merge_changelog |
| 1576 | # ------------------------------ |
| 1577 | # See if we can use gnulib's git-merge-changelog merge driver. |
| 1578 | require_gnulib_merge_changelog=func_require_gnulib_merge_changelog |
| 1579 | func_require_gnulib_merge_changelog () |
| 1580 | { |
| 1581 | $debug_cmd |
| 1582 | |
| 1583 | test -f ChangeLog && { |
| 1584 | $require_git |
| 1585 | |
| 1586 | test true = "$GIT" || { |
| 1587 | if $GIT config merge.merge-changelog.driver >/dev/null ; then |
| 1588 | : |
| 1589 | elif (git-merge-changelog --version) >/dev/null 2>&1 ; then |
| 1590 | func_echo "initializing git-merge-changelog driver" |
| 1591 | $GIT config merge.merge-changelog.name 'GNU-style ChangeLog merge driver' |
| 1592 | $GIT config merge.merge-changelog.driver 'git-merge-changelog %O %A %B' |
| 1593 | else |
| 1594 | func_warning recommend \ |
| 1595 | "Consider installing git-merge-changelog from gnulib." |
| 1596 | fi |
| 1597 | } |
| 1598 | } |
| 1599 | |
| 1600 | require_gnulib_merge_changelog=: |
| 1601 | } |
| 1602 | |
| 1603 | |
| 1604 | # require_gnulib_mk |
| 1605 | # ----------------- |
| 1606 | # Ensure gnulib_mk has a sensible value, extracted from `gnulib-cache.m4' |
| 1607 | # if possible, otherwise letting `gnulib-tool' pick a default. |
| 1608 | require_gnulib_mk=func_require_gnulib_mk |
| 1609 | func_require_gnulib_mk () |
| 1610 | { |
| 1611 | $debug_cmd |
| 1612 | |
| 1613 | test -n "$gnulib_mk" || { |
| 1614 | $require_gnulib_cache |
| 1615 | $require_macro_dir |
| 1616 | |
| 1617 | func_extract_trace "gl_MAKEFILE_NAME" "$gnulib_cache" |
| 1618 | gnulib_mk="$func_extract_trace_result" |
| 1619 | |
| 1620 | test -n "$gnulib_mk" && func_verbose "gnulib_mk='$gnulib_mk'" |
| 1621 | } |
| 1622 | |
| 1623 | require_gnulib_mk=: |
| 1624 | } |
| 1625 | |
| 1626 | |
| 1627 | # require_gnulib_path |
| 1628 | # require_gnulib_url |
| 1629 | # ------------------- |
| 1630 | # Ensure `gnulib_path' and `gnulib_url' are set. |
| 1631 | require_gnulib_path=func_require_dotgitmodules_parameters |
| 1632 | require_gnulib_url=func_require_dotgitmodules_parameters |
| 1633 | func_require_dotgitmodules_parameters () |
| 1634 | { |
| 1635 | $debug_cmd |
| 1636 | |
| 1637 | $require_git |
| 1638 | |
| 1639 | if test true = "$GIT"; then |
| 1640 | # If we can't find git (or if the user specified `--skip-git'), |
| 1641 | # then use an existing gnulib directory specified with |
| 1642 | # `--gnulib-srcdir' if possible. |
| 1643 | test -n "$gnulib_path" \ |
| 1644 | || test ! -x "$opt_gnulib_srcdir/gnulib-tool" \ |
| 1645 | || gnulib_path="$opt_gnulib_srcdir" |
| 1646 | fi |
| 1647 | |
| 1648 | $require_dotgitmodules |
| 1649 | |
| 1650 | # Extract the parameters with sed, since git may be missing |
| 1651 | test -n "$gnulib_path" \ |
| 1652 | || gnulib_path=`sed -e '/^.submodule "gnulib".$/,${ |
| 1653 | /[ ]*path *= */{ |
| 1654 | s,[ ]*,,g;s,^[^=]*=,,;p |
| 1655 | } |
| 1656 | };d' .gitmodules | sed 1q` |
| 1657 | test -n "$gnulib_url" \ |
| 1658 | || gnulib_url=`sed -e '/^.submodule "gnulib".$/,${ |
| 1659 | /[ ]*url *= */{ |
| 1660 | s,[ ]*,,g;s,^[^=]*=,,;p |
| 1661 | } |
| 1662 | };d' .gitmodules | sed 1q` |
| 1663 | |
| 1664 | func_verbose "gnulib_path='$gnulib_path'" |
| 1665 | func_verbose "gnulib_url='$gnulib_url'" |
| 1666 | |
| 1667 | require_gnulib_path=: |
| 1668 | require_gnulib_url=: |
| 1669 | } |
| 1670 | |
| 1671 | |
| 1672 | # require_gnulib_submodule |
| 1673 | # ------------------------ |
| 1674 | # Ensure that there is a current gnulib submodule at `$gnulib_path'. |
| 1675 | require_gnulib_submodule=func_require_gnulib_submodule |
| 1676 | func_require_gnulib_submodule () |
| 1677 | { |
| 1678 | $debug_cmd |
| 1679 | |
| 1680 | $require_git |
| 1681 | |
| 1682 | if test true = "$GIT"; then |
| 1683 | func_warning recommend \ |
| 1684 | "No \`git' found; imported gnulib modules may be outdated." |
| 1685 | else |
| 1686 | $require_gnulib_path |
| 1687 | $require_gnulib_url |
| 1688 | |
| 1689 | if test -f .gitmodules && test -f "$gnulib_path/gnulib-tool"; then |
| 1690 | func_show_eval "$GIT submodule update" \ |
| 1691 | 'func_fatal_error "Error: Unable to update gnulib submodule."' |
| 1692 | |
| 1693 | elif test -n "$opt_gnulib_srcdir"; then |
| 1694 | # Older git can't clone into an empty directory. |
| 1695 | rmdir "$gnulib_path" 2>/dev/null |
| 1696 | func_show_eval "$GIT clone --reference '$opt_gnulib_srcdir' \ |
| 1697 | '$gnulib_url' '$gnulib_path'" \ |
| 1698 | && func_show_eval "$GIT submodule init" \ |
| 1699 | && func_show_eval "$GIT submodule update" \ |
| 1700 | || func_fatal_error "Error: Unable to fetch gnulib submodule." |
| 1701 | |
| 1702 | # Without --gnulib-srcdir, and no existing checked out submodule, we |
| 1703 | # create a new shallow clone of the remote gnulib repository. |
| 1704 | else |
| 1705 | trap func_cleanup_gnulib 1 2 13 15 |
| 1706 | |
| 1707 | shallow= |
| 1708 | $GIT clone -h 2>&1 |func_grep_q -- --depth \ |
| 1709 | && shallow='--depth 2' |
| 1710 | |
| 1711 | func_show_eval "$GIT clone $shallow '$gnulib_url' '$gnulib_path'" \ |
| 1712 | func_cleanup_gnulib |
| 1713 | |
| 1714 | trap - 1 2 13 15 |
| 1715 | fi |
| 1716 | fi |
| 1717 | |
| 1718 | require_gnulib_submodule=: |
| 1719 | } |
| 1720 | |
| 1721 | |
| 1722 | # require_gnulib_tool |
| 1723 | # ------------------- |
| 1724 | # Ensure that `$gnulib_tool' is set, and points to an executable file, |
| 1725 | # or else fall back to using the binary `true' if the main gnulib |
| 1726 | # files appear to have been imported already. |
| 1727 | require_gnulib_tool=func_require_gnulib_tool |
| 1728 | func_require_gnulib_tool () |
| 1729 | { |
| 1730 | $debug_cmd |
| 1731 | |
| 1732 | $require_gnulib_submodule |
| 1733 | |
| 1734 | test true = "$gnulib_tool" || { |
| 1735 | $require_gnulib_path |
| 1736 | |
| 1737 | test -n "$gnulib_tool" \ |
| 1738 | || gnulib_tool="$gnulib_path/gnulib-tool" |
| 1739 | |
| 1740 | test -x "$gnulib_tool" || { |
| 1741 | $require_gnulib_files_already_present |
| 1742 | |
| 1743 | gnulib_tool=true |
| 1744 | func_warning recommend \ |
| 1745 | "No \`gnulib-tool' found; gnulib modules may be missing." |
| 1746 | } |
| 1747 | |
| 1748 | test true = "$gnulib_tool" \ |
| 1749 | || func_verbose "found \`$gnulib_tool'" |
| 1750 | } |
| 1751 | |
| 1752 | require_gnulib_tool=: |
| 1753 | } |
| 1754 | |
| 1755 | |
| 1756 | # require_libtoolize |
| 1757 | # ------------------ |
| 1758 | # Skip libtoolize if it's not needed. |
| 1759 | require_libtoolize=func_require_libtoolize |
| 1760 | func_require_libtoolize () |
| 1761 | { |
| 1762 | $debug_cmd |
| 1763 | |
| 1764 | # Unless we're not searching for libtool use by this package, set |
| 1765 | # LIBTOOLIZE to true if none of `LT_INIT', `AC_PROG_LIBTOOL' and |
| 1766 | # `AM_PROG_LIBTOOL' are used in configure. |
| 1767 | test true = "$LIBTOOLIZE" || { |
| 1768 | func_extract_trace LT_INIT |
| 1769 | test -n "$func_extract_trace_result"||func_extract_trace AC_PROG_LIBTOOL |
| 1770 | test -n "$func_extract_trace_result"||func_extract_trace AM_PROG_LIBTOOL |
| 1771 | test -n "$func_extract_trace_result"||LIBTOOLIZE=true |
| 1772 | } |
| 1773 | |
| 1774 | test -n "$LIBTOOLIZE" || { |
| 1775 | # Find libtoolize, named glibtoolize in Mac Ports, but prefer |
| 1776 | # user-installed libtoolize to ancient glibtoolize shipped by |
| 1777 | # Apple with Mac OS X when Mac Ports is not installed. |
| 1778 | func_find_tool LIBTOOLIZE libtoolize glibtoolize |
| 1779 | } |
| 1780 | |
| 1781 | func_verbose "export LIBTOOLIZE='$LIBTOOLIZE'" |
| 1782 | |
| 1783 | # Make sure the search result is visible to subshells |
| 1784 | export LIBTOOLIZE |
| 1785 | |
| 1786 | require_libtoolize=: |
| 1787 | } |
| 1788 | |
| 1789 | |
| 1790 | # require_macro_dir |
| 1791 | # ----------------- |
| 1792 | # Ensure that `$macro_dir' is set, and if it doesn't already point to an |
| 1793 | # existing directory, create one. |
| 1794 | require_macro_dir=func_require_macro_dir |
| 1795 | func_require_macro_dir () |
| 1796 | { |
| 1797 | $debug_cmd |
| 1798 | |
| 1799 | # Sometimes this is stored in `configure.ac'. |
| 1800 | test -n "$macro_dir" || { |
| 1801 | func_extract_trace AC_CONFIG_MACRO_DIR |
| 1802 | macro_dir="$func_extract_trace_result" |
| 1803 | } |
| 1804 | |
| 1805 | # Otherwise we might find it in `Makefile.am'. |
| 1806 | test -n "$macro_dir" || { |
| 1807 | $require_aclocal_amflags |
| 1808 | |
| 1809 | my_sed_scan='s|^.*-I[ ]*\([^ ]*\) .*|\1|' |
| 1810 | |
| 1811 | # Trailing space in echo is required by the sed script. |
| 1812 | macro_dir=`echo "$aclocal_amflags " |$SED "$my_sed_scan"` |
| 1813 | } |
| 1814 | |
| 1815 | func_verbose "macro_dir='$macro_dir'" |
| 1816 | |
| 1817 | func_check_configuration macro_dir \ |
| 1818 | "AC_CONFIG_MACRO_DIR([name of a directory for configure m4 files])" |
| 1819 | |
| 1820 | $require_vc_ignore_files |
| 1821 | |
| 1822 | # If the macro_dir directory doesn't exist, create it now, and mark it |
| 1823 | # as ignored for the VCS. |
| 1824 | if test ! -d "$macro_dir"; then |
| 1825 | mkdir "$macro_dir" || func_permissions_error "$macro_dir" |
| 1826 | |
| 1827 | test -n "$vc_ignore_files" \ |
| 1828 | || func_insert_sorted_if_absent "$macro_dir" $vc_ignore_files |
| 1829 | fi |
| 1830 | |
| 1831 | require_macro_dir=: |
| 1832 | } |
| 1833 | |
| 1834 | |
| 1835 | # require_makefile_am |
| 1836 | # ------------------- |
| 1837 | # Ensure there is a `Makefile.am' in the current directory. |
| 1838 | # names an existing file. |
| 1839 | require_makefile_am=func_require_makefile_am |
| 1840 | func_require_makefile_am () |
| 1841 | { |
| 1842 | $debug_cmd |
| 1843 | |
| 1844 | test -n "$makefile_am" \ |
| 1845 | || makefile_am="Makefile.am" |
| 1846 | |
| 1847 | <"$makefile_am" |
| 1848 | |
| 1849 | func_verbose "found \`$makefile_am'" |
| 1850 | |
| 1851 | require_makefile_am=: |
| 1852 | } |
| 1853 | |
| 1854 | |
| 1855 | # require_package |
| 1856 | # --------------- |
| 1857 | # Ensure that `$package' contains a sensible default value. |
| 1858 | require_package=func_require_package |
| 1859 | func_require_package () |
| 1860 | { |
| 1861 | $debug_cmd |
| 1862 | |
| 1863 | test -n "$package" || { |
| 1864 | $require_package_name |
| 1865 | |
| 1866 | package=`echo "$package_name" \ |
| 1867 | |$SED 's/GNU //;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
| 1868 | } |
| 1869 | |
| 1870 | func_verbose "package='$package'" |
| 1871 | |
| 1872 | require_package=: |
| 1873 | } |
| 1874 | |
| 1875 | |
| 1876 | # require_package_bugreport |
| 1877 | # ------------------------- |
| 1878 | # Ensure that this has a sensible value, extracted from `configure.ac' |
| 1879 | # if appropriate (and possible!). |
| 1880 | require_package_bugreport=func_require_package_bugreport |
| 1881 | func_require_package_bugreport () |
| 1882 | { |
| 1883 | $debug_cmd |
| 1884 | |
| 1885 | func_extract_trace AC_INIT |
| 1886 | |
| 1887 | save_ifs="$IFS" |
| 1888 | IFS=: |
| 1889 | set dummy $func_extract_trace_result |
| 1890 | IFS="$save_ifs" |
| 1891 | shift |
| 1892 | |
| 1893 | test -n "$package_bugreport" || package_bugreport="$3" |
| 1894 | func_check_configuration package_bugreport \ |
| 1895 | "AC_INIT([$package_name], [$package_version], [[email protected]])" |
| 1896 | func_verbose "package_bugreport='$package_bugreport'" |
| 1897 | |
| 1898 | require_package_bugreport=: |
| 1899 | } |
| 1900 | |
| 1901 | |
| 1902 | # require_package_name |
| 1903 | # -------------------- |
| 1904 | # Ensure that this has a sensible value, extracted from `configure.ac' |
| 1905 | # if appropriate (and possible!). |
| 1906 | require_package_name=func_require_package_name |
| 1907 | func_require_package_name () |
| 1908 | { |
| 1909 | $debug_cmd |
| 1910 | |
| 1911 | func_extract_trace AC_INIT |
| 1912 | |
| 1913 | save_ifs="$IFS" |
| 1914 | IFS=: |
| 1915 | set dummy $func_extract_trace_result |
| 1916 | IFS="$save_ifs" |
| 1917 | shift |
| 1918 | |
| 1919 | test -n "$package_name" || package_name="$1" |
| 1920 | func_check_configuration package_name \ |
| 1921 | "AC_INIT([name of your package], [package version number])" |
| 1922 | func_verbose "package_name='$package_name'" |
| 1923 | |
| 1924 | require_package_name=: |
| 1925 | } |
| 1926 | |
| 1927 | |
| 1928 | # require_package_version |
| 1929 | # ----------------------- |
| 1930 | # Ensure that this has a sensible value, extracted from `configure.ac' |
| 1931 | # if appropriate (and possible!). While we might have set all the |
| 1932 | # parameters extracted from AC_INIT at once, `package_version' in |
| 1933 | # particular is not necessarily available as early as the others, since |
| 1934 | # `git-version-gen' is often involved, and until then we can't rely on |
| 1935 | # getting a correct version number from an AC_INIT extraction. |
| 1936 | require_package_version=func_require_package_version |
| 1937 | func_require_package_version () |
| 1938 | { |
| 1939 | $debug_cmd |
| 1940 | |
| 1941 | func_extract_trace AC_INIT |
| 1942 | |
| 1943 | save_ifs="$IFS" |
| 1944 | IFS=: |
| 1945 | set dummy $func_extract_trace_result |
| 1946 | IFS="$save_ifs" |
| 1947 | shift |
| 1948 | |
| 1949 | test -n "$package_version" || package_version="$2" |
| 1950 | func_check_configuration package_version \ |
| 1951 | "AC_INIT([$package_name], [package version number])" |
| 1952 | func_verbose "package_version='$package_version'" |
| 1953 | |
| 1954 | require_package_version=: |
| 1955 | } |
| 1956 | |
| 1957 | |
| 1958 | # require_source_base |
| 1959 | # ------------------- |
| 1960 | # Ensure that source_base has a sensible value, extracted from |
| 1961 | # `gnulib-cache.m4' if possible. |
| 1962 | require_source_base=func_require_source_base |
| 1963 | func_require_source_base () |
| 1964 | { |
| 1965 | $debug_cmd |
| 1966 | |
| 1967 | $require_gnulib_cache |
| 1968 | |
| 1969 | test -f "$gnulib_cache" && test x = "x$source_base" && { |
| 1970 | $require_macro_dir |
| 1971 | |
| 1972 | func_extract_trace "gl_SOURCE_BASE" "$gnulib_cache" |
| 1973 | |
| 1974 | source_base="$func_extract_trace_result" |
| 1975 | |
| 1976 | func_verbose "source_base='$source_base'" |
| 1977 | } |
| 1978 | |
| 1979 | # Only prevent repeated calls if we found something... |
| 1980 | # gnulib-cache.m4 might arrive before the next call. |
| 1981 | test -n "$source_base" && require_source_base=: |
| 1982 | } |
| 1983 | |
| 1984 | |
| 1985 | # require_vc_ignore_files |
| 1986 | # ----------------------- |
| 1987 | # Ensure that `$vc_ignore' has been processed to list VCS ignore files |
| 1988 | # in `$vc_ignore_files' |
| 1989 | require_vc_ignore_files=func_require_vc_ignore_files |
| 1990 | func_require_vc_ignore_files () |
| 1991 | { |
| 1992 | $debug_cmd |
| 1993 | |
| 1994 | test -n "$vc_ignore" || vc_ignore=auto |
| 1995 | |
| 1996 | if test auto = "$vc_ignore" && test x = x"$vc_ignore_files"; then |
| 1997 | vc_ignore_files= |
| 1998 | test -d .git && vc_ignore_files=.gitignore |
| 1999 | test -d CVS && vc_ignore_files="$vc_ignore_files .cvsignore" |
| 2000 | else |
| 2001 | vc_ignore_files="$vc_ignore" |
| 2002 | fi |
| 2003 | |
| 2004 | func_verbose "vc_ignore_files='$vc_ignore_files'" |
| 2005 | |
| 2006 | require_vc_ignore_files=: |
| 2007 | } |
| 2008 | |
| 2009 | |
| 2010 | ## ------------------## |
| 2011 | ## Helper functions. ## |
| 2012 | ## ------------------## |
| 2013 | |
| 2014 | # This section contains the helper functions used by the rest of `bootstrap'. |
| 2015 | |
| 2016 | # func_len STRING |
| 2017 | # --------------- |
| 2018 | # STRING may not start with a hyphen. |
| 2019 | if (eval 'x=123; test x${#x} = "x3"') 2>/dev/null |
| 2020 | then |
| 2021 | # This is an XSI compatible shell, allowing a faster implementation... |
| 2022 | eval 'func_len () |
| 2023 | { |
| 2024 | $debug_cmd |
| 2025 | |
| 2026 | func_len_result=${#1} |
| 2027 | }' |
| 2028 | else |
| 2029 | # ...otherwise fall back to using expr, which is often a shell builtin. |
| 2030 | func_len () |
| 2031 | { |
| 2032 | $debug_cmd |
| 2033 | |
| 2034 | func_len_result=`expr "$1" : ".*" 2>/dev/null || echo 0` |
| 2035 | } |
| 2036 | fi |
| 2037 | |
| 2038 | |
| 2039 | # func_unset VAR |
| 2040 | # -------------- |
| 2041 | # Portably unset VAR. |
| 2042 | func_unset () |
| 2043 | { |
| 2044 | { eval $1=; unset $1; } |
| 2045 | } |
| 2046 | unset=func_unset |
| 2047 | |
| 2048 | |
| 2049 | # func_cmp_s FILE1 FILE2 |
| 2050 | # ---------------------- |
| 2051 | # Return non-zero exit status unless FILE1 and FILE2 are identical, without |
| 2052 | # output. |
| 2053 | func_cmp_s () |
| 2054 | { |
| 2055 | $debug_cmd |
| 2056 | |
| 2057 | # This function relies on non-zero exit status, which will cause the |
| 2058 | # program to exit when running in `set -e' mode. |
| 2059 | $CMP "$@" >/dev/null 2>&1 |
| 2060 | } |
| 2061 | |
| 2062 | |
| 2063 | # func_grep_q EXPRESSION [FILENAME..]. |
| 2064 | # ------------------------------------ |
| 2065 | # Check whether EXPRESSION matches any line of any listed FILENAME, |
| 2066 | # without output. |
| 2067 | func_grep_q () |
| 2068 | { |
| 2069 | $debug_cmd |
| 2070 | |
| 2071 | # This function relies on non-zero exit status, which will cause the |
| 2072 | # program to exit when running in `set -e' mode. |
| 2073 | $GREP "$@" >/dev/null 2>&1 |
| 2074 | } |
| 2075 | |
| 2076 | |
| 2077 | # func_append_u VAR VALUE |
| 2078 | # ----------------------- |
| 2079 | # Append unique VALUE onto the existing contents of VAR, assuming |
| 2080 | # entries are delimited by the first character of VALUE. For example: |
| 2081 | # |
| 2082 | # func_append_u options " --another-option option-argument" |
| 2083 | # |
| 2084 | # will only append to $options if " --another-option option-argument " |
| 2085 | # is not already present somewhere in $options already (note spaces at |
| 2086 | # each end implied by leading space in second argument). |
| 2087 | func_append_u () |
| 2088 | { |
| 2089 | $debug_cmd |
| 2090 | |
| 2091 | eval my_current_value='`echo $'$1'`' |
| 2092 | my_delim=`expr "$2" : '\(.\)'` |
| 2093 | |
| 2094 | case $my_delim$my_current_value$my_delim in |
| 2095 | *"$2$my_delim"*) ;; |
| 2096 | *) func_append "$@" ;; |
| 2097 | esac |
| 2098 | } |
| 2099 | |
| 2100 | |
| 2101 | # func_strpad STR WIDTH CHAR |
| 2102 | # -------------------------- |
| 2103 | # Trim STR, or pad with CHAR to force a total length of WIDTH. |
| 2104 | func_strpad () |
| 2105 | { |
| 2106 | $debug_cmd |
| 2107 | |
| 2108 | my_width=`expr "$2" - 1` |
| 2109 | func_strpad_result=`echo "$1" |$SED ' |
| 2110 | :a |
| 2111 | s|^.\{0,'"$my_width"'\}$|&'"$3"'| |
| 2112 | ta |
| 2113 | '` |
| 2114 | } |
| 2115 | |
| 2116 | |
| 2117 | # func_strrpad STR WIDTH CHAR |
| 2118 | # --------------------------- |
| 2119 | # Trim STR, or right-justify-pad with CHAR to force a total length of |
| 2120 | # WIDTH. |
| 2121 | func_strrpad () |
| 2122 | { |
| 2123 | $debug_cmd |
| 2124 | |
| 2125 | my_width=`expr "$2" - 1` |
| 2126 | func_strrpad_result=`echo "$1" |$SED ' |
| 2127 | :a |
| 2128 | s|^.\{0,'"$my_width"'\}$|'"$3"'&| |
| 2129 | ta |
| 2130 | '` |
| 2131 | } |
| 2132 | |
| 2133 | |
| 2134 | # func_strrow INDENT FIELD WIDTH [FIELDn WIDTHn]... |
| 2135 | # ------------------------------------------------- |
| 2136 | # Return a string containing each FIELD left justified to WIDTH, with |
| 2137 | # the whole thing indented by INDENT spaces. This function is used to |
| 2138 | # render one row of aligned columns for a table by func_strtable(). |
| 2139 | func_strrow () |
| 2140 | { |
| 2141 | $debug_cmd |
| 2142 | |
| 2143 | func_strrow_linelen="$1"; shift |
| 2144 | |
| 2145 | my_row= |
| 2146 | while test $# -gt 0; do |
| 2147 | func_strrow_linelen=`expr $func_strrow_linelen + $2` |
| 2148 | func_strpad "$1" $2 " " |
| 2149 | func_append my_row "$func_strpad_result" |
| 2150 | shift; shift |
| 2151 | done |
| 2152 | |
| 2153 | func_strrpad "$my_row" $func_strrow_linelen " " |
| 2154 | func_strrow_result="$func_strrpad_result" |
| 2155 | } |
| 2156 | |
| 2157 | |
| 2158 | # func_strtable INDENT WIDTH1...WIDTHn HEADER1...HEADERn FIELD1...FIELDn |
| 2159 | # ---------------------------------------------------------------------- |
| 2160 | # Generate a string of newline-separated rows arranged in lined-up |
| 2161 | # columns of the given WIDTHs, with the entire table indented by INDENT |
| 2162 | # spaces. The number of columns is determined by the number of integer |
| 2163 | # valued WIDTH arguments following INDENT. The next set (i.e. a number |
| 2164 | # of arguments equal to the number of WIDTH arguments) of fields are |
| 2165 | # treated as the table's column HEADERs, and are separated from the |
| 2166 | # remainder of the table by an indented row of `-' characters. Remaining |
| 2167 | # arguments are each aligned below the next available header, wrapping |
| 2168 | # to a new row as necessary. Finally another row of `-' characters is |
| 2169 | # added to mark the end of the table. |
| 2170 | # |
| 2171 | # For example an unindented 3 column table with 2 rows of data would be |
| 2172 | # generated by this call: |
| 2173 | # |
| 2174 | # func_strtable 3 20 10 25 \ |
| 2175 | # Header1 Header2 Header3 \ |
| 2176 | # Row1Col1 Row1Col2 Row1Col3 \ |
| 2177 | # Row2Col1 Row2Col2 Row2Col3 |
| 2178 | # |
| 2179 | # returning the following string: |
| 2180 | # |
| 2181 | # " Header1 Header2 Header3 |
| 2182 | # ------------------------------------------------------- |
| 2183 | # Row1Col1 Row1Col2 Row1Col3 |
| 2184 | # Row2Col1 Row2Col2 Row2Col3 |
| 2185 | # -------------------------------------------------------" |
| 2186 | func_strtable () |
| 2187 | { |
| 2188 | $debug_cmd |
| 2189 | |
| 2190 | # Save the indent value, we'll need it for each row we render. |
| 2191 | my_indent="$1"; shift |
| 2192 | |
| 2193 | # Collect remaining numeric args into a list for reuse between |
| 2194 | # members of each row when we call func_strrow later. |
| 2195 | my_widths="$1"; shift |
| 2196 | while test 0 -lt `expr "$1" : '[1-9][0-9]*$'`; do |
| 2197 | func_append my_widths " $1"; shift |
| 2198 | done |
| 2199 | |
| 2200 | # Extract the same number of positional parameters as there are |
| 2201 | # width elements - we'll do the header rows separately so that |
| 2202 | # we can insert a divider line. |
| 2203 | my_header="$my_indent" |
| 2204 | for my_width in $my_widths; do |
| 2205 | func_append my_header " $1 $my_width"; shift |
| 2206 | done |
| 2207 | func_strrow $my_header |
| 2208 | |
| 2209 | # Strip off the indent, and make a divider with `-' chars, then |
| 2210 | # reindent. |
| 2211 | my_divider=`echo "$func_strrow_result" \ |
| 2212 | |$SED 's|[^ ]|-|g |
| 2213 | :a |
| 2214 | s|- |--|g |
| 2215 | ta |
| 2216 | '` |
| 2217 | |
| 2218 | # Append the header and divider to the running result. |
| 2219 | func_append func_strtable_result "\ |
| 2220 | $func_strrow_result |
| 2221 | $my_divider |
| 2222 | " |
| 2223 | |
| 2224 | # The remaining rows are zipped between the width values we |
| 2225 | # unwound earlier just like the header row above. |
| 2226 | while test $# -gt 0; do |
| 2227 | my_row="$my_indent" |
| 2228 | for my_width in $my_widths; do |
| 2229 | func_append my_row " $1 $my_width"; shift |
| 2230 | done |
| 2231 | func_strrow $my_row |
| 2232 | func_append func_strtable_result "\ |
| 2233 | $func_strrow_result |
| 2234 | " |
| 2235 | done |
| 2236 | |
| 2237 | # Mark the end of the table with a final divider line. |
| 2238 | func_append func_strtable_result "$my_divider" |
| 2239 | } |
| 2240 | |
| 2241 | |
| 2242 | # func_echo ARG... |
| 2243 | # ---------------- |
| 2244 | # Echo program name prefixed message, taking newlines into account. |
| 2245 | func_echo () |
| 2246 | { |
| 2247 | my_message="$*" |
| 2248 | |
| 2249 | save_IFS="$IFS" |
| 2250 | IFS="$nl" |
| 2251 | for my_line in $my_message; do |
| 2252 | IFS="$save_IFS" |
| 2253 | echo "$progname: $my_line" |
| 2254 | done |
| 2255 | IFS="$save_IFS" |
| 2256 | } |
| 2257 | |
| 2258 | |
| 2259 | # func_verbose ARG... |
| 2260 | # ------------------- |
| 2261 | # Echo program name prefixed message in verbose mode only. |
| 2262 | func_verbose () |
| 2263 | { |
| 2264 | $opt_verbose && func_echo ${1+"$@"} |
| 2265 | } |
| 2266 | |
| 2267 | |
| 2268 | # func_error ARG... |
| 2269 | # ----------------- |
| 2270 | # Echo program name prefixed message to standard error. |
| 2271 | func_error () |
| 2272 | { |
| 2273 | my_message="$*" |
| 2274 | |
| 2275 | save_IFS="$IFS" |
| 2276 | IFS="$nl" |
| 2277 | for my_line in $my_message; do |
| 2278 | IFS="$save_IFS" |
| 2279 | echo "$progname: $bold_on$my_line$bold_off" 1>&2 |
| 2280 | done |
| 2281 | IFS="$save_IFS" |
| 2282 | } |
| 2283 | |
| 2284 | # Allow display of bold text on terminals that support it |
| 2285 | bold_on= |
| 2286 | bold_off= |
| 2287 | if test -t 1; then |
| 2288 | if test -n "`tput bold 2>/dev/null`" \ |
| 2289 | && test -n "`tput sgr0 2>/dev/null`" |
| 2290 | then |
| 2291 | bold_on=`tput bold` |
| 2292 | bold_off=`tput sgr0` |
| 2293 | fi |
| 2294 | fi |
| 2295 | |
| 2296 | |
| 2297 | # func_fatal_error ARG... |
| 2298 | # ----------------------- |
| 2299 | # Echo program name prefixed message to standard error, and exit. |
| 2300 | func_fatal_error () |
| 2301 | { |
| 2302 | func_error ${1+"$@"} |
| 2303 | exit $EXIT_FAILURE |
| 2304 | } |
| 2305 | |
| 2306 | |
| 2307 | # func_internal_error ARG... |
| 2308 | # -------------------------- |
| 2309 | # Echo program name prefixed message to standard error, and exit. |
| 2310 | func_internal_error () |
| 2311 | { |
| 2312 | func_fatal_error "INTERNAL ERROR: " ${1+"$@"} " |
| 2313 | Please report this bug to \`[email protected]' |
| 2314 | in as much detail as possible." |
| 2315 | } |
| 2316 | |
| 2317 | |
| 2318 | # func_permissions_error FILE-OR-DIRECTORY |
| 2319 | # ---------------------------------------- |
| 2320 | # Echo program name prefixed permissions error message to standard |
| 2321 | # error, and exit. |
| 2322 | func_permissions_error () |
| 2323 | { |
| 2324 | $debug_cmd |
| 2325 | |
| 2326 | func_fatal_error "Error: Failed to create \`$1', check permissions." |
| 2327 | } |
| 2328 | |
| 2329 | |
| 2330 | # func_warning CATEGORY ARG... |
| 2331 | # ---------------------------- |
| 2332 | # Echo program name prefixed warning message to standard error. Warning |
| 2333 | # messages can be filtered according to CATEGORY. |
| 2334 | func_warning () |
| 2335 | { |
| 2336 | $debug_cmd |
| 2337 | |
| 2338 | case " $warning_categories " in |
| 2339 | *" $1 "*) ;; |
| 2340 | *) func_internal_error "invalid warning category \`$1'" ;; |
| 2341 | esac |
| 2342 | |
| 2343 | my_category="$1" |
| 2344 | shift |
| 2345 | |
| 2346 | case " $opt_warning " in |
| 2347 | *" $my_category "*) $warning_func ${1+"$@"} ;; |
| 2348 | esac |
| 2349 | } |
| 2350 | |
| 2351 | |
| 2352 | # func_fatal_help ARG... |
| 2353 | # ---------------------- |
| 2354 | # Echo program name prefixed message to standard error, followed by |
| 2355 | # a help hint, and exit. |
| 2356 | func_fatal_help () |
| 2357 | { |
| 2358 | $debug_cmd |
| 2359 | |
| 2360 | func_error ${1+"$@"} |
| 2361 | func_fatal_error "$fatal_help" |
| 2362 | } |
| 2363 | fatal_help="Try \`$progname --help' for more information." ## default |
| 2364 | |
| 2365 | |
| 2366 | # func_version |
| 2367 | # ------------ |
| 2368 | # Echo version message to standard output and exit. |
| 2369 | func_version () |
| 2370 | { |
| 2371 | $debug_cmd |
| 2372 | |
| 2373 | cat <<EOF |
| 2374 | $progname $scriptversion |
| 2375 | EOF |
| 2376 | $SED -n '/(C)/!b go |
| 2377 | :more |
| 2378 | /\./!{ |
| 2379 | N |
| 2380 | s|\n# | | |
| 2381 | b more |
| 2382 | } |
| 2383 | :go |
| 2384 | /^# Written by /,/# warranty; / { |
| 2385 | s|^# || |
| 2386 | s|^# *$|| |
| 2387 | s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| |
| 2388 | p |
| 2389 | } |
| 2390 | /^# Written by / { |
| 2391 | s|^# || |
| 2392 | p |
| 2393 | }' < "$progpath" |
| 2394 | |
| 2395 | exit $? |
| 2396 | } |
| 2397 | |
| 2398 | |
| 2399 | # func_usage [NOEXIT] |
| 2400 | # ------------------- |
| 2401 | # Echo short help message to standard output and exit. |
| 2402 | func_usage () |
| 2403 | { |
| 2404 | $debug_cmd |
| 2405 | |
| 2406 | echo "$progpath [OPTION]..." |
| 2407 | echo "" |
| 2408 | echo "$usage_message" |
| 2409 | |
| 2410 | my_ret=$? |
| 2411 | test -n "$1" || { |
| 2412 | echo "Run \`$progname --help | more' for full usage" |
| 2413 | exit $my_ret |
| 2414 | } |
| 2415 | } |
| 2416 | |
| 2417 | |
| 2418 | # func_help [NOEXIT] |
| 2419 | # ------------------ |
| 2420 | # Echo long help message to standard output and exit, |
| 2421 | # unless 'noexit' is passed as argument. |
| 2422 | func_help () |
| 2423 | { |
| 2424 | $debug_cmd |
| 2425 | |
| 2426 | func_usage noexit |
| 2427 | echo "$long_help_message" |
| 2428 | |
| 2429 | my_ret=$? |
| 2430 | test -n "$1" || exit $my_ret |
| 2431 | } |
| 2432 | |
| 2433 | |
| 2434 | # func_missing_arg ARGNAME |
| 2435 | # ------------------------ |
| 2436 | # Echo program name prefixed message to standard error and set global |
| 2437 | # exit_cmd. |
| 2438 | func_missing_arg () |
| 2439 | { |
| 2440 | $debug_cmd |
| 2441 | |
| 2442 | func_error "Error: Missing argument for \`$1'." |
| 2443 | exit_cmd=exit |
| 2444 | } |
| 2445 | |
| 2446 | |
| 2447 | # func_split_short_opt SHORTOPT |
| 2448 | # ----------------------------- |
| 2449 | # Set func_split_short_opt_name and func_split_short_opt_arg shell |
| 2450 | # variables after splitting SHORTOPT after the 2nd character. |
| 2451 | if (eval 'x=-abc; y=${x#??}; z=${x%$y}; test x$y$z = xbc-a') 2>/dev/null |
| 2452 | then |
| 2453 | # This is an XSI compatible shell, allowing a faster implementation... |
| 2454 | eval 'func_split_short_opt () |
| 2455 | { |
| 2456 | $debug_cmd |
| 2457 | |
| 2458 | func_split_short_opt_arg=${1#??} |
| 2459 | func_split_short_opt_name=${1%"$func_split_short_opt_arg"} |
| 2460 | }' |
| 2461 | else |
| 2462 | # ...otherwise fall back to using expr, which is often a shell builtin. |
| 2463 | func_split_short_opt () |
| 2464 | { |
| 2465 | $debug_cmd |
| 2466 | |
| 2467 | func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` |
| 2468 | func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` |
| 2469 | } |
| 2470 | fi #func_split_short_opt |
| 2471 | |
| 2472 | |
| 2473 | # func_split_equals STRING |
| 2474 | # ------------------------ |
| 2475 | # Set func_split_equals_lhs and func_split_equals_rhs shell variables after |
| 2476 | # splitting STRING at the `=' sign. |
| 2477 | if (eval 'x='--ab=cd'; y=${x#*=}; z=${x%%=*}; test x$y$z = xcd--ab') 2>/dev/null |
| 2478 | then |
| 2479 | # This is an XSI compatible shell, allowing a faster implementation... |
| 2480 | eval 'func_split_equals () |
| 2481 | { |
| 2482 | $debug_cmd |
| 2483 | |
| 2484 | func_split_equals_lhs=${1%%=*} |
| 2485 | func_split_equals_rhs=${1#*=} |
| 2486 | test "x$func_split_equals_lhs" = "x$1" \ |
| 2487 | && func_split_equals_rhs="" |
| 2488 | }' |
| 2489 | else |
| 2490 | # ...otherwise fall back to using expr, which is often a shell builtin. |
| 2491 | func_split_equals () |
| 2492 | { |
| 2493 | $debug_cmd |
| 2494 | |
| 2495 | func_split_equals_lhs=`expr "x$1" : 'x\([^=]*)'` |
| 2496 | func_split_equals_rhs="" |
| 2497 | test "x$func_split_equals_lhs" = "x$1" \ |
| 2498 | || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` |
| 2499 | } |
| 2500 | fi #func_split_equals |
| 2501 | |
| 2502 | |
| 2503 | # func_quote_for_eval ARG... |
| 2504 | # -------------------------- |
| 2505 | # Aesthetically quote ARGs to be evaled later. |
| 2506 | # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT |
| 2507 | # is double-quoted, suitable for a subsequent eval, whereas |
| 2508 | # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters |
| 2509 | # which are still active within double quotes backslashified. |
| 2510 | sed_quote_subst='s|\([`"$\\]\)|\\\1|g' |
| 2511 | func_quote_for_eval () |
| 2512 | { |
| 2513 | $debug_cmd |
| 2514 | |
| 2515 | func_quote_for_eval_result= |
| 2516 | |
| 2517 | while test $# -gt 0; do |
| 2518 | case $1 in |
| 2519 | *[\\\`\"\$]*) |
| 2520 | my_unquoted_arg=`printf "$1" | $SED "$sed_quote_subst"` ;; |
| 2521 | *) |
| 2522 | my_unquoted_arg="$1" ;; |
| 2523 | esac |
| 2524 | |
| 2525 | case $my_unquoted_arg in |
| 2526 | # Double-quote args containing shell metacharacters to delay |
| 2527 | # word splitting, command substitution and variable expansion |
| 2528 | # for a subsequent eval. |
| 2529 | # Many Bourne shells cannot handle close brackets correctly |
| 2530 | # in scan sets, so we specify it separately. |
| 2531 | *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") |
| 2532 | my_quoted_arg="\"$my_unquoted_arg\"" |
| 2533 | ;; |
| 2534 | *) |
| 2535 | my_quoted_arg="$my_unquoted_arg" ;; |
| 2536 | esac |
| 2537 | test -n "$func_quote_for_eval_result" \ |
| 2538 | && func_append func_quote_for_eval_result " " |
| 2539 | func_append func_quote_for_eval_result "$my_quoted_arg" |
| 2540 | shift |
| 2541 | done |
| 2542 | } |
| 2543 | |
| 2544 | |
| 2545 | # func_show_eval CMD [FAIL_EXP] |
| 2546 | # ----------------------------- |
| 2547 | # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is |
| 2548 | # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP |
| 2549 | # is given, then evaluate it. |
| 2550 | func_show_eval () |
| 2551 | { |
| 2552 | $debug_cmd |
| 2553 | |
| 2554 | my_cmd="$1" |
| 2555 | my_fail_exp="${2-:}" |
| 2556 | |
| 2557 | ${opt_silent-false} || { |
| 2558 | func_quote_for_eval $my_cmd |
| 2559 | eval func_truncate_cmd $func_quote_for_eval_result |
| 2560 | func_echo "running: $func_truncate_cmd_result" |
| 2561 | } |
| 2562 | |
| 2563 | if ${opt_dry_run-false}; then :; else |
| 2564 | eval "$my_cmd" |
| 2565 | my_status=$? |
| 2566 | if test "$my_status" -eq 0; then :; else |
| 2567 | eval "(exit $my_status); $my_fail_exp" |
| 2568 | fi |
| 2569 | fi |
| 2570 | } |
| 2571 | |
| 2572 | |
| 2573 | # func_truncate_cmd CMD [ARG]... |
| 2574 | # ------------------------------ |
| 2575 | # For unreasonably long commands (such as a gnulib-tool invocation with |
| 2576 | # the full module list for import), truncate CMD after the second non- |
| 2577 | # option ARG. |
| 2578 | func_truncate_cmd () |
| 2579 | { |
| 2580 | $debug_cmd |
| 2581 | |
| 2582 | my_last_arg_opt_p=false |
| 2583 | func_truncate_cmd_result= |
| 2584 | |
| 2585 | set dummy "$@"; shift |
| 2586 | |
| 2587 | while test $# -gt 0; do |
| 2588 | my_opt="$1"; shift |
| 2589 | |
| 2590 | test -n "$func_truncate_cmd_result" \ |
| 2591 | && func_append func_truncate_cmd_result ' ' |
| 2592 | func_append func_truncate_cmd_result "$my_opt" |
| 2593 | |
| 2594 | func_len "x$func_truncate_cmd_result" |
| 2595 | |
| 2596 | case $my_opt in |
| 2597 | -*) my_last_arg_opt_p=: ;; |
| 2598 | *) $my_last_arg_opt_p \ |
| 2599 | || test $min_cmd_len -gt $func_len_result \ |
| 2600 | || break |
| 2601 | my_last_arg_opt_p=false |
| 2602 | ;; |
| 2603 | esac |
| 2604 | done |
| 2605 | |
| 2606 | test $# -gt 0 && func_append func_truncate_cmd_result "..." |
| 2607 | } |
| 2608 | |
| 2609 | |
| 2610 | # func_extract_trace MACRO_NAME [FILENAME]... |
| 2611 | # ------------------------------------------- |
| 2612 | # set `$func_extract_trace_result' to a colon delimited list of |
| 2613 | # arguments to MACRO_NAME in FILENAME. If no FILENAME is not given, |
| 2614 | # then `configure.ac' is assumed. |
| 2615 | func_extract_trace () |
| 2616 | { |
| 2617 | $debug_cmd |
| 2618 | |
| 2619 | $require_configure_ac |
| 2620 | $require_gnu_m4 |
| 2621 | |
| 2622 | my_macro="$1"; shift |
| 2623 | test $# -gt 0 || { |
| 2624 | set dummy $configure_ac |
| 2625 | shift |
| 2626 | } |
| 2627 | |
| 2628 | # Generate an error if the first file is missing |
| 2629 | <"$1" |
| 2630 | |
| 2631 | # Sadly, we can't use `autom4te' tracing to extract macro |
| 2632 | # arguments, because it complains about things we want to |
| 2633 | # ignore at bootstrap time - like missing m4_include files; |
| 2634 | # AC_PREREQ being newer than the installed autoconf; and |
| 2635 | # returns nothing when tracing `AM_INIT_AUTOMAKE' when |
| 2636 | # aclocal hasn't been generated yet. |
| 2637 | # |
| 2638 | # The following tries to emulate a less persnickety version |
| 2639 | # of (and due to not having to wait for Perl startup on |
| 2640 | # every invocation, it's probably faster too): |
| 2641 | # |
| 2642 | # autom4te --language=Autoconf --trace=$my_macro:\$% "$@" |
| 2643 | # |
| 2644 | # First we give a minimal set of macro declarations to M4 |
| 2645 | # to prime it for reading Autoconf macros, while still |
| 2646 | # providing some of the functionality generally used at |
| 2647 | # m4-time to supply dynamic arguments to Autocof functions, |
| 2648 | # but without following `m4_s?include' files. |
| 2649 | # |
| 2650 | # We discard M4's stdout, but the M4 trace output from reading |
| 2651 | # our "autoconf.mini" followed by any other files passed to |
| 2652 | # this function is then scanned by sed to transform it into |
| 2653 | # a colon delimited argument list assigned to a shell variable. |
| 2654 | # |
| 2655 | # Finally, we `eval' the sed generated assignment to get |
| 2656 | # the result back into this script for further use by callers |
| 2657 | # of this function. |
| 2658 | |
| 2659 | func_extract_trace_result= |
| 2660 | eval `echo ' |
| 2661 | # Initialisation. |
| 2662 | m4_changequote([,]) |
| 2663 | m4_define([m4_copy], [m4_define([$2], m4_defn([$1]))]) |
| 2664 | m4_define([m4_rename], [m4_copy([$1], [$2])m4_undefine([$1])]) |
| 2665 | |
| 2666 | # Disable these macros. |
| 2667 | m4_undefine([m4_dnl]) |
| 2668 | m4_undefine([m4_include]) |
| 2669 | m4_undefine([m4_m4exit]) |
| 2670 | m4_undefine([m4_m4wrap]) |
| 2671 | m4_undefine([m4_maketemp]) |
| 2672 | |
| 2673 | # Copy and rename macros not handled by "m4 --prefix". |
| 2674 | m4_define([dnl], [m4_builtin([dnl])]) |
| 2675 | m4_copy([m4_define], [m4_defun]) |
| 2676 | m4_rename([m4_ifelse], [m4_if]) |
| 2677 | m4_ifdef([m4_mkstemp], [m4_undefine([m4_mkstemp])]) |
| 2678 | m4_rename([m4_patsubst], [m4_bpatsubst]) |
| 2679 | m4_rename([m4_regexp], [m4_bregexp]) |
| 2680 | |
| 2681 | # "m4sugar.mini" - useful m4-time macros for dynamic arguments. |
| 2682 | # If we discover packages that need more m4 macros defined in |
| 2683 | # order to bootstrap correctly, add them here: |
| 2684 | m4_define([m4_bmatch], |
| 2685 | [m4_if([$#], 0, [], [$#], 1, [], [$#], 2, [$2], |
| 2686 | [m4_if(m4_bregexp([$1], [$2]), -1, |
| 2687 | [$0([$1], m4_shift3($@))], [$3])])]) |
| 2688 | m4_define([m4_ifndef], [m4_ifdef([$1], [$3], [$2])]) |
| 2689 | m4_define([m4_ifset], |
| 2690 | [m4_ifdef([$1], [m4_ifval(m4_defn([$1]), [$2], [$3])], [$3])]) |
| 2691 | m4_define([m4_require], [$1]) |
| 2692 | m4_define([m4_shift3], [m4_shift(m4shift(m4shift($@)))]) |
| 2693 | |
| 2694 | # "autoconf.mini" - things from autoconf macros we care about. |
| 2695 | m4_copy([m4_defun], [AC_DEFUN]) |
| 2696 | |
| 2697 | # Dummy definition for the macro we want to trace. |
| 2698 | # AM_INIT_AUTOMAKE at least produces no trace without this. |
| 2699 | AC_DEFUN(['"$my_macro"'])' \ |
| 2700 | |$M4 -daq --prefix --trace="$my_macro" - "$@" 2>&1 1>/dev/null \ |
| 2701 | |$SED -n 's|#.*$|| |
| 2702 | /^m4trace: -1- '"$my_macro"'/ { |
| 2703 | s|^m4trace: -1- '"$my_macro"'[([]*|func_extract_trace_result='\''| |
| 2704 | s|], [[]|:|g |
| 2705 | s|[])]*$|:'\''| |
| 2706 | s|[^'\'']$|\&'\''| |
| 2707 | p |
| 2708 | }'` |
| 2709 | |
| 2710 | # Leave the ':' sentinel in place for successfully traced macros |
| 2711 | # without arguments, otherwise remove it so that the results of |
| 2712 | # single-argument macros can be used without additional parsing. |
| 2713 | test : = "$func_extract_trace_result" \ |
| 2714 | || func_extract_trace_result=`echo "$func_extract_trace_result" |$SED 's|:$||'` |
| 2715 | } |
| 2716 | |
| 2717 | |
| 2718 | # func_insert_sorted_if_absent STR FILE... |
| 2719 | # ---------------------------------------- |
| 2720 | # If $STR is not already on a line by itself in $FILE, insert it, |
| 2721 | # sorting the new contents of the file and replacing $FILE with the result. |
| 2722 | func_insert_sorted_if_absent () |
| 2723 | { |
| 2724 | $debug_cmd |
| 2725 | |
| 2726 | str=$1 |
| 2727 | shift |
| 2728 | |
| 2729 | for file |
| 2730 | do |
| 2731 | test -f $file || touch $file |
| 2732 | |
| 2733 | func_grep_q "$str" "$file" \ |
| 2734 | && func_verbose "inserting \`$str' into \`$file'" |
| 2735 | |
| 2736 | echo "$str" | sort -u - $file | func_cmp_s - $file \ |
| 2737 | || echo "$str" | sort -u - $file -o $file \ |
| 2738 | || func_permissions_error "$file" |
| 2739 | done |
| 2740 | } |
| 2741 | |
| 2742 | |
| 2743 | # func_sort_ver VER1 VER2 |
| 2744 | # ----------------------- |
| 2745 | # Note this deviates from the version comparison in automake |
| 2746 | # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a |
| 2747 | # but this should suffice as we won't be specifying old |
| 2748 | # version formats or redundant trailing .0 in bootstrap.conf. |
| 2749 | # If we did want full compatibility then we should probably |
| 2750 | # use m4_version_compare from autoconf. |
| 2751 | func_sort_ver () # sort -V is not generally available |
| 2752 | { |
| 2753 | $debug_cmd |
| 2754 | |
| 2755 | ver1="$1" |
| 2756 | ver2="$2" |
| 2757 | |
| 2758 | # split on '.' and compare each component |
| 2759 | i=1 |
| 2760 | while : ; do |
| 2761 | p1=`echo "$ver1" | cut -d. -f$i` |
| 2762 | p2=`echo "$ver2" | cut -d. -f$i` |
| 2763 | if test ! "$p1"; then |
| 2764 | echo "$1 $2" |
| 2765 | break |
| 2766 | elif test ! "$p2"; then |
| 2767 | echo "$2 $1" |
| 2768 | break |
| 2769 | elif test ! "$p1" = "$p2"; then |
| 2770 | if test "$p1" -gt "$p2" 2>/dev/null; then # numeric comparison |
| 2771 | echo "$2 $1" |
| 2772 | elif test "$p2" -gt "$p1" 2>/dev/null; then # numeric comparison |
| 2773 | echo "$1 $2" |
| 2774 | else # numeric, then lexicographic comparison |
| 2775 | lp=`printf "$p1\n$p2\n" | sort -n | tail -n1` |
| 2776 | if test "$lp" = "$p2"; then |
| 2777 | echo "$1 $2" |
| 2778 | else |
| 2779 | echo "$2 $1" |
| 2780 | fi |
| 2781 | fi |
| 2782 | break |
| 2783 | fi |
| 2784 | i=`expr $i + 1` |
| 2785 | done |
| 2786 | } |
| 2787 | |
| 2788 | |
| 2789 | # func_get_version APP |
| 2790 | # -------------------- |
| 2791 | # echo the version number (if any) of APP, which is looked up along your |
| 2792 | # PATH. |
| 2793 | func_get_version () |
| 2794 | { |
| 2795 | $debug_cmd |
| 2796 | |
| 2797 | app=$1 |
| 2798 | |
| 2799 | { $app --version || $app --version </dev/null; } >/dev/null 2>&1 \ |
| 2800 | || return 1 |
| 2801 | |
| 2802 | $app --version 2>&1 | |
| 2803 | $SED -n '# extract version within line |
| 2804 | s|.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1| |
| 2805 | t done |
| 2806 | |
| 2807 | # extract version at start of line |
| 2808 | s|^\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1| |
| 2809 | t done |
| 2810 | |
| 2811 | d |
| 2812 | |
| 2813 | :done |
| 2814 | #the following essentially does s|5.005|5.5| |
| 2815 | s|\.0*\([1-9]\)|.\1|g |
| 2816 | p |
| 2817 | q' |
| 2818 | } |
| 2819 | |
| 2820 | |
| 2821 | # func_check_versions APP1 VER1 URL1 ...[APPN VERN URLN] |
| 2822 | # ------------------------------------------------------ |
| 2823 | func_check_versions () |
| 2824 | { |
| 2825 | $debug_cmd |
| 2826 | |
| 2827 | func_check_versions_result=: |
| 2828 | |
| 2829 | while test $# -gt 0; do |
| 2830 | my_app="$1"; shift |
| 2831 | my_reqver="$1"; shift |
| 2832 | my_url="$1"; shift |
| 2833 | |
| 2834 | # Honor $APP variables ($TAR, $AUTOCONF, etc.) |
| 2835 | my_appvar=`echo $my_app | tr '[a-z]' '[A-Z]'` |
| 2836 | test "$my_appvar" = TAR && my_appvar=AMTAR |
| 2837 | eval "my_app=\${$my_appvar-$my_app}" |
| 2838 | my_instver=`func_get_version $my_app` |
| 2839 | |
| 2840 | test ! "$my_instver" \ |
| 2841 | || func_verbose "found \`$my_app' version $my_instver" |
| 2842 | |
| 2843 | # Fail if --version didn't work. |
| 2844 | if test ! "$my_instver"; then |
| 2845 | func_error "Error: \`$my_app' not found" |
| 2846 | func_check_versions_result=false |
| 2847 | |
| 2848 | # Fail if a new version than what we have is required. |
| 2849 | elif test ! "$my_reqver" = "-"; then |
| 2850 | my_newer=`func_sort_ver $my_reqver $my_instver | cut -d' ' -f2` |
| 2851 | test ! "$my_newer" = "$my_instver" && { |
| 2852 | func_error "\ |
| 2853 | Error: \`$my_app' version == $my_instver is too old |
| 2854 | \`$my_app' version >= $my_reqver is required" |
| 2855 | func_check_versions_result=false |
| 2856 | } |
| 2857 | fi |
| 2858 | done |
| 2859 | } |
| 2860 | |
| 2861 | |
| 2862 | # func_cleanup_gnulib |
| 2863 | # ------------------- |
| 2864 | # Recursively delete everything below the path in the global variable |
| 2865 | # GNULIB_PATH. |
| 2866 | func_cleanup_gnulib () |
| 2867 | { |
| 2868 | $debug_cmd |
| 2869 | |
| 2870 | status=$? |
| 2871 | $RM -fr "$gnulib_path" |
| 2872 | exit $status |
| 2873 | } |
| 2874 | |
| 2875 | |
| 2876 | # func_symlink_to_dir SRCDIR FILENAME [DEST_FILENAME] |
| 2877 | # --------------------------------------------------- |
| 2878 | # Make a symlink from FILENAME in SRCDIR to the current directory, |
| 2879 | # optionally calling the symlink DEST_FILENAME. |
| 2880 | func_symlink_to_dir () |
| 2881 | { |
| 2882 | $debug_cmd |
| 2883 | |
| 2884 | $require_vc_ignore_files |
| 2885 | |
| 2886 | src=$1/$2 |
| 2887 | dst=${3-$2} |
| 2888 | |
| 2889 | test -f "$src" && { |
| 2890 | |
| 2891 | # If the destination directory doesn't exist, create it. |
| 2892 | # This is required at least for "lib/uniwidth/cjk.h". |
| 2893 | dst_dir=`dirname "$dst"` |
| 2894 | if ! test -d "$dst_dir"; then |
| 2895 | mkdir -p "$dst_dir" |
| 2896 | |
| 2897 | # If we've just created a directory like lib/uniwidth, |
| 2898 | # tell version control system(s) it's ignorable. |
| 2899 | # FIXME: for now, this does only one level |
| 2900 | parent=`dirname "$dst_dir"` |
| 2901 | for dot_ig in x $vc_ignore_files; do |
| 2902 | test $dot_ig = x && continue |
| 2903 | ig=$parent/$dot_ig |
| 2904 | func_insert_sorted_if_absent `echo "$dst_dir" |$SED 's|.*/||'` $ig |
| 2905 | done |
| 2906 | fi |
| 2907 | |
| 2908 | if $opt_copy; then |
| 2909 | { |
| 2910 | test ! -h "$dst" \ |
| 2911 | || func_show_eval "$RM -f '$dst'" |
| 2912 | } \ |
| 2913 | && test -f "$dst" \ |
| 2914 | && func_cmp_s "$src" "$dst" \ |
| 2915 | && func_echo "copying file \`$src'" \ |
| 2916 | && cp -fp "$src" "$dst" |
| 2917 | else |
| 2918 | test -h "$dst" \ |
| 2919 | && src_ls=`ls -diL "$src" 2>/dev/null` \ |
| 2920 | && set $src_ls && src_i=$1 \ |
| 2921 | && dst_ls=`ls -diL "$dst" 2>/dev/null` \ |
| 2922 | && set $dst_ls && dst_i=$1 \ |
| 2923 | && test "$src_i" = "$dst_i" \ |
| 2924 | || { |
| 2925 | dot_dots= |
| 2926 | case $src in |
| 2927 | /*) ;; |
| 2928 | *) |
| 2929 | case /$dst/ in |
| 2930 | *//* | */../* | */./* | /*/*/*/*/*/) |
| 2931 | func_fatal_error "\ |
| 2932 | Error: Invalid symlink calculation: $src -> $dst" |
| 2933 | ;; |
| 2934 | /*/*/*/*/) dot_dots=../../../;; |
| 2935 | /*/*/*/) dot_dots=../../;; |
| 2936 | /*/*/) dot_dots=../;; |
| 2937 | esac |
| 2938 | ;; |
| 2939 | esac |
| 2940 | |
| 2941 | func_echo "linking file \`$src'" |
| 2942 | ln -fs "$dot_dots$src" "$dst" |
| 2943 | } |
| 2944 | fi |
| 2945 | } |
| 2946 | } |
| 2947 | |
| 2948 | |
| 2949 | # func_download_po_files SUBDIR DOMAIN |
| 2950 | # ------------------------------------ |
| 2951 | func_download_po_files () |
| 2952 | { |
| 2953 | $debug_cmd |
| 2954 | |
| 2955 | func_echo "getting translations into $1 for $2..." |
| 2956 | cmd=`printf "$po_download_command_format" "$2" "$1"` |
| 2957 | eval "$cmd" |
| 2958 | } |
| 2959 | |
| 2960 | |
| 2961 | # func_find_tool ENVVAR NAMES... |
| 2962 | # ------------------------------ |
| 2963 | # Search for a required program. Use the value of ENVVAR, if set, |
| 2964 | # otherwise find the first of the NAMES that can be run (i.e., |
| 2965 | # supports --version). If found, set ENVVAR to the program name, |
| 2966 | # die otherwise. |
| 2967 | func_find_tool () |
| 2968 | { |
| 2969 | $debug_cmd |
| 2970 | |
| 2971 | find_tool_envvar=$1 |
| 2972 | shift |
| 2973 | find_tool_names=$@ |
| 2974 | eval "find_tool_res=\$$find_tool_envvar" |
| 2975 | if test x"$find_tool_res" = x; then |
| 2976 | for i |
| 2977 | do |
| 2978 | if ($i --version </dev/null) >/dev/null 2>&1; then |
| 2979 | find_tool_res=$i |
| 2980 | break |
| 2981 | fi |
| 2982 | done |
| 2983 | else |
| 2984 | find_tool_error_prefix="\$$find_tool_envvar: " |
| 2985 | fi |
| 2986 | test x"$find_tool_res" = x && func_fatal_error "\ |
| 2987 | Error: One of these is required: |
| 2988 | $find_tool_names" |
| 2989 | |
| 2990 | ($find_tool_res --version </dev/null) >/dev/null 2>&1 \ |
| 2991 | || func_fatal_error "\ |
| 2992 | Error: ${find_tool_error_prefix}Cannot run \`$find_tool_res --version'" |
| 2993 | |
| 2994 | eval "$find_tool_envvar=\$find_tool_res" |
| 2995 | eval "export $find_tool_envvar" |
| 2996 | } |
| 2997 | |
| 2998 | |
| 2999 | # func_update_po_files PO_DIR DOMAIN |
| 3000 | # ---------------------------------- |
| 3001 | # Mirror .po files to $po_dir/.reference and copy only the new |
| 3002 | # or modified ones into $po_dir. Also update $po_dir/LINGUAS. |
| 3003 | # Note po files that exist locally only are left in $po_dir but will |
| 3004 | # not be included in LINGUAS and hence will not be distributed. |
| 3005 | func_update_po_files () |
| 3006 | { |
| 3007 | $debug_cmd |
| 3008 | |
| 3009 | # Directory containing primary .po files. |
| 3010 | # Overwrite them only when we're sure a .po file is new. |
| 3011 | po_dir=$1 |
| 3012 | domain=$2 |
| 3013 | |
| 3014 | # Mirror *.po files into this dir. |
| 3015 | # Usually contains *.s1 checksum files. |
| 3016 | ref_po_dir="$po_dir/.reference" |
| 3017 | |
| 3018 | test -d $ref_po_dir || mkdir $ref_po_dir || return |
| 3019 | func_download_po_files $ref_po_dir $domain \ |
| 3020 | && ls "$ref_po_dir"/*.po 2>/dev/null | |
| 3021 | $SED 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return |
| 3022 | |
| 3023 | # Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6. |
| 3024 | func_find_tool SHA1SUM sha1sum gsha1sum shasum |
| 3025 | |
| 3026 | langs=`cd $ref_po_dir && echo *.po|$SED 's|\.po||g'` |
| 3027 | test "$langs" = '*' && langs=x |
| 3028 | for po in $langs; do |
| 3029 | case $po in x) continue;; esac |
| 3030 | new_po="$ref_po_dir/$po.po" |
| 3031 | cksum_file="$ref_po_dir/$po.s1" |
| 3032 | if ! test -f "$cksum_file" || |
| 3033 | ! test -f "$po_dir/$po.po" || |
| 3034 | ! $SHA1SUM -c --status "$cksum_file" \ |
| 3035 | < "$new_po" > /dev/null; then |
| 3036 | echo "updated $po_dir/$po.po..." |
| 3037 | cp "$new_po" "$po_dir/$po.po" \ |
| 3038 | && $SHA1SUM < "$new_po" > "$cksum_file" |
| 3039 | fi |
| 3040 | done |
| 3041 | } |
| 3042 | |
| 3043 | |
| 3044 | |
| 3045 | ## ----------------- ## |
| 3046 | ## Global variables. ## |
| 3047 | ## ----------------- ## |
| 3048 | |
| 3049 | EXIT_SUCCESS=0 |
| 3050 | EXIT_FAILURE=1 |
| 3051 | EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. |
| 3052 | EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. |
| 3053 | |
| 3054 | exit_status=$EXIT_SUCCESS |
| 3055 | |
| 3056 | # Allow overriding, eg to get a function call trace: |
| 3057 | # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash bootstrap |
| 3058 | debug_cmd="${debug_cmd-:}" |
| 3059 | exit_cmd=: |
| 3060 | |
| 3061 | dirname='s|/[^/]*$||' |
| 3062 | basename='s|^.*/||' |
| 3063 | |
| 3064 | nl=' |
| 3065 | ' |
| 3066 | |
| 3067 | # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh |
| 3068 | # is ksh but when the shell is invoked as "sh" and the current value of |
| 3069 | # the _XPG environment variable is not equal to 1 (one), the special |
| 3070 | # positional parameter $0, within a function call, is the name of the |
| 3071 | # function. |
| 3072 | progpath="$0" |
| 3073 | |
| 3074 | # The name of this program: |
| 3075 | progname=`echo "$progpath" |$SED "$basename"` |
| 3076 | |
| 3077 | ## -------------------------------------------------- ## |
| 3078 | ## Source package customisations in `bootstrap.conf'. ## |
| 3079 | ## -------------------------------------------------- ## |
| 3080 | |
| 3081 | # Override the default configuration, if necessary. |
| 3082 | # Make sure that bootstrap.conf is sourced from the current directory |
| 3083 | # if we were invoked as "sh bootstrap". |
| 3084 | case "$0" in |
| 3085 | */*) test -r "$0.conf" && . "$0.conf" ;; |
| 3086 | *) test -r "$0.conf" && . ./"$0.conf" ;; |
| 3087 | esac |
| 3088 | |
| 3089 | |
| 3090 | ## ------------------------------- ## |
| 3091 | ## Actually perform the bootstrap. ## |
| 3092 | ## ------------------------------- ## |
| 3093 | |
| 3094 | func_bootstrap ${1+"$@"} |
| 3095 | |
| 3096 | # The End. |
| 3097 | exit $exit_status |
| 3098 | |
| 3099 | # Local variables: |
| 3100 | # mode: shell-script |
| 3101 | # sh-indentation: 2 |
| 3102 | # eval: (add-hook 'write-file-hooks 'time-stamp) |
| 3103 | # time-stamp-start: "scriptversion=" |
| 3104 | # time-stamp-format: "%:y-%02m-%02d.%02H" |
| 3105 | # time-stamp-time-zone: "UTC" |
| 3106 | # time-stamp-end: "; # UTC" |
| 3107 | # End: |