1#! /bin/sh 2## DO NOT EDIT - This file generated from build-aux/bootstrap.in 3## by inline-source v2014-01-03.01 4 5# Bootstrap an Autotooled package from checked-out sources. 6# Written by Gary V. Vaughan, 2010 7 8# Copyright (C) 2010-2015 Free Software Foundation, Inc. 9# This is free software; see the source for copying conditions. There is NO 10# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 12# This program is free software: you can redistribute it and/or modify 13# it under the terms of the GNU General Public License as published by 14# the Free Software Foundation, either version 3 of the License, or 15# (at your option) any later version. 16 17# This program is distributed in the hope that it will be useful, 18# but WITHOUT ANY WARRANTY; without even the implied warranty of 19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20# GNU General Public License for more details. 21 22# You should have received a copy of the GNU General Public License 23# along with this program. If not, see <http://www.gnu.org/licenses/>. 24 25# Originally written by Paul Eggert. The canonical version of this 26# script is maintained as build-aux/bootstrap in gnulib, however, to 27# be useful to your project, you should place a copy of it under 28# version control in the top-level directory of your project. The 29# intent is that all customization can be done with a bootstrap.conf 30# file also maintained in your version control; gnulib comes with a 31# template build-aux/bootstrap.conf to get you started. 32 33# Please report bugs or propose patches to bug-gnulib@gnu.org. 34 35 36## ------ ## 37## Usage. ## 38## ------ ## 39 40# Most GNUish projects do not keep all of the generated Autotool 41# files under version control, but running all of the right tools 42# with the right arguments, in the correct order to regenerate 43# all of those files in readiness for configuration and building 44# can be surprisingly involved! Many projects have a 'bootstrap' 45# script under version control to invoke Autotools and perform 46# other assorted book-keeping with version numbers and the like. 47# 48# This bootstrap script aims to probe the configure.ac and top 49# Makefile.am of your project to automatically determine what 50# the correct ordering and arguments are and then run the tools for 51# you. In order to use it, you can generate an initial standalone 52# script with: 53# 54# gl/build-aux/inline-source gl/build-aux/bootstrap.in > bootstrap 55# 56# You should then store than script in version control for other 57# developers in you project. It will give you instructions about 58# how to keep it up to date if the sources change. 59# 60# See gl/doc/bootstrap.texi for documentation on how to write 61# a bootstrap.conf to customize it for your project's 62# idiosyncracies. 63 64 65## ================================================================== ## 66## ## 67## DO NOT EDIT THIS FILE, CUSTOMIZE IT USING A BOOTSTRAP.CONF ## 68## ## 69## ================================================================== ## 70 71## ------------------------------- ## 72## User overridable command paths. ## 73## ------------------------------- ## 74 75# All uppercase denotes values stored in the environment. These 76# variables should generally be overridden by the user - however, we do 77# set them to 'true' in some parts of this script to prevent them being 78# called at the wrong time by other tools that we call ('autoreconf', 79# for example). 80# 81# We also allow 'LIBTOOLIZE', 'M4', 'SHA1SUM' and some others to be 82# overridden, and export the result for child processes, but they are 83# handled by the function 'func_find_tool' and not defaulted in this 84# section. 85 86: ${ACLOCAL="aclocal"} 87: ${AUTOCONF="autoconf"} 88: ${AUTOHEADER="autoheader"} 89: ${AUTOM4TE="autom4te"} 90: ${AUTOHEADER="autoheader"} 91: ${AUTOMAKE="automake"} 92: ${AUTOPOINT="autopoint"} 93: ${AUTORECONF="autoreconf"} 94: ${CMP="cmp"} 95: ${CONFIG_SHELL="/bin/sh"} 96: ${DIFF="diff"} 97: ${GIT="git"} 98: ${LN_S="ln -s"} 99: ${RM="rm"} 100 101export ACLOCAL 102export AUTOCONF 103export AUTOHEADER 104export AUTOM4TE 105export AUTOHEADER 106export AUTOMAKE 107export AUTOPOINT 108export AUTORECONF 109export CONFIG_SHELL 110 111 112: ${LUAROCKS="luarocks"} 113 114export LUAROCKS 115 116 117## -------------- ## 118## Configuration. ## 119## -------------- ## 120 121# A newline delimited list of triples of programs (that respond to 122# --version), the minimum version numbers required (or just '-' in the 123# version field if any version will be sufficient) and homepage URLs 124# to help locate missing packages. 125buildreq= 126 127# Name of a file containing instructions on installing missing packages 128# required in 'buildreq'. 129buildreq_readme=README-hacking 130 131# These are extracted from AC_INIT in configure.ac, though you can 132# override those values in 'bootstrap.conf' if you prefer. 133build_aux= 134macro_dir= 135package= 136package_name= 137package_version= 138package_bugreport= 139 140# These are extracted from 'gnulib-cache.m4', or else fall-back 141# automatically on the gnulib defaults; unless you set the values 142# manually in 'bootstrap.conf'. 143doc_base= 144gnulib_mk= 145gnulib_name= 146local_gl_dir= 147source_base= 148tests_base= 149 150# The list of gnulib modules required at 'gnulib-tool' time. If you 151# check 'gnulib-cache.m4' into your repository, then this list will be 152# extracted automatically. 153gnulib_modules= 154 155# Extra gnulib files that are not in modules, which override files of 156# the same name installed by other bootstrap tools. 157gnulib_non_module_files=" 158 build-aux/compile 159 build-aux/install-sh 160 build-aux/mdate-sh 161 build-aux/texinfo.tex 162 build-aux/depcomp 163 build-aux/config.guess 164 build-aux/config.sub 165 doc/INSTALL 166" 167 168# Relative path to the local gnulib submodule, and url to the upstream 169# git repository. If you have a gnulib entry in your .gitmodules file, 170# these values are ignored. 171gnulib_path= 172gnulib_url= 173 174# Additional gnulib-tool options to use. 175gnulib_tool_options=" 176 --no-changelog 177" 178 179# bootstrap removes any macro-files that are not included by aclocal.m4, 180# except for files listed in this variable that are always kept. 181gnulib_precious=" 182 gnulib-tool.m4 183" 184 185# When truncating long commands for display, always allow at least this 186# many characters before truncating. 187min_cmd_len=160 188 189# The command to download all .po files for a specified domain into 190# a specified directory. Fill in the first %s is the domain name, and 191# the second with the destination directory. Use rsync's -L and -r 192# options because the latest/%s directory and the .po files within are 193# all symlinks. 194po_download_command_format=\ 195"rsync --delete --exclude '*.s1' -Lrtvz \ 196'translationproject.org::tp/latest/%s/' '%s'" 197 198# Other locale categories that need message catalogs. 199extra_locale_categories= 200 201# Additional xgettext options to use. Gnulib might provide you with an 202# extensive list of additional options to append to this, but gettext 203# 0.16.1 and newer appends them automaticaly, so you can safely ignore 204# the complaints from 'gnulib-tool' if your $configure_ac states: 205# 206# AM_GNU_GETTEXT_VERSION([0.16.1]) 207xgettext_options=" 208 --flag=_:1:pass-c-format 209 --flag=N_:1:pass-c-format 210" 211 212# Package copyright holder for gettext files. Defaults to FSF if unset. 213copyright_holder= 214 215# File that should exist in the top directory of a checked out hierarchy, 216# but not in a distribution tarball. 217checkout_only_file= 218 219# Whether to use copies instead of symlinks by default (if set to true, 220# the --copy option has no effect). 221copy=false 222 223# Set this to ".cvsignore .gitignore" in 'bootstrap.conf' if you want 224# those files to be generated in directories like 'lib/', 'm4/', and 'po/', 225# or set it to "auto" to make this script select what to use based 226# on what version control system (if any) is used in the source directory. 227# Or set it to "none" to ignore VCS ignore files entirely. Default is 228# "auto". 229vc_ignore= 230 231 232# List of slingshot files to link into stdlib tree before autotooling. 233slingshot_files=$slingshot_files 234 235# Relative path to the local slingshot submodule, and url to the upsream 236# git repository. If you have a slingshot entry in your .gitmodules file, 237# these values are ignored. 238slingshot_path=$slingshot_path 239slingshot_url=$slingshot_url 240 241# NOTE: slingshot bootstrap will check rockspecs listed in $buildreq, 242# according to the URL part of a specification triple ending in 243# `.rockspec`. 244 245 246## ------------------- ## 247## External Libraries. ## 248## ------------------- ## 249 250# Source required external libraries: 251# Set a version string for this script. 252scriptversion=2014-01-03.01; # UTC 253 254# General shell script boiler plate, and helper functions. 255# Written by Gary V. Vaughan, 2004 256 257# Copyright (C) 2004-2014 Free Software Foundation, Inc. 258# This is free software; see the source for copying conditions. There is NO 259# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 260 261# This program is free software; you can redistribute it and/or modify 262# it under the terms of the GNU General Public License as published by 263# the Free Software Foundation; either version 3 of the License, or 264# (at your option) any later version. 265 266# As a special exception to the GNU General Public License, if you distribute 267# this file as part of a program or library that is built using GNU Libtool, 268# you may include this file under the same distribution terms that you use 269# for the rest of that program. 270 271# This program is distributed in the hope that it will be useful, 272# but WITHOUT ANY WARRANTY; without even the implied warranty of 273# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 274# General Public License for more details. 275 276# You should have received a copy of the GNU General Public License 277# along with this program. If not, see <http://www.gnu.org/licenses/>. 278 279# Please report bugs or propose patches to gary@gnu.org. 280 281 282## ------ ## 283## Usage. ## 284## ------ ## 285 286# Evaluate this file near the top of your script to gain access to 287# the functions and variables defined here: 288# 289# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 290# 291# If you need to override any of the default environment variable 292# settings, do that before evaluating this file. 293 294 295## -------------------- ## 296## Shell normalisation. ## 297## -------------------- ## 298 299# Some shells need a little help to be as Bourne compatible as possible. 300# Before doing anything else, make sure all that help has been provided! 301 302DUALCASE=1; export DUALCASE # for MKS sh 303if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 304 emulate sh 305 NULLCMD=: 306 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 307 # is contrary to our usage. Disable this feature. 308 alias -g '${1+"$@"}'='"$@"' 309 setopt NO_GLOB_SUBST 310else 311 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 312fi 313 314# NLS nuisances: We save the old values in case they are required later. 315_G_user_locale= 316_G_safe_locale= 317for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 318do 319 eval "if test set = \"\${$_G_var+set}\"; then 320 save_$_G_var=\$$_G_var 321 $_G_var=C 322 export $_G_var 323 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 324 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 325 fi" 326done 327 328# CDPATH. 329(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 330 331# Make sure IFS has a sensible default 332sp=' ' 333nl=' 334' 335IFS="$sp $nl" 336 337# There are apparently some retarded systems that use ';' as a PATH separator! 338if test "${PATH_SEPARATOR+set}" != set; then 339 PATH_SEPARATOR=: 340 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 341 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 342 PATH_SEPARATOR=';' 343 } 344fi 345 346 347 348## ------------------------- ## 349## Locate command utilities. ## 350## ------------------------- ## 351 352 353# func_executable_p FILE 354# ---------------------- 355# Check that FILE is an executable regular file. 356func_executable_p () 357{ 358 test -f "$1" && test -x "$1" 359} 360 361 362# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 363# -------------------------------------------- 364# Search for either a program that responds to --version with output 365# containing "GNU", or else returned by CHECK_FUNC otherwise, by 366# trying all the directories in PATH with each of the elements of 367# PROGS_LIST. 368# 369# CHECK_FUNC should accept the path to a candidate program, and 370# set $func_check_prog_result if it truncates its output less than 371# $_G_path_prog_max characters. 372func_path_progs () 373{ 374 _G_progs_list=$1 375 _G_check_func=$2 376 _G_PATH=${3-"$PATH"} 377 378 _G_path_prog_max=0 379 _G_path_prog_found=false 380 _G_save_IFS=$IFS; IFS=$PATH_SEPARATOR 381 for _G_dir in $_G_PATH; do 382 IFS=$_G_save_IFS 383 test -z "$_G_dir" && _G_dir=. 384 for _G_prog_name in $_G_progs_list; do 385 for _exeext in '' .EXE; do 386 _G_path_prog=$_G_dir/$_G_prog_name$_exeext 387 func_executable_p "$_G_path_prog" || continue 388 case `"$_G_path_prog" --version 2>&1` in 389 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 390 *) $_G_check_func $_G_path_prog 391 func_path_progs_result=$func_check_prog_result 392 ;; 393 esac 394 $_G_path_prog_found && break 3 395 done 396 done 397 done 398 IFS=$_G_save_IFS 399 test -z "$func_path_progs_result" && { 400 echo "no acceptable sed could be found in \$PATH" >&2 401 exit 1 402 } 403} 404 405 406# We want to be able to use the functions in this file before configure 407# has figured out where the best binaries are kept, which means we have 408# to search for them ourselves - except when the results are already set 409# where we skip the searches. 410 411# Unless the user overrides by setting SED, search the path for either GNU 412# sed, or the sed that truncates its output the least. 413test -z "$SED" && { 414 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 415 for _G_i in 1 2 3 4 5 6 7; do 416 _G_sed_script=$_G_sed_script$nl$_G_sed_script 417 done 418 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 419 _G_sed_script= 420 421 func_check_prog_sed () 422 { 423 _G_path_prog=$1 424 425 _G_count=0 426 printf 0123456789 >conftest.in 427 while : 428 do 429 cat conftest.in conftest.in >conftest.tmp 430 mv conftest.tmp conftest.in 431 cp conftest.in conftest.nl 432 echo '' >> conftest.nl 433 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 434 diff conftest.out conftest.nl >/dev/null 2>&1 || break 435 _G_count=`expr $_G_count + 1` 436 if test "$_G_count" -gt "$_G_path_prog_max"; then 437 # Best one so far, save it but keep looking for a better one 438 func_check_prog_result=$_G_path_prog 439 _G_path_prog_max=$_G_count 440 fi 441 # 10*(2^10) chars as input seems more than enough 442 test 10 -lt "$_G_count" && break 443 done 444 rm -f conftest.in conftest.tmp conftest.nl conftest.out 445 } 446 447 func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 448 rm -f conftest.sed 449 SED=$func_path_progs_result 450} 451 452 453# Unless the user overrides by setting GREP, search the path for either GNU 454# grep, or the grep that truncates its output the least. 455test -z "$GREP" && { 456 func_check_prog_grep () 457 { 458 _G_path_prog=$1 459 460 _G_count=0 461 _G_path_prog_max=0 462 printf 0123456789 >conftest.in 463 while : 464 do 465 cat conftest.in conftest.in >conftest.tmp 466 mv conftest.tmp conftest.in 467 cp conftest.in conftest.nl 468 echo 'GREP' >> conftest.nl 469 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 470 diff conftest.out conftest.nl >/dev/null 2>&1 || break 471 _G_count=`expr $_G_count + 1` 472 if test "$_G_count" -gt "$_G_path_prog_max"; then 473 # Best one so far, save it but keep looking for a better one 474 func_check_prog_result=$_G_path_prog 475 _G_path_prog_max=$_G_count 476 fi 477 # 10*(2^10) chars as input seems more than enough 478 test 10 -lt "$_G_count" && break 479 done 480 rm -f conftest.in conftest.tmp conftest.nl conftest.out 481 } 482 483 func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 484 GREP=$func_path_progs_result 485} 486 487 488## ------------------------------- ## 489## User overridable command paths. ## 490## ------------------------------- ## 491 492# All uppercase variable names are used for environment variables. These 493# variables can be overridden by the user before calling a script that 494# uses them if a suitable command of that name is not already available 495# in the command search PATH. 496 497: ${CP="cp -f"} 498: ${ECHO="printf %s\n"} 499: ${EGREP="$GREP -E"} 500: ${FGREP="$GREP -F"} 501: ${LN_S="ln -s"} 502: ${MAKE="make"} 503: ${MKDIR="mkdir"} 504: ${MV="mv -f"} 505: ${RM="rm -f"} 506: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 507 508 509## -------------------- ## 510## Useful sed snippets. ## 511## -------------------- ## 512 513sed_dirname='s|/[^/]*$||' 514sed_basename='s|^.*/||' 515 516# Sed substitution that helps us do robust quoting. It backslashifies 517# metacharacters that are still active within double-quoted strings. 518sed_quote_subst='s|\([`"$\\]\)|\\\1|g' 519 520# Same as above, but do not quote variable references. 521sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 522 523# Sed substitution that turns a string into a regex matching for the 524# string literally. 525sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 526 527# Sed substitution that converts a w32 file name or path 528# that contains forward slashes, into one that contains 529# (escaped) backslashes. A very naive implementation. 530sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 531 532# Re-'\' parameter expansions in output of sed_double_quote_subst that 533# were '\'-ed in input to the same. If an odd number of '\' preceded a 534# '$' in input to sed_double_quote_subst, that '$' was protected from 535# expansion. Since each input '\' is now two '\'s, look for any number 536# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 537_G_bs='\\' 538_G_bs2='\\\\' 539_G_bs4='\\\\\\\\' 540_G_dollar='\$' 541sed_double_backslash="\ 542 s/$_G_bs4/&\\ 543/g 544 s/^$_G_bs2$_G_dollar/$_G_bs&/ 545 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 546 s/\n//g" 547 548 549## ----------------- ## 550## Global variables. ## 551## ----------------- ## 552 553# Except for the global variables explicitly listed below, the following 554# functions in the '^func_' namespace, and the '^require_' namespace 555# variables initialised in the 'Resource management' section, sourcing 556# this file will not pollute your global namespace with anything 557# else. There's no portable way to scope variables in Bourne shell 558# though, so actually running these functions will sometimes place 559# results into a variable named after the function, and often use 560# temporary variables in the '^_G_' namespace. If you are careful to 561# avoid using those namespaces casually in your sourcing script, things 562# should continue to work as you expect. And, of course, you can freely 563# overwrite any of the functions or variables defined here before 564# calling anything to customize them. 565 566EXIT_SUCCESS=0 567EXIT_FAILURE=1 568EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 569EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 570 571# Allow overriding, eg assuming that you follow the convention of 572# putting '$debug_cmd' at the start of all your functions, you can get 573# bash to show function call trace with: 574# 575# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 576debug_cmd=${debug_cmd-":"} 577exit_cmd=: 578 579# By convention, finish your script with: 580# 581# exit $exit_status 582# 583# so that you can set exit_status to non-zero if you want to indicate 584# something went wrong during execution without actually bailing out at 585# the point of failure. 586exit_status=$EXIT_SUCCESS 587 588# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 589# is ksh but when the shell is invoked as "sh" and the current value of 590# the _XPG environment variable is not equal to 1 (one), the special 591# positional parameter $0, within a function call, is the name of the 592# function. 593progpath=$0 594 595# The name of this program. 596progname=`$ECHO "$progpath" |$SED "$sed_basename"` 597 598# Make sure we have an absolute progpath for reexecution: 599case $progpath in 600 [\\/]*|[A-Za-z]:\\*) ;; 601 *[\\/]*) 602 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 603 progdir=`cd "$progdir" && pwd` 604 progpath=$progdir/$progname 605 ;; 606 *) 607 _G_IFS=$IFS 608 IFS=${PATH_SEPARATOR-:} 609 for progdir in $PATH; do 610 IFS=$_G_IFS 611 test -x "$progdir/$progname" && break 612 done 613 IFS=$_G_IFS 614 test -n "$progdir" || progdir=`pwd` 615 progpath=$progdir/$progname 616 ;; 617esac 618 619 620## ----------------- ## 621## Standard options. ## 622## ----------------- ## 623 624# The following options affect the operation of the functions defined 625# below, and should be set appropriately depending on run-time para- 626# meters passed on the command line. 627 628opt_dry_run=false 629opt_quiet=false 630opt_verbose=false 631 632# Categories 'all' and 'none' are always available. Append any others 633# you will pass as the first argument to func_warning from your own 634# code. 635warning_categories= 636 637# By default, display warnings according to 'opt_warning_types'. Set 638# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 639# treat the next displayed warning as a fatal error. 640warning_func=func_warn_and_continue 641 642# Set to 'all' to display all warnings, 'none' to suppress all 643# warnings, or a space delimited list of some subset of 644# 'warning_categories' to display only the listed warnings. 645opt_warning_types=all 646 647 648## -------------------- ## 649## Resource management. ## 650## -------------------- ## 651 652# This section contains definitions for functions that each ensure a 653# particular resource (a file, or a non-empty configuration variable for 654# example) is available, and if appropriate to extract default values 655# from pertinent package files. Call them using their associated 656# 'require_*' variable to ensure that they are executed, at most, once. 657# 658# It's entirely deliberate that calling these functions can set 659# variables that don't obey the namespace limitations obeyed by the rest 660# of this file, in order that that they be as useful as possible to 661# callers. 662 663 664# require_term_colors 665# ------------------- 666# Allow display of bold text on terminals that support it. 667require_term_colors=func_require_term_colors 668func_require_term_colors () 669{ 670 $debug_cmd 671 672 test -t 1 && { 673 # COLORTERM and USE_ANSI_COLORS environment variables take 674 # precedence, because most terminfo databases neglect to describe 675 # whether color sequences are supported. 676 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 677 678 if test 1 = "$USE_ANSI_COLORS"; then 679 # Standard ANSI escape sequences 680 tc_reset='[0m' 681 tc_bold='[1m'; tc_standout='[7m' 682 tc_red='[31m'; tc_green='[32m' 683 tc_blue='[34m'; tc_cyan='[36m' 684 else 685 # Otherwise trust the terminfo database after all. 686 test -n "`tput sgr0 2>/dev/null`" && { 687 tc_reset=`tput sgr0` 688 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 689 tc_standout=$tc_bold 690 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 691 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 692 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 693 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 694 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 695 } 696 fi 697 } 698 699 require_term_colors=: 700} 701 702 703# require_rockspecs_req 704# --------------------- 705# Remove rockspecs from $buildreq, and add them to $rockspecs_req. 706require_rockspecs_req=slingshot_require_rockspecs_req 707slingshot_require_rockspecs_req () 708{ 709 $debug_cmd 710 711 test -n "$rockspecs_req" || { 712 _G_non_rockspecs= 713 714 set dummy $buildreq; shift 715 716 while test $# -gt 2; do 717 case $3 in 718 *.rockspec) 719 func_append rockspecs_req " $1 $2 $3" 720 ;; 721 [a-z]*://*) 722 func_append _G_non_rockspecs " $1 $2 $3" 723 ;; 724 *) func_fatal_error "\ 725'$3' from the buildreq table in 726'bootstrap.conf' does not look like the URL for downloading 727$1. Please ensure that buildreq is a strict newline 728delimited list of triples; 'program min-version url'." 729 ;; 730 esac 731 shift; shift; shift 732 done 733 734 buildreq=$_G_non_rockspecs 735 } 736 737 require_rockspecs_req=: 738} 739 740 741# require_slingshot_dotgitmodules 742# ------------------------------- 743# Ensure we have a '.gitmodules' file, with appropriate 'slingshot' settings. 744require_slingshot_dotgitmodules=slingshot_require_slingshot_dotgitmodules 745slingshot_require_slingshot_dotgitmodules () 746{ 747 $debug_cmd 748 749 $require_git 750 751 test true = "$GIT" || { 752 # A slingshot entry in .gitmodules always takes precedence. 753 _G_path=`$GIT config --file .gitmodules submodule.slingshot.path 2>/dev/null` 754 755 test -n "$_G_path" || { 756 $require_vc_ignore_files 757 758 func_verbose "adding slingshot entries to '.gitmodules'" 759 760 test -n "$slingshot_path" || slingshot_path=slingshot 761 test -n "$slingshot_url" || slingshot_url=git://github.com/gvvaughan/slingshot.git 762 763 { 764 echo '[submodule "slingshot"]' 765 echo " path=$slingshot_path" 766 echo " url=$slingshot_url" 767 } >> .gitmodules 768 769 test -n "$vc_ignore_files" \ 770 || func_insert_if_absent ".gitmodules" $vc_ignore_files 771 } 772 } 773 774 require_slingshot_dotgitmodules=: 775} 776 777 778# require_slingshot_path 779# require_slingshot_url 780# ---------------------- 781# Ensure 'slingshot_path' and 'slingshot_url' are set. 782require_slingshot_path=slingshot_require_slingshot_dotgitmodules_parameters 783require_slingshot_url=slingshot_require_slingshot_dotgitmodules_parameters 784slingshot_require_slingshot_dotgitmodules_parameters () 785{ 786 $debug_cmd 787 788 $require_git 789 $require_slingshot_dotgitmodules 790 791 test -f .gitmodules \ 792 || func_fatal_error "Unable to update '.gitmodules' with slingshot submodule" 793 794 test true = "$GIT" || { 795 slingshot_path=`$GIT config --file=.gitmodules --get submodule.slingshot.path` 796 slingshot_url=`$GIT config --file=.gitmodules --get submodule.slingshot.url` 797 798 func_verbose "slingshot_path='$slingshot_path'" 799 func_verbose "slingshot_url='$slingshot_url'" 800 } 801 802 require_slingshot_path=: 803 require_slingshot_url=: 804} 805 806 807# require_slingshot_submodule 808# --------------------------- 809# Ensure that there is a current slingshot submodule. 810require_slingshot_submodule=slingshot_require_slingshot_submodule 811slingshot_require_slingshot_submodule () 812{ 813 $debug_cmd 814 815 $require_git 816 817 if test true = "$GIT"; then 818 func_warning recommend \ 819 "No 'git' found; imported slingshot modules may be missing." 820 else 821 $require_slingshot_dotgitmodules 822 823 if test -f .gitmodules; then 824 $require_slingshot_path 825 $require_slingshot_url 826 827 if test -f "slingshot/src/mkrockspecs.in"; then 828 : All present and correct. 829 830 else 831 trap slingshot_cleanup 1 2 13 15 832 833 shallow= 834 $GIT clone -h 2>&1 |func_grep_q -- --depth \ 835 && shallow='--depth 365' 836 837 func_show_eval "$GIT clone $shallow '$slingshot_url' '$slingshot_path'" \ 838 slingshot_cleanup 839 840 # FIXME: Solaris /bin/sh will try to execute '-' if any of 841 # these signals are caught after this. 842 trap - 1 2 13 15 843 fi 844 845 # Make sure we've checked out the correct revision of slingshot. 846 func_show_eval "$GIT submodule init -- $slingshot_path" \ 847 && func_show_eval "$GIT submodule update -- $slingshot_path" \ 848 || func_fatal_error "Unable to update slingshot submodule." 849 fi 850 fi 851 852 require_slingshot_submodule=: 853} 854 855 856# require_bootstrap_uptodate 857# -------------------------- 858# Complain if the version of bootstrap in the build-aux directory differs 859# from the one we are running. 860require_bootstrap_uptodate=slingshot_require_bootstrap_uptodate 861slingshot_require_bootstrap_uptodate () 862{ 863 $debug_cmd 864 865 $require_slingshot_submodule 866 867 _G_slingshot_bootstrap=slingshot/bootstrap 868 869 rm -f $progname.new 870 871 if test -f "$_G_slingshot_bootstrap"; then 872 if func_cmp_s "$progpath" "$_G_slingshot_bootstrap"; then 873 func_verbose "bootstrap script up to date" 874 else 875 cp -f $_G_slingshot_bootstrap $progname.new 876 func_warning upgrade "\ 877An updated slingshot bootstrap script is ready for you in 878'$progname.new'. After you've verified that you want the 879changes, you can update with: 880 mv -f $progname.new $progname 881 ./$progname 882 883Or you can disable this check permanently by adding the 884following to 'bootstrap.conf': 885 require_bootstrap_uptodate=:" 886 fi 887 else 888 func_warning upgrade "\ 889Your slingshot submodule appears to be damagedi, so I can't tell 890whether your bootstrap has gone out of sync. Please check for 891and undo any local changes, or revert to the slingshot revision 892you were using previously, and rerun this script." 893 fi 894 895 require_bootstrap_uptodate=: 896} 897 898 899# slingshot_cleanup 900# ----------------- 901# Recursively delete everything at $slingshot_path. 902slingshot_cleanup () 903{ 904 $debug_cmd 905 906 $require_slingshot_path 907 908 _G_status=$? 909 $RM -fr $slingshot_path 910 exit $_G_status 911} 912 913 914## ----------------- ## 915## Function library. ## 916## ----------------- ## 917 918# This section contains a variety of useful functions to call in your 919# scripts. Take note of the portable wrappers for features provided by 920# some modern shells, which will fall back to slower equivalents on 921# less featureful shells. 922 923 924# func_append VAR VALUE 925# --------------------- 926# Append VALUE onto the existing contents of VAR. 927 928 # We should try to minimise forks, especially on Windows where they are 929 # unreasonably slow, so skip the feature probes when bash or zsh are 930 # being used: 931 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 932 : ${_G_HAVE_ARITH_OP="yes"} 933 : ${_G_HAVE_XSI_OPS="yes"} 934 # The += operator was introduced in bash 3.1 935 case $BASH_VERSION in 936 [12].* | 3.0 | 3.0*) ;; 937 *) 938 : ${_G_HAVE_PLUSEQ_OP="yes"} 939 ;; 940 esac 941 fi 942 943 # _G_HAVE_PLUSEQ_OP 944 # Can be empty, in which case the shell is probed, "yes" if += is 945 # useable or anything else if it does not work. 946 test -z "$_G_HAVE_PLUSEQ_OP" \ 947 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 948 && _G_HAVE_PLUSEQ_OP=yes 949 950if test yes = "$_G_HAVE_PLUSEQ_OP" 951then 952 # This is an XSI compatible shell, allowing a faster implementation... 953 eval 'func_append () 954 { 955 $debug_cmd 956 957 eval "$1+=\$2" 958 }' 959else 960 # ...otherwise fall back to using expr, which is often a shell builtin. 961 func_append () 962 { 963 $debug_cmd 964 965 eval "$1=\$$1\$2" 966 } 967fi 968 969 970# func_append_quoted VAR VALUE 971# ---------------------------- 972# Quote VALUE and append to the end of shell variable VAR, separated 973# by a space. 974if test yes = "$_G_HAVE_PLUSEQ_OP"; then 975 eval 'func_append_quoted () 976 { 977 $debug_cmd 978 979 func_quote_for_eval "$2" 980 eval "$1+=\\ \$func_quote_for_eval_result" 981 }' 982else 983 func_append_quoted () 984 { 985 $debug_cmd 986 987 func_quote_for_eval "$2" 988 eval "$1=\$$1\\ \$func_quote_for_eval_result" 989 } 990fi 991 992 993# func_append_uniq VAR VALUE 994# -------------------------- 995# Append unique VALUE onto the existing contents of VAR, assuming 996# entries are delimited by the first character of VALUE. For example: 997# 998# func_append_uniq options " --another-option option-argument" 999# 1000# will only append to $options if " --another-option option-argument " 1001# is not already present somewhere in $options already (note spaces at 1002# each end implied by leading space in second argument). 1003func_append_uniq () 1004{ 1005 $debug_cmd 1006 1007 eval _G_current_value='`$ECHO $'$1'`' 1008 _G_delim=`expr "$2" : '\(.\)'` 1009 1010 case $_G_delim$_G_current_value$_G_delim in 1011 *"$2$_G_delim"*) ;; 1012 *) func_append "$@" ;; 1013 esac 1014} 1015 1016 1017# func_arith TERM... 1018# ------------------ 1019# Set func_arith_result to the result of evaluating TERMs. 1020 test -z "$_G_HAVE_ARITH_OP" \ 1021 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 1022 && _G_HAVE_ARITH_OP=yes 1023 1024if test yes = "$_G_HAVE_ARITH_OP"; then 1025 eval 'func_arith () 1026 { 1027 $debug_cmd 1028 1029 func_arith_result=$(( $* )) 1030 }' 1031else 1032 func_arith () 1033 { 1034 $debug_cmd 1035 1036 func_arith_result=`expr "$@"` 1037 } 1038fi 1039 1040 1041# func_basename FILE 1042# ------------------ 1043# Set func_basename_result to FILE with everything up to and including 1044# the last / stripped. 1045if test yes = "$_G_HAVE_XSI_OPS"; then 1046 # If this shell supports suffix pattern removal, then use it to avoid 1047 # forking. Hide the definitions single quotes in case the shell chokes 1048 # on unsupported syntax... 1049 _b='func_basename_result=${1##*/}' 1050 _d='case $1 in 1051 */*) func_dirname_result=${1%/*}$2 ;; 1052 * ) func_dirname_result=$3 ;; 1053 esac' 1054 1055else 1056 # ...otherwise fall back to using sed. 1057 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 1058 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 1059 if test "X$func_dirname_result" = "X$1"; then 1060 func_dirname_result=$3 1061 else 1062 func_append func_dirname_result "$2" 1063 fi' 1064fi 1065 1066eval 'func_basename () 1067{ 1068 $debug_cmd 1069 1070 '"$_b"' 1071}' 1072 1073 1074# func_dirname FILE APPEND NONDIR_REPLACEMENT 1075# ------------------------------------------- 1076# Compute the dirname of FILE. If nonempty, add APPEND to the result, 1077# otherwise set result to NONDIR_REPLACEMENT. 1078eval 'func_dirname () 1079{ 1080 $debug_cmd 1081 1082 '"$_d"' 1083}' 1084 1085 1086# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 1087# -------------------------------------------------------- 1088# Perform func_basename and func_dirname in a single function 1089# call: 1090# dirname: Compute the dirname of FILE. If nonempty, 1091# add APPEND to the result, otherwise set result 1092# to NONDIR_REPLACEMENT. 1093# value returned in "$func_dirname_result" 1094# basename: Compute filename of FILE. 1095# value retuned in "$func_basename_result" 1096# For efficiency, we do not delegate to the functions above but instead 1097# duplicate the functionality here. 1098eval 'func_dirname_and_basename () 1099{ 1100 $debug_cmd 1101 1102 '"$_b"' 1103 '"$_d"' 1104}' 1105 1106 1107# func_echo ARG... 1108# ---------------- 1109# Echo program name prefixed message. 1110func_echo () 1111{ 1112 $debug_cmd 1113 1114 _G_message=$* 1115 1116 func_echo_IFS=$IFS 1117 IFS=$nl 1118 for _G_line in $_G_message; do 1119 IFS=$func_echo_IFS 1120 $ECHO "$progname: $_G_line" 1121 done 1122 IFS=$func_echo_IFS 1123} 1124 1125 1126# func_echo_all ARG... 1127# -------------------- 1128# Invoke $ECHO with all args, space-separated. 1129func_echo_all () 1130{ 1131 $ECHO "$*" 1132} 1133 1134 1135# func_echo_infix_1 INFIX ARG... 1136# ------------------------------ 1137# Echo program name, followed by INFIX on the first line, with any 1138# additional lines not showing INFIX. 1139func_echo_infix_1 () 1140{ 1141 $debug_cmd 1142 1143 $require_term_colors 1144 1145 _G_infix=$1; shift 1146 _G_indent=$_G_infix 1147 _G_prefix="$progname: $_G_infix: " 1148 _G_message=$* 1149 1150 # Strip color escape sequences before counting printable length 1151 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 1152 do 1153 test -n "$_G_tc" && { 1154 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 1155 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 1156 } 1157 done 1158 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 1159 1160 func_echo_infix_1_IFS=$IFS 1161 IFS=$nl 1162 for _G_line in $_G_message; do 1163 IFS=$func_echo_infix_1_IFS 1164 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 1165 _G_prefix=$_G_indent 1166 done 1167 IFS=$func_echo_infix_1_IFS 1168} 1169 1170 1171# func_error ARG... 1172# ----------------- 1173# Echo program name prefixed message to standard error. 1174func_error () 1175{ 1176 $debug_cmd 1177 1178 $require_term_colors 1179 1180 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 1181} 1182 1183 1184# func_fatal_error ARG... 1185# ----------------------- 1186# Echo program name prefixed message to standard error, and exit. 1187func_fatal_error () 1188{ 1189 $debug_cmd 1190 1191 func_error "$*" 1192 exit $EXIT_FAILURE 1193} 1194 1195 1196# func_grep EXPRESSION FILENAME 1197# ----------------------------- 1198# Check whether EXPRESSION matches any line of FILENAME, without output. 1199func_grep () 1200{ 1201 $debug_cmd 1202 1203 $GREP "$1" "$2" >/dev/null 2>&1 1204} 1205 1206 1207# func_len STRING 1208# --------------- 1209# Set func_len_result to the length of STRING. STRING may not 1210# start with a hyphen. 1211 test -z "$_G_HAVE_XSI_OPS" \ 1212 && (eval 'x=a/b/c; 1213 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1214 && _G_HAVE_XSI_OPS=yes 1215 1216if test yes = "$_G_HAVE_XSI_OPS"; then 1217 eval 'func_len () 1218 { 1219 $debug_cmd 1220 1221 func_len_result=${#1} 1222 }' 1223else 1224 func_len () 1225 { 1226 $debug_cmd 1227 1228 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 1229 } 1230fi 1231 1232 1233# func_mkdir_p DIRECTORY-PATH 1234# --------------------------- 1235# Make sure the entire path to DIRECTORY-PATH is available. 1236func_mkdir_p () 1237{ 1238 $debug_cmd 1239 1240 _G_directory_path=$1 1241 _G_dir_list= 1242 1243 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 1244 1245 # Protect directory names starting with '-' 1246 case $_G_directory_path in 1247 -*) _G_directory_path=./$_G_directory_path ;; 1248 esac 1249 1250 # While some portion of DIR does not yet exist... 1251 while test ! -d "$_G_directory_path"; do 1252 # ...make a list in topmost first order. Use a colon delimited 1253 # list incase some portion of path contains whitespace. 1254 _G_dir_list=$_G_directory_path:$_G_dir_list 1255 1256 # If the last portion added has no slash in it, the list is done 1257 case $_G_directory_path in */*) ;; *) break ;; esac 1258 1259 # ...otherwise throw away the child directory and loop 1260 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 1261 done 1262 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 1263 1264 func_mkdir_p_IFS=$IFS; IFS=: 1265 for _G_dir in $_G_dir_list; do 1266 IFS=$func_mkdir_p_IFS 1267 # mkdir can fail with a 'File exist' error if two processes 1268 # try to create one of the directories concurrently. Don't 1269 # stop in that case! 1270 $MKDIR "$_G_dir" 2>/dev/null || : 1271 done 1272 IFS=$func_mkdir_p_IFS 1273 1274 # Bail out if we (or some other process) failed to create a directory. 1275 test -d "$_G_directory_path" || \ 1276 func_fatal_error "Failed to create '$1'" 1277 fi 1278} 1279 1280 1281# func_mktempdir [BASENAME] 1282# ------------------------- 1283# Make a temporary directory that won't clash with other running 1284# libtool processes, and avoids race conditions if possible. If 1285# given, BASENAME is the basename for that directory. 1286func_mktempdir () 1287{ 1288 $debug_cmd 1289 1290 _G_template=${TMPDIR-/tmp}/${1-$progname} 1291 1292 if test : = "$opt_dry_run"; then 1293 # Return a directory name, but don't create it in dry-run mode 1294 _G_tmpdir=$_G_template-$$ 1295 else 1296 1297 # If mktemp works, use that first and foremost 1298 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 1299 1300 if test ! -d "$_G_tmpdir"; then 1301 # Failing that, at least try and use $RANDOM to avoid a race 1302 _G_tmpdir=$_G_template-${RANDOM-0}$$ 1303 1304 func_mktempdir_umask=`umask` 1305 umask 0077 1306 $MKDIR "$_G_tmpdir" 1307 umask $func_mktempdir_umask 1308 fi 1309 1310 # If we're not in dry-run mode, bomb out on failure 1311 test -d "$_G_tmpdir" || \ 1312 func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 1313 fi 1314 1315 $ECHO "$_G_tmpdir" 1316} 1317 1318 1319# func_normal_abspath PATH 1320# ------------------------ 1321# Remove doubled-up and trailing slashes, "." path components, 1322# and cancel out any ".." path components in PATH after making 1323# it an absolute path. 1324func_normal_abspath () 1325{ 1326 $debug_cmd 1327 1328 # These SED scripts presuppose an absolute path with a trailing slash. 1329 _G_pathcar='s|^/\([^/]*\).*$|\1|' 1330 _G_pathcdr='s|^/[^/]*||' 1331 _G_removedotparts=':dotsl 1332 s|/\./|/|g 1333 t dotsl 1334 s|/\.$|/|' 1335 _G_collapseslashes='s|/\{1,\}|/|g' 1336 _G_finalslash='s|/*$|/|' 1337 1338 # Start from root dir and reassemble the path. 1339 func_normal_abspath_result= 1340 func_normal_abspath_tpath=$1 1341 func_normal_abspath_altnamespace= 1342 case $func_normal_abspath_tpath in 1343 "") 1344 # Empty path, that just means $cwd. 1345 func_stripname '' '/' "`pwd`" 1346 func_normal_abspath_result=$func_stripname_result 1347 return 1348 ;; 1349 # The next three entries are used to spot a run of precisely 1350 # two leading slashes without using negated character classes; 1351 # we take advantage of case's first-match behaviour. 1352 ///*) 1353 # Unusual form of absolute path, do nothing. 1354 ;; 1355 //*) 1356 # Not necessarily an ordinary path; POSIX reserves leading '//' 1357 # and for example Cygwin uses it to access remote file shares 1358 # over CIFS/SMB, so we conserve a leading double slash if found. 1359 func_normal_abspath_altnamespace=/ 1360 ;; 1361 /*) 1362 # Absolute path, do nothing. 1363 ;; 1364 *) 1365 # Relative path, prepend $cwd. 1366 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 1367 ;; 1368 esac 1369 1370 # Cancel out all the simple stuff to save iterations. We also want 1371 # the path to end with a slash for ease of parsing, so make sure 1372 # there is one (and only one) here. 1373 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1374 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 1375 while :; do 1376 # Processed it all yet? 1377 if test / = "$func_normal_abspath_tpath"; then 1378 # If we ascended to the root using ".." the result may be empty now. 1379 if test -z "$func_normal_abspath_result"; then 1380 func_normal_abspath_result=/ 1381 fi 1382 break 1383 fi 1384 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1385 -e "$_G_pathcar"` 1386 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1387 -e "$_G_pathcdr"` 1388 # Figure out what to do with it 1389 case $func_normal_abspath_tcomponent in 1390 "") 1391 # Trailing empty path component, ignore it. 1392 ;; 1393 ..) 1394 # Parent dir; strip last assembled component from result. 1395 func_dirname "$func_normal_abspath_result" 1396 func_normal_abspath_result=$func_dirname_result 1397 ;; 1398 *) 1399 # Actual path component, append it. 1400 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1401 ;; 1402 esac 1403 done 1404 # Restore leading double-slash if one was found on entry. 1405 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1406} 1407 1408 1409# func_notquiet ARG... 1410# -------------------- 1411# Echo program name prefixed message only when not in quiet mode. 1412func_notquiet () 1413{ 1414 $debug_cmd 1415 1416 $opt_quiet || func_echo ${1+"$@"} 1417 1418 # A bug in bash halts the script if the last line of a function 1419 # fails when set -e is in force, so we need another command to 1420 # work around that: 1421 : 1422} 1423 1424 1425# func_relative_path SRCDIR DSTDIR 1426# -------------------------------- 1427# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1428func_relative_path () 1429{ 1430 $debug_cmd 1431 1432 func_relative_path_result= 1433 func_normal_abspath "$1" 1434 func_relative_path_tlibdir=$func_normal_abspath_result 1435 func_normal_abspath "$2" 1436 func_relative_path_tbindir=$func_normal_abspath_result 1437 1438 # Ascend the tree starting from libdir 1439 while :; do 1440 # check if we have found a prefix of bindir 1441 case $func_relative_path_tbindir in 1442 $func_relative_path_tlibdir) 1443 # found an exact match 1444 func_relative_path_tcancelled= 1445 break 1446 ;; 1447 $func_relative_path_tlibdir*) 1448 # found a matching prefix 1449 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1450 func_relative_path_tcancelled=$func_stripname_result 1451 if test -z "$func_relative_path_result"; then 1452 func_relative_path_result=. 1453 fi 1454 break 1455 ;; 1456 *) 1457 func_dirname $func_relative_path_tlibdir 1458 func_relative_path_tlibdir=$func_dirname_result 1459 if test -z "$func_relative_path_tlibdir"; then 1460 # Have to descend all the way to the root! 1461 func_relative_path_result=../$func_relative_path_result 1462 func_relative_path_tcancelled=$func_relative_path_tbindir 1463 break 1464 fi 1465 func_relative_path_result=../$func_relative_path_result 1466 ;; 1467 esac 1468 done 1469 1470 # Now calculate path; take care to avoid doubling-up slashes. 1471 func_stripname '' '/' "$func_relative_path_result" 1472 func_relative_path_result=$func_stripname_result 1473 func_stripname '/' '/' "$func_relative_path_tcancelled" 1474 if test -n "$func_stripname_result"; then 1475 func_append func_relative_path_result "/$func_stripname_result" 1476 fi 1477 1478 # Normalisation. If bindir is libdir, return '.' else relative path. 1479 if test -n "$func_relative_path_result"; then 1480 func_stripname './' '' "$func_relative_path_result" 1481 func_relative_path_result=$func_stripname_result 1482 fi 1483 1484 test -n "$func_relative_path_result" || func_relative_path_result=. 1485 1486 : 1487} 1488 1489 1490# func_quote_for_eval ARG... 1491# -------------------------- 1492# Aesthetically quote ARGs to be evaled later. 1493# This function returns two values: 1494# i) func_quote_for_eval_result 1495# double-quoted, suitable for a subsequent eval 1496# ii) func_quote_for_eval_unquoted_result 1497# has all characters that are still active within double 1498# quotes backslashified. 1499func_quote_for_eval () 1500{ 1501 $debug_cmd 1502 1503 func_quote_for_eval_unquoted_result= 1504 func_quote_for_eval_result= 1505 while test 0 -lt $#; do 1506 case $1 in 1507 *[\\\`\"\$]*) 1508 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1509 *) 1510 _G_unquoted_arg=$1 ;; 1511 esac 1512 if test -n "$func_quote_for_eval_unquoted_result"; then 1513 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1514 else 1515 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1516 fi 1517 1518 case $_G_unquoted_arg in 1519 # Double-quote args containing shell metacharacters to delay 1520 # word splitting, command substitution and variable expansion 1521 # for a subsequent eval. 1522 # Many Bourne shells cannot handle close brackets correctly 1523 # in scan sets, so we specify it separately. 1524 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1525 _G_quoted_arg=\"$_G_unquoted_arg\" 1526 ;; 1527 *) 1528 _G_quoted_arg=$_G_unquoted_arg 1529 ;; 1530 esac 1531 1532 if test -n "$func_quote_for_eval_result"; then 1533 func_append func_quote_for_eval_result " $_G_quoted_arg" 1534 else 1535 func_append func_quote_for_eval_result "$_G_quoted_arg" 1536 fi 1537 shift 1538 done 1539} 1540 1541 1542# func_quote_for_expand ARG 1543# ------------------------- 1544# Aesthetically quote ARG to be evaled later; same as above, 1545# but do not quote variable references. 1546func_quote_for_expand () 1547{ 1548 $debug_cmd 1549 1550 case $1 in 1551 *[\\\`\"]*) 1552 _G_arg=`$ECHO "$1" | $SED \ 1553 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1554 *) 1555 _G_arg=$1 ;; 1556 esac 1557 1558 case $_G_arg in 1559 # Double-quote args containing shell metacharacters to delay 1560 # word splitting and command substitution for a subsequent eval. 1561 # Many Bourne shells cannot handle close brackets correctly 1562 # in scan sets, so we specify it separately. 1563 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1564 _G_arg=\"$_G_arg\" 1565 ;; 1566 esac 1567 1568 func_quote_for_expand_result=$_G_arg 1569} 1570 1571 1572# func_stripname PREFIX SUFFIX NAME 1573# --------------------------------- 1574# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1575# PREFIX and SUFFIX must not contain globbing or regex special 1576# characters, hashes, percent signs, but SUFFIX may contain a leading 1577# dot (in which case that matches only a dot). 1578if test yes = "$_G_HAVE_XSI_OPS"; then 1579 eval 'func_stripname () 1580 { 1581 $debug_cmd 1582 1583 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1584 # positional parameters, so assign one to ordinary variable first. 1585 func_stripname_result=$3 1586 func_stripname_result=${func_stripname_result#"$1"} 1587 func_stripname_result=${func_stripname_result%"$2"} 1588 }' 1589else 1590 func_stripname () 1591 { 1592 $debug_cmd 1593 1594 case $2 in 1595 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1596 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1597 esac 1598 } 1599fi 1600 1601 1602# func_show_eval CMD [FAIL_EXP] 1603# ----------------------------- 1604# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1605# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1606# is given, then evaluate it. 1607func_show_eval () 1608{ 1609 $debug_cmd 1610 1611 _G_cmd=$1 1612 _G_fail_exp=${2-':'} 1613 1614 func_quote_for_expand "$_G_cmd" 1615 eval "func_notquiet $func_quote_for_expand_result" 1616 1617 $opt_dry_run || { 1618 eval "$_G_cmd" 1619 _G_status=$? 1620 if test 0 -ne "$_G_status"; then 1621 eval "(exit $_G_status); $_G_fail_exp" 1622 fi 1623 } 1624} 1625 1626 1627# func_show_eval_locale CMD [FAIL_EXP] 1628# ------------------------------------ 1629# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1630# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1631# is given, then evaluate it. Use the saved locale for evaluation. 1632func_show_eval_locale () 1633{ 1634 $debug_cmd 1635 1636 _G_cmd=$1 1637 _G_fail_exp=${2-':'} 1638 1639 $opt_quiet || { 1640 func_quote_for_expand "$_G_cmd" 1641 eval "func_echo $func_quote_for_expand_result" 1642 } 1643 1644 $opt_dry_run || { 1645 eval "$_G_user_locale 1646 $_G_cmd" 1647 _G_status=$? 1648 eval "$_G_safe_locale" 1649 if test 0 -ne "$_G_status"; then 1650 eval "(exit $_G_status); $_G_fail_exp" 1651 fi 1652 } 1653} 1654 1655 1656# func_tr_sh 1657# ---------- 1658# Turn $1 into a string suitable for a shell variable name. 1659# Result is stored in $func_tr_sh_result. All characters 1660# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1661# if $1 begins with a digit, a '_' is prepended as well. 1662func_tr_sh () 1663{ 1664 $debug_cmd 1665 1666 case $1 in 1667 [0-9]* | *[!a-zA-Z0-9_]*) 1668 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1669 ;; 1670 * ) 1671 func_tr_sh_result=$1 1672 ;; 1673 esac 1674} 1675 1676 1677# func_verbose ARG... 1678# ------------------- 1679# Echo program name prefixed message in verbose mode only. 1680func_verbose () 1681{ 1682 $debug_cmd 1683 1684 $opt_verbose && func_echo "$*" 1685 1686 : 1687} 1688 1689 1690# func_warn_and_continue ARG... 1691# ----------------------------- 1692# Echo program name prefixed warning message to standard error. 1693func_warn_and_continue () 1694{ 1695 $debug_cmd 1696 1697 $require_term_colors 1698 1699 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1700} 1701 1702 1703# func_warning CATEGORY ARG... 1704# ---------------------------- 1705# Echo program name prefixed warning message to standard error. Warning 1706# messages can be filtered according to CATEGORY, where this function 1707# elides messages where CATEGORY is not listed in the global variable 1708# 'opt_warning_types'. 1709func_warning () 1710{ 1711 $debug_cmd 1712 1713 # CATEGORY must be in the warning_categories list! 1714 case " $warning_categories " in 1715 *" $1 "*) ;; 1716 *) func_internal_error "invalid warning category '$1'" ;; 1717 esac 1718 1719 _G_category=$1 1720 shift 1721 1722 case " $opt_warning_types " in 1723 *" $_G_category "*) $warning_func ${1+"$@"} ;; 1724 esac 1725} 1726 1727 1728# func_sort_ver VER1 VER2 1729# ----------------------- 1730# 'sort -V' is not generally available. 1731# Note this deviates from the version comparison in automake 1732# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1733# but this should suffice as we won't be specifying old 1734# version formats or redundant trailing .0 in bootstrap.conf. 1735# If we did want full compatibility then we should probably 1736# use m4_version_compare from autoconf. 1737func_sort_ver () 1738{ 1739 $debug_cmd 1740 1741 printf '%s\n%s\n' "$1" "$2" \ 1742 | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n 1743} 1744 1745# func_lt_ver PREV CURR 1746# --------------------- 1747# Return true if PREV and CURR are in the correct order according to 1748# func_sort_ver, otherwise false. Use it like this: 1749# 1750# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1751func_lt_ver () 1752{ 1753 $debug_cmd 1754 1755 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1756} 1757 1758 1759# Local variables: 1760# mode: shell-script 1761# sh-indentation: 2 1762# eval: (add-hook 'before-save-hook 'time-stamp) 1763# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1764# time-stamp-time-zone: "UTC" 1765# End: 1766#! /bin/sh 1767 1768# Set a version string for this script. 1769scriptversion=2014-01-07.03; # UTC 1770 1771# A portable, pluggable option parser for Bourne shell. 1772# Written by Gary V. Vaughan, 2010 1773 1774# Copyright (C) 2010-2014 Free Software Foundation, Inc. 1775# This is free software; see the source for copying conditions. There is NO 1776# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1777 1778# This program is free software: you can redistribute it and/or modify 1779# it under the terms of the GNU General Public License as published by 1780# the Free Software Foundation, either version 3 of the License, or 1781# (at your option) any later version. 1782 1783# This program is distributed in the hope that it will be useful, 1784# but WITHOUT ANY WARRANTY; without even the implied warranty of 1785# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1786# GNU General Public License for more details. 1787 1788# You should have received a copy of the GNU General Public License 1789# along with this program. If not, see <http://www.gnu.org/licenses/>. 1790 1791# Please report bugs or propose patches to gary@gnu.org. 1792 1793 1794## ------ ## 1795## Usage. ## 1796## ------ ## 1797 1798# This file is a library for parsing options in your shell scripts along 1799# with assorted other useful supporting features that you can make use 1800# of too. 1801# 1802# For the simplest scripts you might need only: 1803# 1804# #!/bin/sh 1805# . relative/path/to/funclib.sh 1806# . relative/path/to/options-parser 1807# scriptversion=1.0 1808# func_options ${1+"$@"} 1809# eval set dummy "$func_options_result"; shift 1810# ...rest of your script... 1811# 1812# In order for the '--version' option to work, you will need to have a 1813# suitably formatted comment like the one at the top of this file 1814# starting with '# Written by ' and ending with '# warranty; '. 1815# 1816# For '-h' and '--help' to work, you will also need a one line 1817# description of your script's purpose in a comment directly above the 1818# '# Written by ' line, like the one at the top of this file. 1819# 1820# The default options also support '--debug', which will turn on shell 1821# execution tracing (see the comment above debug_cmd below for another 1822# use), and '--verbose' and the func_verbose function to allow your script 1823# to display verbose messages only when your user has specified 1824# '--verbose'. 1825# 1826# After sourcing this file, you can plug processing for additional 1827# options by amending the variables from the 'Configuration' section 1828# below, and following the instructions in the 'Option parsing' 1829# section further down. 1830 1831## -------------- ## 1832## Configuration. ## 1833## -------------- ## 1834 1835# You should override these variables in your script after sourcing this 1836# file so that they reflect the customisations you have added to the 1837# option parser. 1838 1839# The usage line for option parsing errors and the start of '-h' and 1840# '--help' output messages. You can embed shell variables for delayed 1841# expansion at the time the message is displayed, but you will need to 1842# quote other shell meta-characters carefully to prevent them being 1843# expanded when the contents are evaled. 1844usage='$progpath [OPTION]...' 1845 1846# Short help message in response to '-h' and '--help'. Add to this or 1847# override it after sourcing this library to reflect the full set of 1848# options your script accepts. 1849usage_message="\ 1850 --debug enable verbose shell tracing 1851 -W, --warnings=CATEGORY 1852 report the warnings falling in CATEGORY [all] 1853 -v, --verbose verbosely report processing 1854 --version print version information and exit 1855 -h, --help print short or long help message and exit 1856" 1857 1858# Additional text appended to 'usage_message' in response to '--help'. 1859long_help_message=" 1860Warning categories include: 1861 'all' show all warnings 1862 'none' turn off all the warnings 1863 'error' warnings are treated as fatal errors" 1864 1865# Help message printed before fatal option parsing errors. 1866fatal_help="Try '\$progname --help' for more information." 1867 1868 1869 1870## ------------------------- ## 1871## Hook function management. ## 1872## ------------------------- ## 1873 1874# This section contains functions for adding, removing, and running hooks 1875# to the main code. A hook is just a named list of of function, that can 1876# be run in order later on. 1877 1878# func_hookable FUNC_NAME 1879# ----------------------- 1880# Declare that FUNC_NAME will run hooks added with 1881# 'func_add_hook FUNC_NAME ...'. 1882func_hookable () 1883{ 1884 $debug_cmd 1885 1886 func_append hookable_fns " $1" 1887} 1888 1889 1890# func_add_hook FUNC_NAME HOOK_FUNC 1891# --------------------------------- 1892# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1893# first have been declared "hookable" by a call to 'func_hookable'. 1894func_add_hook () 1895{ 1896 $debug_cmd 1897 1898 case " $hookable_fns " in 1899 *" $1 "*) ;; 1900 *) func_fatal_error "'$1' does not accept hook functions." ;; 1901 esac 1902 1903 eval func_append ${1}_hooks '" $2"' 1904} 1905 1906 1907# func_remove_hook FUNC_NAME HOOK_FUNC 1908# ------------------------------------ 1909# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1910func_remove_hook () 1911{ 1912 $debug_cmd 1913 1914 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1915} 1916 1917 1918# func_run_hooks FUNC_NAME [ARG]... 1919# --------------------------------- 1920# Run all hook functions registered to FUNC_NAME. 1921# It is assumed that the list of hook functions contains nothing more 1922# than a whitespace-delimited list of legal shell function names, and 1923# no effort is wasted trying to catch shell meta-characters or preserve 1924# whitespace. 1925func_run_hooks () 1926{ 1927 $debug_cmd 1928 1929 case " $hookable_fns " in 1930 *" $1 "*) ;; 1931 *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1932 esac 1933 1934 eval _G_hook_fns=\$$1_hooks; shift 1935 1936 for _G_hook in $_G_hook_fns; do 1937 eval $_G_hook '"$@"' 1938 1939 # store returned options list back into positional 1940 # parameters for next 'cmd' execution. 1941 eval _G_hook_result=\$${_G_hook}_result 1942 eval set dummy "$_G_hook_result"; shift 1943 done 1944 1945 func_quote_for_eval ${1+"$@"} 1946 func_run_hooks_result=$func_quote_for_eval_result 1947} 1948 1949 1950 1951## --------------- ## 1952## Option parsing. ## 1953## --------------- ## 1954 1955# In order to add your own option parsing hooks, you must accept the 1956# full positional parameter list in your hook function, remove any 1957# options that you action, and then pass back the remaining unprocessed 1958# options in '<hooked_function_name>_result', escaped suitably for 1959# 'eval'. Like this: 1960# 1961# my_options_prep () 1962# { 1963# $debug_cmd 1964# 1965# # Extend the existing usage message. 1966# usage_message=$usage_message' 1967# -s, --silent don'\''t print informational messages 1968# ' 1969# 1970# func_quote_for_eval ${1+"$@"} 1971# my_options_prep_result=$func_quote_for_eval_result 1972# } 1973# func_add_hook func_options_prep my_options_prep 1974# 1975# 1976# my_silent_option () 1977# { 1978# $debug_cmd 1979# 1980# # Note that for efficiency, we parse as many options as we can 1981# # recognise in a loop before passing the remainder back to the 1982# # caller on the first unrecognised argument we encounter. 1983# while test $# -gt 0; do 1984# opt=$1; shift 1985# case $opt in 1986# --silent|-s) opt_silent=: ;; 1987# # Separate non-argument short options: 1988# -s*) func_split_short_opt "$_G_opt" 1989# set dummy "$func_split_short_opt_name" \ 1990# "-$func_split_short_opt_arg" ${1+"$@"} 1991# shift 1992# ;; 1993# *) set dummy "$_G_opt" "$*"; shift; break ;; 1994# esac 1995# done 1996# 1997# func_quote_for_eval ${1+"$@"} 1998# my_silent_option_result=$func_quote_for_eval_result 1999# } 2000# func_add_hook func_parse_options my_silent_option 2001# 2002# 2003# my_option_validation () 2004# { 2005# $debug_cmd 2006# 2007# $opt_silent && $opt_verbose && func_fatal_help "\ 2008# '--silent' and '--verbose' options are mutually exclusive." 2009# 2010# func_quote_for_eval ${1+"$@"} 2011# my_option_validation_result=$func_quote_for_eval_result 2012# } 2013# func_add_hook func_validate_options my_option_validation 2014# 2015# You'll alse need to manually amend $usage_message to reflect the extra 2016# options you parse. It's preferable to append if you can, so that 2017# multiple option parsing hooks can be added safely. 2018 2019 2020# func_options [ARG]... 2021# --------------------- 2022# All the functions called inside func_options are hookable. See the 2023# individual implementations for details. 2024func_hookable func_options 2025func_options () 2026{ 2027 $debug_cmd 2028 2029 func_options_prep ${1+"$@"} 2030 eval func_parse_options \ 2031 ${func_options_prep_result+"$func_options_prep_result"} 2032 eval func_validate_options \ 2033 ${func_parse_options_result+"$func_parse_options_result"} 2034 2035 eval func_run_hooks func_options \ 2036 ${func_validate_options_result+"$func_validate_options_result"} 2037 2038 # save modified positional parameters for caller 2039 func_options_result=$func_run_hooks_result 2040} 2041 2042 2043# func_options_prep [ARG]... 2044# -------------------------- 2045# All initialisations required before starting the option parse loop. 2046# Note that when calling hook functions, we pass through the list of 2047# positional parameters. If a hook function modifies that list, and 2048# needs to propogate that back to rest of this script, then the complete 2049# modified list must be put in 'func_run_hooks_result' before 2050# returning. 2051func_hookable func_options_prep 2052func_options_prep () 2053{ 2054 $debug_cmd 2055 2056 # Option defaults: 2057 opt_verbose=false 2058 opt_warning_types= 2059 2060 func_run_hooks func_options_prep ${1+"$@"} 2061 2062 # save modified positional parameters for caller 2063 func_options_prep_result=$func_run_hooks_result 2064} 2065 2066 2067# func_parse_options [ARG]... 2068# --------------------------- 2069# The main option parsing loop. 2070func_hookable func_parse_options 2071func_parse_options () 2072{ 2073 $debug_cmd 2074 2075 func_parse_options_result= 2076 2077 # this just eases exit handling 2078 while test $# -gt 0; do 2079 # Defer to hook functions for initial option parsing, so they 2080 # get priority in the event of reusing an option name. 2081 func_run_hooks func_parse_options ${1+"$@"} 2082 2083 # Adjust func_parse_options positional parameters to match 2084 eval set dummy "$func_run_hooks_result"; shift 2085 2086 # Break out of the loop if we already parsed every option. 2087 test $# -gt 0 || break 2088 2089 _G_opt=$1 2090 shift 2091 case $_G_opt in 2092 --debug|-x) debug_cmd='set -x' 2093 func_echo "enabling shell trace mode" 2094 $debug_cmd 2095 ;; 2096 2097 --no-warnings|--no-warning|--no-warn) 2098 set dummy --warnings none ${1+"$@"} 2099 shift 2100 ;; 2101 2102 --warnings|--warning|-W) 2103 test $# = 0 && func_missing_arg $_G_opt && break 2104 case " $warning_categories $1" in 2105 *" $1 "*) 2106 # trailing space prevents matching last $1 above 2107 func_append_uniq opt_warning_types " $1" 2108 ;; 2109 *all) 2110 opt_warning_types=$warning_categories 2111 ;; 2112 *none) 2113 opt_warning_types=none 2114 warning_func=: 2115 ;; 2116 *error) 2117 opt_warning_types=$warning_categories 2118 warning_func=func_fatal_error 2119 ;; 2120 *) 2121 func_fatal_error \ 2122 "unsupported warning category: '$1'" 2123 ;; 2124 esac 2125 shift 2126 ;; 2127 2128 --verbose|-v) opt_verbose=: ;; 2129 --version) func_version ;; 2130 -\?|-h) func_usage ;; 2131 --help) func_help ;; 2132 2133 # Separate optargs to long options (plugins may need this): 2134 --*=*) func_split_equals "$_G_opt" 2135 set dummy "$func_split_equals_lhs" \ 2136 "$func_split_equals_rhs" ${1+"$@"} 2137 shift 2138 ;; 2139 2140 # Separate optargs to short options: 2141 -W*) 2142 func_split_short_opt "$_G_opt" 2143 set dummy "$func_split_short_opt_name" \ 2144 "$func_split_short_opt_arg" ${1+"$@"} 2145 shift 2146 ;; 2147 2148 # Separate non-argument short options: 2149 -\?*|-h*|-v*|-x*) 2150 func_split_short_opt "$_G_opt" 2151 set dummy "$func_split_short_opt_name" \ 2152 "-$func_split_short_opt_arg" ${1+"$@"} 2153 shift 2154 ;; 2155 2156 --) break ;; 2157 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 2158 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2159 esac 2160 done 2161 2162 # save modified positional parameters for caller 2163 func_quote_for_eval ${1+"$@"} 2164 func_parse_options_result=$func_quote_for_eval_result 2165} 2166 2167 2168# func_validate_options [ARG]... 2169# ------------------------------ 2170# Perform any sanity checks on option settings and/or unconsumed 2171# arguments. 2172func_hookable func_validate_options 2173func_validate_options () 2174{ 2175 $debug_cmd 2176 2177 # Display all warnings if -W was not given. 2178 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 2179 2180 func_run_hooks func_validate_options ${1+"$@"} 2181 2182 # Bail if the options were screwed! 2183 $exit_cmd $EXIT_FAILURE 2184 2185 # save modified positional parameters for caller 2186 func_validate_options_result=$func_run_hooks_result 2187} 2188 2189 2190 2191 2192# slingshot_options_prep 2193# ---------------------- 2194# Preparation for additional slingshot option parsing. 2195slingshot_options_prep () 2196{ 2197 $debug_cmd 2198 2199 # Option defaults: 2200 opt_skip_rock_checks=false 2201 # opt_luarocks_tree default in *unset*! 2202 2203 # Extend the existing usage message. 2204 usage_message=$usage_message' 2205Slingshot Options: 2206 2207 --luarocks-tree=DIR 2208 check a non-default tree for prerequisite rocks 2209 --skip-rock-checks 2210 ignore Lua rocks in bootstrap.conf:buildreq' 2211 2212 func_quote_for_eval ${1+"$@"} 2213 slingshot_options_prep_result=$func_quote_for_eval_result 2214} 2215func_add_hook func_options_prep slingshot_options_prep 2216 2217 2218# slingshot_parse_options OPT... 2219# ------------------------------ 2220# Called at the end of each main option parse loop to process any 2221# additional slingshot options. 2222slingshot_parse_options () 2223{ 2224 $debug_cmd 2225 2226 # Perform our own loop to consume as many options as possible in 2227 # each iteration. 2228 while test $# -gt 0; do 2229 _G_opt=$1 2230 shift 2231 case $_G_opt in 2232 --luarocks-tree) 2233 test $# = 0 && func_missing_arg $_G_opt && break 2234 opt_luarocks_tree=$1 2235 shift 2236 ;; 2237 2238 --skip-rock-checks) 2239 opt_skip_rock_checks=: 2240 ;; 2241 2242 # Separate optargs to long options (plugins may need this): 2243 --*=*) func_split_equals "$_G_opt" 2244 set dummy "$func_split_equals_lhs" \ 2245 "$func_split_equals_rhs" ${1+"$@"} 2246 shift 2247 ;; 2248 2249 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2250 esac 2251 done 2252 2253 # save modified positional parameters for caller 2254 func_quote_for_eval ${1+"$@"} 2255 slingshot_parse_options_result=$func_quote_for_eval_result 2256} 2257func_add_hook func_parse_options slingshot_parse_options 2258 2259 2260# slingshot_option_validation 2261# --------------------------- 2262# Flag any inconsistencies in users' selection of slingshot options. 2263slingshot_option_validation () 2264{ 2265 $debug_cmd 2266 2267 test -z "$opt_luarocks_tree" \ 2268 || test -d "$opt_luarocks_tree" \ 2269 || func_fatal_help "$opt_luarocks_tree: not a directory" 2270} 2271func_add_hook func_validate_options slingshot_option_validation 2272 2273 2274## ----------------- ## 2275## Helper functions. ## 2276## ----------------- ## 2277 2278# This section contains the helper functions used by the rest of the 2279# hookable option parser framework in ascii-betical order. 2280 2281 2282# func_fatal_help ARG... 2283# ---------------------- 2284# Echo program name prefixed message to standard error, followed by 2285# a help hint, and exit. 2286func_fatal_help () 2287{ 2288 $debug_cmd 2289 2290 eval \$ECHO \""Usage: $usage"\" 2291 eval \$ECHO \""$fatal_help"\" 2292 func_error ${1+"$@"} 2293 exit $EXIT_FAILURE 2294} 2295 2296 2297# func_help 2298# --------- 2299# Echo long help message to standard output and exit. 2300func_help () 2301{ 2302 $debug_cmd 2303 2304 func_usage_message 2305 $ECHO "$long_help_message" 2306 exit 0 2307} 2308 2309 2310# func_missing_arg ARGNAME 2311# ------------------------ 2312# Echo program name prefixed message to standard error and set global 2313# exit_cmd. 2314func_missing_arg () 2315{ 2316 $debug_cmd 2317 2318 func_error "Missing argument for '$1'." 2319 exit_cmd=exit 2320} 2321 2322 2323# func_split_equals STRING 2324# ------------------------ 2325# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 2326# splitting STRING at the '=' sign. 2327test -z "$_G_HAVE_XSI_OPS" \ 2328 && (eval 'x=a/b/c; 2329 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 2330 && _G_HAVE_XSI_OPS=yes 2331 2332if test yes = "$_G_HAVE_XSI_OPS" 2333then 2334 # This is an XSI compatible shell, allowing a faster implementation... 2335 eval 'func_split_equals () 2336 { 2337 $debug_cmd 2338 2339 func_split_equals_lhs=${1%%=*} 2340 func_split_equals_rhs=${1#*=} 2341 test "x$func_split_equals_lhs" = "x$1" \ 2342 && func_split_equals_rhs= 2343 }' 2344else 2345 # ...otherwise fall back to using expr, which is often a shell builtin. 2346 func_split_equals () 2347 { 2348 $debug_cmd 2349 2350 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 2351 func_split_equals_rhs= 2352 test "x$func_split_equals_lhs" = "x$1" \ 2353 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 2354 } 2355fi #func_split_equals 2356 2357 2358# func_split_short_opt SHORTOPT 2359# ----------------------------- 2360# Set func_split_short_opt_name and func_split_short_opt_arg shell 2361# variables after splitting SHORTOPT after the 2nd character. 2362if test yes = "$_G_HAVE_XSI_OPS" 2363then 2364 # This is an XSI compatible shell, allowing a faster implementation... 2365 eval 'func_split_short_opt () 2366 { 2367 $debug_cmd 2368 2369 func_split_short_opt_arg=${1#??} 2370 func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 2371 }' 2372else 2373 # ...otherwise fall back to using expr, which is often a shell builtin. 2374 func_split_short_opt () 2375 { 2376 $debug_cmd 2377 2378 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 2379 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 2380 } 2381fi #func_split_short_opt 2382 2383 2384# func_usage 2385# ---------- 2386# Echo short help message to standard output and exit. 2387func_usage () 2388{ 2389 $debug_cmd 2390 2391 func_usage_message 2392 $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 2393 exit 0 2394} 2395 2396 2397# func_usage_message 2398# ------------------ 2399# Echo short help message to standard output. 2400func_usage_message () 2401{ 2402 $debug_cmd 2403 2404 eval \$ECHO \""Usage: $usage"\" 2405 echo 2406 $SED -n 's|^# || 2407 /^Written by/{ 2408 x;p;x 2409 } 2410 h 2411 /^Written by/q' < "$progpath" 2412 echo 2413 eval \$ECHO \""$usage_message"\" 2414} 2415 2416 2417# func_version 2418# ------------ 2419# Echo version message to standard output and exit. 2420func_version () 2421{ 2422 $debug_cmd 2423 2424 printf '%s\n' "$progname $scriptversion" 2425 $SED -n ' 2426 /(C)/!b go 2427 :more 2428 /\./!{ 2429 N 2430 s|\n# | | 2431 b more 2432 } 2433 :go 2434 /^# Written by /,/# warranty; / { 2435 s|^# || 2436 s|^# *$|| 2437 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2438 p 2439 } 2440 /^# Written by / { 2441 s|^# || 2442 p 2443 } 2444 /^warranty; /q' < "$progpath" 2445 2446 exit $? 2447} 2448 2449 2450# Local variables: 2451# mode: shell-script 2452# sh-indentation: 2 2453# eval: (add-hook 'before-save-hook 'time-stamp) 2454# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 2455# time-stamp-time-zone: "UTC" 2456# End: 2457#! /bin/sh 2458 2459# Extract macro arguments from autotools input with GNU M4. 2460# Written by Gary V. Vaughan, 2010 2461# 2462# Copyright (C) 2010-2014 Free Software Foundation, Inc. 2463# This is free software; see the source for copying conditions. There is NO 2464# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 2465 2466# Make sure we've evaluated scripts we depend on. 2467test -z "$progpath" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/funclib.sh 2468test extract-trace = "$progname" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/options-parser 2469 2470# Set a version string. 2471scriptversion=2014-12-03.16; # UTC 2472 2473# This program is free software: you can redistribute it and/or modify 2474# it under the terms of the GNU General Public License as published by 2475# the Free Software Foundation, either version 3 of the License, or 2476# (at your option) any later version. 2477 2478# This program is distributed in the hope that it will be useful, 2479# but WITHOUT ANY WARRANTY; without even the implied warranty of 2480# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2481# GNU General Public License for more details. 2482 2483# You should have received a copy of the GNU General Public License 2484# along with this program. If not, see <http://www.gnu.org/licenses/>. 2485 2486# Please report bugs or propose patches to gary@gnu.org. 2487 2488 2489# slingshot_copy FILENAME SRCDIR DESTDIR 2490# -------------------------------------- 2491# If option '--copy' was specified, or soft-linking SRCFILE to DESTFILE 2492# fails, then try to copy SRCFILE to DESTFILE (making sure to update the 2493# timestamp so that a series of files with dependencies can be copied 2494# in the right order that their timestamps won't trigger rebuilds). 2495slingshot_copy () 2496{ 2497 $debug_cmd 2498 2499 slingshot_srcfile=`echo "$2/$1" |sed -e 's|/\./|/|g'` 2500 slingshot_destfile=`echo "$3/$1" |sed -e 's|/\./|/|g'` 2501 2502 $opt_force || { 2503 # Nothing to do if the files are already identical. 2504 if func_cmp_s "$slingshot_srcfile" "$slingshot_destfile"; then 2505 func_verbose "'$slingshot_destfile' is up to date." 2506 return 0 2507 fi 2508 } 2509 2510 # Require --force to remove existing $slingshot_destfile. 2511 $opt_force && $RM "$slingshot_destfile" 2512 test -f "$slingshot_destfile" && { 2513 func_warn_and_continue "'$slingshot_destfile' exists: use '--force' to overwrite" 2514 return 0 2515 } 2516 2517 # Be careful to support 'func_copy dir/target srcbase destbase'. 2518 func_dirname "$slingshot_destfile" 2519 func_mkdir_p "$func_dirname_result" 2520 2521 # Copy or link according to '--copy' option. 2522 if $opt_copy; then 2523 slingshot_copycmd=$CP 2524 slingshot_copy_type=copying 2525 else 2526 slingshot_copycmd=$LN_S 2527 slingshot_copy_type=linking 2528 2529 func_relative_path "$3" "$2" 2530 slingshot_srcfile=$func_relative_path_result/$1 2531 fi 2532 slingshot_copy_msg="$slingshot_copy_type file '$slingshot_destfile'" 2533 $opt_verbose && \ 2534 slingshot_copy_msg="$slingshot_copy_type $slingshot_srcfile $3" 2535 2536 if $opt_dry_run || { 2537 ( umask 0 2538 $slingshot_copycmd "$slingshot_srcfile" "$slingshot_destfile" 2539 ) >/dev/null 2>&1 2540 } 2541 then 2542 echo "$slingshot_copy_msg" 2543 else 2544 func_error "$slingshot_copy_type '$2/$1' to '$3/' failed" 2545 return 1 2546 fi 2547} 2548 2549 2550# slingshot_rockspec_error 2551# ------------------------ 2552# Called by zile_check_rockspecs for missing rocks. 2553slingshot_rockspec_error () 2554{ 2555 $debug_cmd 2556 2557 _G_strippedver=`expr "$_G_reqver" : '=*\(.*\)'` 2558 func_error "\ 2559Prerequisite LuaRock '$_G_rock $_G_strippedver' not found. Please install it." 2560 2561 rockspecs_uptodate_result=false 2562} 2563 2564 2565## ------ ## 2566## Usage. ## 2567## ------ ## 2568 2569# Run './extract-trace --help' for help with using this script from the 2570# command line. 2571# 2572# Or source first 'options-parser' and then this file into your own 2573# scripts in order to make use of the function and variable framework 2574# they define, and also to avoid the overhead of forking to run this 2575# script in its own process on every call. 2576 2577 2578 2579## ----------------- ## 2580## Helper functions. ## 2581## ----------------- ## 2582 2583# This section contains the helper functions used by the rest of 2584# 'extract-trace'. 2585 2586 2587# func_autoconf_configure MAYBE-CONFIGURE-FILE 2588# -------------------------------------------- 2589# Ensure that MAYBE-CONFIGURE-FILE is the name of a file in the current 2590# directory that contains an uncommented call to AC_INIT. 2591func_autoconf_configure () 2592{ 2593 $debug_cmd 2594 2595 _G_sed_no_comment=' 2596 s|#.*$|| 2597 s|^dnl .*$|| 2598 s| dnl .*$||' 2599 _G_ac_init= 2600 2601 # If we were passed a genuine file, make sure it calls AC_INIT. 2602 test -f "$1" \ 2603 && _G_ac_init=`$SED "$_G_sed_no_comment" "$1" |$GREP AC_INIT` 2604 2605 # Otherwise it is not a genuine Autoconf input file. 2606 test -n "$_G_ac_init" 2607 _G_status=$? 2608 2609 test 0 -ne "$_G_status" \ 2610 && func_verbose "'$1' not using Autoconf" 2611 2612 (exit $_G_status) 2613} 2614 2615 2616# func_tool_version_output CMD [FATAL-ERROR-MSG] 2617# ---------------------------------------------- 2618# Attempt to run 'CMD --version', discarding errors. The output can be 2619# ignored by redirecting stdout, and this function used simply to test 2620# whether the command exists and exits normally when passed a 2621# '--version' argument. 2622# When FATAL-ERROR-MSG is given, then this function will display the 2623# message and exit if running 'CMD --version' returns a non-zero exit 2624# status. 2625func_tool_version_output () 2626{ 2627 $debug_cmd 2628 2629 _G_cmd=$1 2630 _G_fatal_error_msg=$2 2631 2632 # Some tools, like 'git2cl' produce thousands of lines of output 2633 # unless stdin is /dev/null - in that case we want to return 2634 # successfully without saving all of that output. Other tools, 2635 # such as 'help2man' exit with a non-zero status when stdin comes 2636 # from /dev/null, so we re-execute without /dev/null if that 2637 # happens. This means that occasionally, the output from both calls 2638 # ends up in the result, but the alternative would be to discard the 2639 # output from one call, and hope the other produces something useful. 2640 { $_G_cmd --version </dev/null || $_G_cmd --version; } 2>/dev/null 2641 _G_status=$? 2642 2643 test 0 -ne "$_G_status" && test -n "$_G_fatal_error_msg" \ 2644 && func_fatal_error "$_G_fatal_error_msg" 2645 2646 (exit $_G_status) 2647} 2648 2649 2650# func_tool_version_number CMD [FATAL-ERROR-MSG] 2651# ---------------------------------------------- 2652# Pass arguments to func_tool_version_output, but set 2653# $func_tool_version_number_result to the last dot delimited digit string 2654# on the first line of output. 2655func_tool_version_number () 2656{ 2657 $debug_cmd 2658 2659 _G_verout=`func_tool_version_output "$@"` 2660 _G_status=$? 2661 2662 # A version number starts with a digit following a space on the first 2663 # line of output from `--version`. 2664 _G_verout=`echo "$_G_verout" |sed 1q` 2665 if test -n "$_G_verout"; then 2666 _G_vernum=`expr "$_G_verout" : '.* \([0-9][^ ]*\)'` 2667 fi 2668 2669 if test -n "$_G_vernum"; then 2670 printf '%s\n' "$_G_vernum" 2671 else 2672 printf '%s\n' "$_G_verout" 2673 fi 2674 2675 (exit $_G_status) 2676} 2677 2678 2679# func_find_tool ENVVAR NAMES... 2680# ------------------------------ 2681# Search for a required program. Use the value of ENVVAR, if set, 2682# otherwise find the first of the NAMES that can be run (i.e., 2683# supports --version). If found, set ENVVAR to the program name, 2684# die otherwise. 2685func_find_tool () 2686{ 2687 $debug_cmd 2688 2689 _G_find_tool_envvar=$1 2690 shift 2691 _G_find_tool_names=$@ 2692 eval "_G_find_tool_res=\$$_G_find_tool_envvar" 2693 if test -n "$_G_find_tool_res"; then 2694 _G_find_tool_error_prefix="\$$find_tool_envvar: " 2695 else 2696 _G_find_tool_res= 2697 _G_bestver= 2698 for _G_prog 2699 do 2700 _G_find_tool_save_IFS=$IFS 2701 IFS=: 2702 for _G_dir in $PATH; do 2703 IFS=$_G_find_tool_save_IFS 2704 _G_progpath=$_G_dir/$_G_prog 2705 test -r "$_G_progpath" && { 2706 _G_curver=`func_tool_version_number $_G_progpath` 2707 case $_G_bestver,$_G_curver in 2708 ,) 2709 # first non--version responsive prog sticks! 2710 test -n "$_G_progpath" || _G_find_tool_res=$_G_progpath 2711 ;; 2712 ,*) 2713 # first --version responsive prog beats non--version responsive! 2714 _G_find_tool_res=$_G_progpath 2715 _G_bestver=$_G_curver 2716 ;; 2717 *,*) 2718 # another --version responsive prog must be newer to beat previous one! 2719 test "x$_G_curver" = "x$_G_bestver" \ 2720 || func_lt_ver "$_G_curver" "$_G_bestver" \ 2721 || { 2722 _G_find_tool_res=$_G_progpath 2723 _G_bestver=$_G_curver 2724 } 2725 ;; 2726 esac 2727 } 2728 done 2729 IFS=$_G_find_tool_save_IFS 2730 done 2731 fi 2732 if test -n "$_G_find_tool_res"; then 2733 func_tool_version_number >/dev/null $_G_find_tool_res "\ 2734${_G_find_tool_error_prefix}Cannot run '$_G_find_tool_res --version'" 2735 2736 # Make sure the result is exported to the environment for children 2737 # to use. 2738 eval "$_G_find_tool_envvar=\$_G_find_tool_res" 2739 eval "export $_G_find_tool_envvar" 2740 else 2741 func_error "\ 2742One of these is required: 2743 $_G_find_tool_names" 2744 fi 2745} 2746 2747 2748 2749## -------------------- ## 2750## Resource management. ## 2751## -------------------- ## 2752 2753# This section contains definitions for functions that each ensure a 2754# particular resource (a file, or a non-empty configuration variable for 2755# example) is available, and if appropriate to extract default values 2756# from pertinent package files. Where a variable already has a non- 2757# empty value (as set by the package's 'bootstrap.conf'), that value is 2758# used in preference to deriving the default. Call them using their 2759# associated 'require_*' variable to ensure that they are executed, at 2760# most, once. 2761# 2762# It's entirely deliberate that calling these functions can set 2763# variables that don't obey the namespace limitations obeyed by the rest 2764# of this file, in order that that they be as useful as possible to 2765# callers. 2766 2767 2768# require_configure_ac 2769# -------------------- 2770# Ensure that there is a 'configure.ac' or 'configure.in' file in the 2771# current directory that contains an uncommented call to AC_INIT, and 2772# that '$configure_ac' contains its name. 2773require_configure_ac=func_require_configure_ac 2774func_require_configure_ac () 2775{ 2776 $debug_cmd 2777 2778 test -z "$configure_ac" \ 2779 && func_autoconf_configure configure.ac && configure_ac=configure.ac 2780 test -z "$configure_ac" \ 2781 && func_autoconf_configure configure.in && configure_ac=configure.in 2782 test -z "$configure_ac" \ 2783 || func_verbose "found '$configure_ac'" 2784 2785 require_configure_ac=: 2786} 2787 2788 2789# require_gnu_m4 2790# -------------- 2791# Search for GNU M4, and export it in $M4. 2792require_gnu_m4=func_require_gnu_m4 2793func_require_gnu_m4 () 2794{ 2795 $debug_cmd 2796 2797 test -n "$M4" || { 2798 # Find the first m4 binary that responds to --version. 2799 func_find_tool M4 gm4 gnum4 m4 2800 } 2801 2802 test -n "$M4" || func_fatal_error "\ 2803Please install GNU M4, or 'export M4=/path/to/gnu/m4'." 2804 2805 func_verbose "export M4='$M4'" 2806 2807 # Make sure the search result is visible to subshells 2808 export M4 2809 2810 require_gnu_m4=: 2811} 2812 2813 2814## --------------- ## 2815## Core functions. ## 2816## --------------- ## 2817 2818# This section contains the high level functions used when calling this 2819# file as a script. 'func_extract_trace' is probably the only one that you 2820# won't want to replace if you source this file into your own script. 2821 2822 2823# func_extract_trace MACRO_NAMES [FILENAME]... 2824# -------------------------------------------- 2825# set '$func_extract_trace_result' to a colon delimited list of arguments 2826# to any of the comma separated list of MACRO_NAMES in FILENAME. If no 2827# FILENAME is given, then '$configure_ac' is assumed. 2828func_extract_trace () 2829{ 2830 $debug_cmd 2831 2832 $require_configure_ac 2833 $require_gnu_m4 2834 2835 _G_m4_traces=`$ECHO "--trace=$1" |$SED 's%,% --trace=%g'` 2836 _G_re_macros=`$ECHO "($1)" |$SED 's%,%|%g'` 2837 _G_macros="$1"; shift 2838 test $# -gt 0 || { 2839 set dummy $configure_ac 2840 shift 2841 } 2842 2843 # Generate an error if the first file is missing 2844 <"$1" 2845 2846 # Sadly, we can't use 'autom4te' tracing to extract macro arguments, 2847 # because it complains about things we want to ignore at bootstrap 2848 # time - like missing m4_include files; AC_PREREQ being newer than 2849 # the installed autoconf; and returns nothing when tracing 2850 # 'AM_INIT_AUTOMAKE' when aclocal hasn't been generated yet. 2851 # 2852 # The following tries to emulate a less persnickety version of (and 2853 # due to not having to wait for Perl startup on every invocation, 2854 # it's probably faster too): 2855 # 2856 # autom4te --language=Autoconf --trace=$my_macro:\$% "$@" 2857 # 2858 # First we give a minimal set of macro declarations to M4 to prime 2859 # it for reading Autoconf macros, while still providing some of the 2860 # functionality generally used at m4-time to supply dynamic 2861 # arguments to Autocof functions, but without following 2862 # 'm4_s?include' files. 2863 _G_mini=' 2864 # Initialisation. 2865 m4_changequote([,]) 2866 m4_define([m4_copy], [m4_define([$2], m4_defn([$1]))]) 2867 m4_define([m4_rename], [m4_copy([$1], [$2])m4_undefine([$1])]) 2868 2869 # Disable these macros. 2870 m4_undefine([m4_dnl]) 2871 m4_undefine([m4_include]) 2872 m4_undefine([m4_m4exit]) 2873 m4_undefine([m4_m4wrap]) 2874 m4_undefine([m4_maketemp]) 2875 2876 # Copy and rename macros not handled by "m4 --prefix". 2877 m4_define([dnl], [m4_builtin([dnl])]) 2878 m4_copy([m4_define], [m4_defun]) 2879 m4_rename([m4_ifelse], [m4_if]) 2880 m4_ifdef([m4_mkstemp], [m4_undefine([m4_mkstemp])]) 2881 m4_rename([m4_patsubst], [m4_bpatsubst]) 2882 m4_rename([m4_regexp], [m4_bregexp]) 2883 2884 # "m4sugar.mini" - useful m4-time macros for dynamic arguments. 2885 # If we discover packages that need more m4 macros defined in 2886 # order to bootstrap correctly, add them here: 2887 m4_define([m4_bmatch], 2888 [m4_if([$#], 0, [], [$#], 1, [], [$#], 2, [$2], 2889 [m4_if(m4_bregexp([$1], [$2]), -1, 2890 [$0([$1], m4_shift3($@))], [$3])])]) 2891 m4_define([m4_ifndef], [m4_ifdef([$1], [$3], [$2])]) 2892 m4_define([m4_ifset], 2893 [m4_ifdef([$1], [m4_ifval(m4_defn([$1]), [$2], [$3])], [$3])]) 2894 m4_define([m4_require], [$1]) 2895 m4_define([m4_shift3], [m4_shift(m4shift(m4shift($@)))]) 2896 2897 # "autoconf.mini" - things from autoconf macros we care about. 2898 m4_copy([m4_defun], [AC_DEFUN]) 2899 2900 # Dummy definitions for the macros we want to trace. 2901 # AM_INIT_AUTOMAKE at least produces no trace without this. 2902 ' 2903 2904 _G_save=$IFS 2905 IFS=, 2906 for _G_macro in $_G_macros; do 2907 IFS=$_G_save 2908 func_append _G_mini "AC_DEFUN([$_G_macro])$nl" 2909 done 2910 IFS=$_G_save 2911 2912 # We discard M4's stdout, but the M4 trace output from reading our 2913 # "autoconf.mini" followed by any other files passed to this 2914 # function is then scanned by sed to transform it into a colon 2915 # delimited argument list assigned to a shell variable. 2916 _G_transform='s|#.*$||; s|^dnl .*$||; s| dnl .*$||;' 2917 2918 # Unfortunately, alternation in regexp addresses doesn't work in at 2919 # least BSD (and hence Mac OS X) sed, so we have to append a capture 2920 # and print block for each traced macro to the sed transform script. 2921 _G_save=$IFS 2922 IFS=, 2923 for _G_macro in $_G_macros; do 2924 IFS=$_G_save 2925 func_append _G_transform ' 2926 /^m4trace: -1- '"$_G_macro"'/ { 2927 s|^m4trace: -1- '"$_G_macro"'[([]*|| 2928 s|], [[]|:|g 2929 s|[])]*$|:| 2930 s|\(.\):$|\1| 2931 p 2932 }' 2933 done 2934 IFS=$_G_save 2935 2936 # Save the command pipeline results for further use by callers of 2937 # this function. 2938 func_extract_trace_result=`$ECHO "$_G_mini" \ 2939 |$M4 -daq --prefix $_G_m4_traces - "$@" 2>&1 1>/dev/null \ 2940 |$SED -n -e "$_G_transform"` 2941} 2942 2943 2944# func_extract_trace_first MACRO_NAMES [FILENAME]... 2945# -------------------------------------------------- 2946# Exactly like func_extract_trace, except that only the first argument 2947# to the first invocation of one of the comma separated MACRO_NAMES is 2948# returned in '$func_extract_trace_first_result'. 2949func_extract_trace_first () 2950{ 2951 $debug_cmd 2952 2953 func_extract_trace ${1+"$@"} 2954 func_extract_trace_first_result=`$ECHO "$func_extract_trace_result" \ 2955 |$SED -e 's|:.*$||g' -e 1q` 2956} 2957 2958 2959# func_main [ARG]... 2960# ------------------ 2961func_main () 2962{ 2963 $debug_cmd 2964 2965 # Configuration. 2966 usage='$progname MACRO_NAME FILE [...]' 2967 2968 long_help_message=' 2969The first argument to this program is the name of an autotools macro 2970whose arguments you want to extract by examining the files listed in the 2971remaining arguments using the same tool that Autoconf and Automake use, 2972GNU M4. 2973 2974The arguments are returned separated by colons, with each traced call 2975on a separate line.' 2976 2977 # Option processing. 2978 func_options "$@" 2979 eval set dummy "$func_options_result"; shift 2980 2981 # Validate remaining non-option arguments. 2982 test $# -gt 1 \ 2983 || func_fatal_help "not enough arguments" 2984 2985 # Pass non-option arguments to extraction function. 2986 func_extract_trace "$@" 2987 2988 # Display results. 2989 test -n "$func_extract_trace_result" \ 2990 && $ECHO "$func_extract_trace_result" 2991 2992 # The End. 2993 exit $EXIT_SUCCESS 2994} 2995 2996 2997## --------------------------- ## 2998## Actually perform the trace. ## 2999## --------------------------- ## 3000 3001# Only call 'func_main' if this script was called directly. 3002test extract-trace = "$progname" && func_main "$@" 3003 3004# Local variables: 3005# mode: shell-script 3006# sh-indentation: 2 3007# eval: (add-hook 'before-save-hook 'time-stamp) 3008# time-stamp-pattern: "20/scriptversion=%:y-%02m-%02d.%02H; # UTC" 3009# time-stamp-time-zone: "UTC" 3010# End: 3011 3012# Set a version string for *this* script. 3013scriptversion=2014-11-04.13; # UTC 3014 3015 3016## ------------------- ## 3017## Hookable functions. ## 3018## ------------------- ## 3019 3020# After 'bootstrap.conf' has been sourced, execution proceeds by calling 3021# 'func_bootstrap'. Wherever a function is decorated with 3022# 'func_hookable func_name', you will find a matching 'func_run_hooks 3023# func_name', which executes all functions added with 'func_add_hook 3024# func_name my_func'. 3025# 3026# You might notice that many of these functions begin with a series of 3027# '$require_foo' lines. See the docu-comments at the start of the 3028# 'Resource management' section for a description of what these are. 3029 3030 3031# func_bootstrap [ARG]... 3032# ----------------------- 3033# All the functions called inside func_bootstrap are hookable. See the 3034# the individual implementations for details. 3035func_bootstrap () 3036{ 3037 $debug_cmd 3038 3039 # Save the current positional parameters to prevent them being 3040 # corrupted by calls to 'set' in 'func_init'. 3041 func_quote_for_eval ${1+"$@"} 3042 _G_saved_positional_parameters=$func_quote_for_eval_result 3043 3044 # Initialisation. 3045 func_init 3046 3047 # Option processing. 3048 eval func_options "$_G_saved_positional_parameters" 3049 3050 # Post-option preparation. 3051 func_prep 3052 3053 # Reconfigure the package. 3054 func_reconfigure 3055 3056 # Ensure .version is up-to-date. 3057 func_update_dotversion 3058 3059 # Finalisation. 3060 func_fini 3061} 3062 3063 3064# func_init 3065# --------- 3066# Any early initialisations can be hooked to this function. Consider 3067# whether you can hook onto 'func_prep' instead, because if you hook 3068# any slow to execute code in here, it will also add to the time before 3069# './bootstrap --version' can respond. 3070func_hookable func_init 3071func_init () 3072{ 3073 $debug_cmd 3074 3075 func_run_hooks func_init 3076} 3077 3078 3079# func_prep 3080# --------- 3081# Function to perform preparation for remaining bootstrap process. If 3082# your hooked code relies on the outcome of 'func_options' hook it here 3083# rather than to 'func_init'. 3084# 3085# All the functions called inside func_prep are hookable. See the 3086# individual implementations for details. 3087func_hookable func_prep 3088func_prep () 3089{ 3090 $debug_cmd 3091 3092 $require_buildtools_uptodate 3093 $require_checkout_only_file 3094 3095 $require_gnulib_merge_changelog 3096 3097 # Report the results of SED and GREP searches from funclib.sh. 3098 func_verbose "GREP='$GREP'" 3099 func_verbose "SED='$SED'" 3100 3101 # fetch update files from the translation project 3102 func_update_translations 3103 3104 func_run_hooks func_prep 3105} 3106 3107 3108# func_update_translations 3109# ------------------------ 3110# Update package po files and translations. 3111func_hookable func_update_translations 3112func_update_translations () 3113{ 3114 $debug_cmd 3115 3116 $opt_skip_po || { 3117 test -d po && { 3118 $require_package 3119 3120 func_update_po_files po $package || exit $? 3121 } 3122 3123 func_run_hooks func_update_translations 3124 } 3125} 3126 3127 3128# func_reconfigure 3129# ---------------- 3130# Reconfigure the current package by running the appropriate autotools in a 3131# suitable order. 3132func_hookable func_reconfigure 3133func_reconfigure () 3134{ 3135 $debug_cmd 3136 3137 $require_automake_options 3138 3139 # Automake (without 'foreign' option) requires that NEWS & README exist. 3140 case " $automake_options " in 3141 " foreign ") ;; 3142 *) 3143 func_ensure_NEWS 3144 func_ensure_README 3145 ;; 3146 esac 3147 3148 # Ensure ChangeLog presence. 3149 if test -n "$gnulib_modules"; then 3150 func_ifcontains "$gnulib_modules" gitlog-to-changelog \ 3151 func_ensure_changelog 3152 else 3153 $require_gnulib_cache 3154 if $SED -n '/^gl_MODULES(\[/,/^])$/p' $gnulib_cache 2>/dev/null | 3155 func_grep_q gitlog-to-changelog 3156 then 3157 func_ensure_changelog 3158 fi 3159 fi 3160 3161 # Released 'autopoint' has the tendency to install macros that have 3162 # been obsoleted in current 'gnulib', so run this before 'gnulib-tool'. 3163 func_autopoint 3164 3165 # Autoreconf runs 'aclocal' before 'libtoolize', which causes spurious 3166 # warnings if the initial 'aclocal' is confused by the libtoolized 3167 # (or worse: out-of-date) macro directory. 3168 func_libtoolize 3169 3170 # If you need to do anything after 'gnulib-tool' is done, but before 3171 # 'autoreconf' runs, you don't need to override this whole function, 3172 # because 'func_gnulib_tool' is hookable. 3173 func_gnulib_tool 3174 3175 func_autoreconf 3176 3177 func_run_hooks func_reconfigure 3178} 3179 3180 3181# func_gnulib_tool 3182# ---------------- 3183# Run 'gnulib-tool' to fetch gnulib modules into the current package. 3184# 3185# It's assumed that since you are using gnulib's 'bootstrap' script, 3186# you're also using gnulib elsewhere in your package. If not, then 3187# you can replace this function in 'bootstrap.conf' with: 3188# 3189# func_gnulib_tool () { :; } 3190# 3191# (although the function returns immediately if $gnulib_tool is set to 3192# true in any case). 3193func_hookable func_gnulib_tool 3194func_gnulib_tool () 3195{ 3196 $debug_cmd 3197 3198 $require_gnulib_tool 3199 $require_libtoolize 3200 3201 test true = "$gnulib_tool" || { 3202 # bootstrap.conf written for gnulib bootstrap expects 3203 # gnulib_tool_option_extras to which --no-changelog is appended, 3204 # but libtool bootstrap expects you to append to gnulib_tool_options 3205 # so that you can override the --no-changelog default: make sure we 3206 # support both styles so users can migrate between them easily. 3207 gnulib_tool_all_options="$gnulib_tool_options $gnulib_tool_option_extras" 3208 3209 if test -n "$gnulib_modules"; then 3210 $require_gnulib_cache 3211 $require_gnulib_tool_base_options 3212 3213 gnulib_mode=--import 3214 3215 # Try not to pick up any stale values from 'gnulib-cache.m4'. 3216 rm -f "$gnulib_cache" 3217 3218 test -n "$gnulib_tool_base_options" \ 3219 && func_append_uniq gnulib_tool_all_options " $gnulib_tool_base_options" 3220 test -n "$gnulib_mk" \ 3221 && func_append_uniq gnulib_tool_all_options " --makefile-name=$gnulib_mk" 3222 test -n "$tests_base" && { 3223 func_append_uniq gnulib_tool_all_options " --tests-base=$tests_base" 3224 func_append_uniq gnulib_tool_all_options " --with-tests" 3225 } 3226 else 3227 3228 # 'gnulib_modules' and others are cached in 'gnulib-cache.m4': 3229 # Use 'gnulib --update' to fetch gnulib modules. 3230 gnulib_mode=--update 3231 fi 3232 3233 # Add a sensible default libtool option to gnulib_tool_options. 3234 # The embedded echo is to squash whitespace before globbing. 3235 case `echo " "$gnulib_tool_all_options" "` in 3236 *" --no-libtool "*|*" --libtool "*) ;; 3237 *) if test true = "$LIBTOOLIZE"; then 3238 func_append_uniq gnulib_tool_all_options " --no-libtool" 3239 else 3240 func_append_uniq gnulib_tool_all_options " --libtool" 3241 fi 3242 ;; 3243 esac 3244 3245 $opt_copy || func_append_uniq gnulib_tool_all_options " --symlink" 3246 3247 func_append_uniq gnulib_tool_all_options " $gnulib_mode" 3248 func_append gnulib_tool_all_options " $gnulib_modules" 3249 3250 # The embedded echo is to squash whitespace before display. 3251 gnulib_cmd=`echo $gnulib_tool $gnulib_tool_all_options` 3252 3253 func_show_eval "$gnulib_cmd" 'exit $?' 3254 3255 # Use 'gnulib-tool --copy-file' to install non-module files. 3256 func_install_gnulib_non_module_files 3257 } 3258 3259 func_run_hooks func_gnulib_tool 3260} 3261 3262 3263# func_fini 3264# --------- 3265# Function to perform all finalisation for the bootstrap process. 3266func_hookable func_fini 3267func_fini () 3268{ 3269 $debug_cmd 3270 3271 func_gettext_configuration 3272 func_clean_dangling_symlinks 3273 func_clean_unused_macros 3274 func_skip_po_recommendation 3275 3276 func_run_hooks func_fini 3277 3278 $require_bootstrap_uptodate 3279 3280 func_echo "Done. Now you can run './configure'." 3281} 3282 3283 3284# func_gettext_configuration 3285# -------------------------- 3286# Edit configuration values into po/Makevars. 3287func_hookable func_gettext_configuration 3288func_gettext_configuration () 3289{ 3290 $debug_cmd 3291 3292 $require_autopoint 3293 3294 test true = "$AUTOPOINT" || { 3295 $require_copyright_holder 3296 $require_extra_locale_categories 3297 $require_package_bugreport 3298 3299 # Escape xgettext options for sed Makevars generation below. 3300 # We have to delete blank lines in a separate script so that we don't 3301 # append \\\ to the penultimate line, and then delete the last empty 3302 # line, which messes up the variable substitution later in this 3303 # function. Note that adding a literal \\\ requires double escaping 3304 # here, once for the execution subshell, and again for the assignment, 3305 # which is why there are actually 12 (!!) backslashes in the script. 3306 _G_xgettext_options=`echo "$xgettext_options$nl" |$SED '/^$/d' |$SED ' 3307 $b 3308 s|$| \\\\\\\\\\\\|'` 3309 3310 # Create gettext configuration. 3311 func_echo "Creating po/Makevars from po/Makevars.template ..." 3312 $RM -f po/Makevars 3313 $SED ' 3314 /^EXTRA_LOCALE_CATEGORIES *=/s|=.*|= '"$extra_locale_categories"'| 3315 /^COPYRIGHT_HOLDER *=/s|=.*|= '"$copyright_holder"'| 3316 /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$package_bugreport"'| 3317 /^XGETTEXT_OPTIONS *=/{ 3318 s|$| \\| 3319 a\ 3320 '"$_G_xgettext_options"' \\\ 3321 $${end_of_xgettext_options+} 3322 } 3323 ' po/Makevars.template >po/Makevars || exit 1 3324 } 3325 3326 func_run_hooks func_gettext_configuration 3327} 3328 3329 3330 3331## The section title above is chosen for what section of bootstrap 3332## these functions will be merged to, so that the invocations of 3333## `func_add_hook` are guaranteed not to be executed until after 3334## the hook management functions are defined. 3335 3336 3337# slingshot_split_buildreq 3338# ------------------------ 3339# For convenience, let the user add rockspec requirements to $buildreq. 3340# Note that this is for *build-time* requirements (e.g. ldoc), so that 3341# make can complete without error. You should add *run-time* rockspec 3342# requirements (e.g. stdlib) to rockspec.conf. 3343slingshot_split_buildreq () 3344{ 3345 $debug_cmd 3346 3347 $require_rockspecs_req 3348} 3349func_add_hook func_init slingshot_split_buildreq 3350 3351 3352# slingshot_check_rockspecs 3353# ------------------------- 3354# Check build-time rockspecs from $buildreq are uptodate. 3355# It would be nice if we could rely on luarock binaries to respond to 3356# `--version` like GNU apps, but there is no reliable consensus, so we 3357# have to check installed luarock versions directly, and warn the user 3358# if the apps we're checking for are not somewhere along PATH. 3359slingshot_check_rockspecs () 3360{ 3361 $debug_cmd 3362 3363 $opt_skip_rock_checks && return 3364 3365 $require_rockspecs_req 3366 3367 _G_req= 3368 rockspecs_uptodate_result=: 3369 3370 set dummy $rockspecs_req; shift 3371 while test $# -gt 0; do 3372 _G_rock=$1; shift 3373 _G_reqver=$1; shift 3374 _G_url=$1; shift 3375 3376 func_append _G_req " $_G_rock $_G_url" 3377 3378 # Honor $APP variables ($LDOC, $SPECL, etc.) 3379 _G_appvar=`echo $_G_rock |tr '[a-z]' '[A-Z]'` 3380 eval "_G_rock=\${$_G_appvar-$_G_rock}" 3381 3382 # Trust the user will ensure the binaries will arive at the 3383 # specified location before they are needed if they set these. 3384 if eval 'test -n "${'$_G_appvar'+set}"'; then 3385 eval test -f '"${'$_G_appvar'}"' \ 3386 || eval 'func_warning settings "\ 3387not checking whether $'$_G_appvar' has version $_G_reqver; 3388configure or make may fail because you set $_G_appvar, but 3389$'$_G_appvar' does not yet exist!"' 3390 else 3391 _G_instver=`$LUAROCKS ${opt_luarocks_tree+--tree=$opt_luarocks_tree} \ 3392 show $_G_rock 2>/dev/null \ 3393 |sed -n '/^'"$_G_rock"' .* - /{s/^'"$_G_rock"' \(.*\) - .*$/\1/p;}'` 3394 3395 if test -z "$_G_instver"; then 3396 slingshot_rockspec_error 3397 else 3398 func_verbose "found '$_G_rock' version $_G_instver." 3399 3400 case $_G_reqver in 3401 =*) 3402 test "x$_G_reqver" = "x=$_G_instver" || slingshot_rockspec_error 3403 ;; 3404 *) 3405 func_lt_ver "$_G_reqver" "$_G_instver" || slingshot_rockspec_error 3406 ;; 3407 esac 3408 fi 3409 fi 3410 done 3411 3412 $rockspecs_uptodate_result || { 3413 func_strtable 0 10 48 \ 3414 "Program" "Rockspec_URL" $_G_req 3415 func_fatal_error "Missing rocks: 3416$func_strtable_result 3417Install missing rockspecs with: 3418 $LUAROCKS ${opt_luarocks_tree+--tree=$opt_luarocks_tree }install \$Rockspec_URL 3419and then rerun bootstrap with the --luarocks-tree option set 3420appropriately, or if you're sure that the missing rocks will 3421be installed before running make by exporting: 3422 APPNAME=/path/to/app. 3423" 3424 } 3425} 3426func_add_hook func_prep slingshot_check_rockspecs 3427 3428 3429# slingshot_copy_files 3430# -------------------- 3431# Update files from slingshot subproject. 3432slingshot_copy_files () 3433{ 3434 $debug_cmd 3435 3436 $require_package 3437 3438 test slingshot = "$package" || { 3439 func_check_configuration slingshot_files 3440 3441 $require_slingshot_submodule 3442 3443 # Make sure we have the latest mkrockspecs 3444 # (the rebootstrap rule in slingshot/GNUmakefile autoruns). 3445 make -C slingshot build-aux/mkrockspecs 3446 3447 # Update in-tree links. 3448 for file in $slingshot_files; do 3449 func_dirname_and_basename "./$file" 3450 slingshot_copy "$func_basename_result" \ 3451 "slingshot/$func_dirname_result" "$func_dirname_result" 3452 done 3453 } 3454} 3455func_add_hook func_prep slingshot_copy_files 3456 3457 3458# slingshot_ensure_changelog 3459# -------------------------- 3460# Slingshot project probably won't have a gnulib_modules list. 3461# So we redo the ChangeLog check against slingshot_files. 3462slingshot_ensure_changelog () 3463{ 3464 $debug_cmd 3465 3466 if test -n "$slingshot_files"; then 3467 func_ifcontains "$slingshot_files" build-aux/gitlog-to-changelog \ 3468 func_ensure_changelog 3469 fi 3470 3471 return 0 3472} 3473func_add_hook func_prep slingshot_ensure_changelog 3474 3475 3476# slingshot_update_travis_yml 3477# --------------------------- 3478# When 'travis.yml.in' is listed in $slingshot_files, complain if 3479# regenerating '.travis.yml' would change it. 3480slingshot_update_travis_yml () 3481{ 3482 $debug_cmd 3483 3484 $require_git 3485 3486 _G_travis_yml_in=travis.yml.in 3487 _G_travis_yml_out=.travis.yml 3488 3489 rm -f "$_G_travis_yml_out.new" 3490 3491 test true = "$GIT" || { 3492 case " "`echo $slingshot_files`" " in 3493 *" travis.yml.in "*) 3494 # Remove trailing blanks so as not to trip sc_trailing_blank in syntax check 3495 test -f "$_G_travis_yml_in" && { 3496 $slingshot_require_travis_extra_rocks 3497 3498 eval `grep '^ *PACKAGE=' configure | sed 1q` 3499 eval `grep '^ *VERSION=' configure | sed 1q` 3500 3501 cat "$_G_travis_yml_in" | 3502 sed 's| *$||' | 3503 sed "s|@EXTRA_ROCKS@|`echo $travis_extra_rocks`|g" | 3504 sed "s|@PACKAGE@|$PACKAGE|g" | 3505 sed "s|@VERSION@|$VERSION|g" 3506 3507 if test -f .slackid; then 3508 read slackid < .slackid 3509 printf '%s\n' '' 'notifications:' " slack: $slackid" 3510 fi 3511 } > "$_G_travis_yml_out.new" 3512 3513 if test -f "$_G_travis_yml_out"; then 3514 if func_cmp_s "$_G_travis_yml_out" "$_G_travis_yml_out.new"; then 3515 func_verbose "$_G_travis_yml_out is up to date" 3516 rm -f "$_G_travis_yml_out.new" 3517 else 3518 func_warning upgrade "\ 3519An updated $_G_travis_yml_out script is ready for you in 3520'$_G_travis_yml_out.new'. After you've verified that you want 3521the changes, you can update with: 3522 mv -f $_G_travis_yml_out.new $_G_travis_yml_out" 3523 fi 3524 else 3525 func_verbose "creating '$_G_travis_yml_out'" 3526 mv -f "$_G_travis_yml_out.new" "$_G_travis_yml_out" 3527 fi 3528 ;; 3529 esac 3530 } 3531} 3532func_add_hook func_fini slingshot_update_travis_yml 3533 3534 3535# slingshot_check_rockstree_path 3536# ------------------------------ 3537# Show a warning at the end of bootstrap if --luarocks-tree was passed 3538# set, but $opt_luarocks_tree/bin is not in the command PATH. 3539slingshot_check_rockstree_path () 3540{ 3541 $debug_cmd 3542 3543 test -z "$rockspecs_req" || { 3544 case :$PATH: in 3545 *:$opt_luarocks_tree/bin:*) ;; 3546 *) func_warning recommend \ 3547 "If configure or make fail, try adding $opt_luarocks_tree/bin to PATH" ;; 3548 esac 3549 } 3550} 3551func_add_hook func_fini slingshot_check_rockstree_path 3552 3553 3554## --------------- ## 3555## Core functions. ## 3556## --------------- ## 3557 3558# This section contains the main functions called from the 'Hookable 3559# functions' (shown above), and are the ones you're most likely 3560# to want to replace with your own implementations in 'bootstrap.conf'. 3561 3562 3563# func_autopoint 3564# -------------- 3565# If this package uses gettext, then run 'autopoint'. 3566func_autopoint () 3567{ 3568 $debug_cmd 3569 3570 $require_autopoint 3571 3572 test true = "$AUTOPOINT" \ 3573 || func_show_eval "$AUTOPOINT --force" 'exit $?' 3574} 3575 3576 3577# func_libtoolize 3578# --------------- 3579# If this package uses libtool, then run 'libtoolize'. 3580func_libtoolize () 3581{ 3582 $debug_cmd 3583 3584 $require_libtoolize 3585 3586 test true = "$LIBTOOLIZE" || { 3587 _G_libtoolize_options= 3588 $opt_copy && func_append _G_libtoolize_options " --copy" 3589 $opt_force && func_append _G_libtoolize_options " --force" 3590 $opt_verbose || func_append _G_libtoolize_options " --quiet" 3591 func_show_eval "$LIBTOOLIZE$_G_libtoolize_options" 'exit $?' 3592 } 3593} 3594 3595 3596# func_gnulib_tool_copy_file SRC DEST 3597# ----------------------------------- 3598# Copy SRC, a path relative to the gnulib sub-tree, to DEST, a path 3599# relative to the top-level source directory using gnulib-tool so that 3600# any patches or replacements in $local_gl_dir are applied. 3601func_gnulib_tool_copy_file () 3602{ 3603 $debug_cmd 3604 3605 $require_gnulib_tool 3606 $require_patch 3607 3608 if test true = "$gnulib_tool"; then 3609 # If gnulib-tool is not available (e.g. bootstrapping in a 3610 # distribution tarball), make sure that at least we have some 3611 # version of the required file already in place. 3612 test -f "$2" || func_fatal_error "\ 3613Can't find, copy or download '$2', a required 3614gnulib supplied file, please provide the location of a 3615complete 'gnulib' tree by setting 'gnulib_path' in your 3616'bootstrap.conf' or with the '--gnulib-srcdir' option - 3617or else specify the location of your 'git' binary by 3618setting 'GIT' in the environment so that a fresh 3619'gnulib' submodule can be cloned." 3620 else 3621 $require_gnulib_copy_cmd 3622 3623 $gnulib_copy_cmd $1 $2 2>/dev/null || { 3624 $require_gnulib_path 3625 3626 func_error "'$gnulib_path/$1' does not exist" 3627 return 1 3628 } 3629 fi 3630} 3631 3632 3633# func_install_gnulib_non_module_files 3634# ------------------------------------ 3635# Get additional non-module files from gnulib, overriding existing files. 3636func_install_gnulib_non_module_files () 3637{ 3638 $debug_cmd 3639 3640 $require_build_aux 3641 $require_gnulib_tool 3642 3643 test -n "$gnulib_non_module_files" && { 3644 maybe_exit_cmd=: 3645 3646 for file in $gnulib_non_module_files; do 3647 case $file in 3648 */COPYING*) dest=COPYING;; 3649 */INSTALL) dest=INSTALL;; 3650 build-aux/missing) dest= 3651 func_warning settings "\ 3652Please remove build-aux/missing from gnulib_module_files in 3653'bootstrap.conf', as it may clash with Automake's version." 3654 ;; 3655 build-aux/*) dest=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;; 3656 *) dest=$file;; 3657 esac 3658 3659 # Be sure to show all copying errors before bailing out 3660 test -z "$dest" \ 3661 || func_gnulib_tool_copy_file "$file" "$dest" \ 3662 || maybe_exit_cmd="exit $EXIT_FAILURE" 3663 done 3664 3665 $maybe_exit_cmd 3666 } 3667} 3668 3669 3670# func_ensure_changelog 3671# --------------------- 3672# Even with 'gitlog-to-changelog' generated ChangeLogs, automake 3673# will not run to completion with no ChangeLog file. 3674func_ensure_changelog () 3675{ 3676 $debug_cmd 3677 3678 test -f ChangeLog && mv -f ChangeLog ChangeLog~ 3679 3680 cat >ChangeLog <<'EOT' 3681## ---------------------- ## 3682## DO NOT EDIT THIS FILE! ## 3683## ---------------------- ## 3684 3685ChangeLog is generated by gitlog-to-changelog. 3686EOT 3687 3688 _G_message="creating dummy 'ChangeLog'" 3689 test -f ChangeLog~ \ 3690 && func_append _G_message ' (backup in ChangeLog~)' 3691 func_verbose "$_G_message" 3692 3693 return 0 3694} 3695 3696 3697# func_ensure_NEWS 3698# ---------------- 3699# Without AM_INIT_AUTOMAKE([foreign]), automake will not run to 3700# completion with no NEWS file, even though NEWS.md or NEWS.txt 3701# is often preferable. 3702func_ensure_NEWS () 3703{ 3704 $debug_cmd 3705 3706 test -f NEWS || { 3707 _G_NEWS= 3708 for _G_news in NEWS.txt NEWS.md NEWS.rst; do 3709 test -f "$_G_news" && break 3710 done 3711 3712 test -f "$_G_news" && $LN_S $_G_news NEWS 3713 func_verbose "$LN_S $_G_news NEWS" 3714 } 3715 3716 return 0 3717} 3718 3719 3720# func_ensure_README 3721# ------------------ 3722# Without AM_INIT_AUTOMAKE([foreign]), automake will not run to 3723# completion with no README file, even though README.md or README.txt 3724# is often preferable. 3725func_ensure_README () 3726{ 3727 $debug_cmd 3728 3729 test -f README || { 3730 _G_README= 3731 for _G_readme in README.txt README.md README.rst; do 3732 test -f "$_G_readme" && break 3733 done 3734 3735 test -f "$_G_readme" && $LN_S $_G_readme README 3736 func_verbose "$LN_S $_G_readme README" 3737 } 3738 3739 return 0 3740} 3741 3742 3743# func_autoreconf [SUBDIR] 3744# ------------------------ 3745# Being careful not to re-run 'autopoint' or 'libtoolize', and not to 3746# try to run 'autopoint', 'libtoolize' or 'autoheader' on packages that 3747# don't use them, defer to 'autoreconf' for execution of the remaining 3748# autotools to bootstrap this package. 3749# 3750# Projects with multiple trees to reconfigure can hook another call to 3751# this function onto func_reconfigure: 3752# 3753# my_autoreconf_foo () 3754# { 3755# func_autoreconf foo 3756# } 3757# func_add_hook func_reconfigure my_autoreconf_foo 3758func_autoreconf () 3759{ 3760 $debug_cmd 3761 3762 $require_autoheader 3763 $require_build_aux # automake and others put files in here 3764 $require_macro_dir # aclocal and others put files in here 3765 3766 # We ran these manually already, and autoreconf won't exec ':' 3767 save_AUTOPOINT=$AUTOPOINT; AUTOPOINT=true 3768 save_LIBTOOLIZE=$LIBTOOLIZE; LIBTOOLIZE=true 3769 3770 _G_autoreconf_options= 3771 $opt_copy || func_append _G_autoreconf_options " --symlink" 3772 $opt_force && func_append _G_autoreconf_options " --force" 3773 $opt_verbose && func_append _G_autoreconf_options " --verbose" 3774 func_show_eval "$AUTORECONF$_G_autoreconf_options --install${1+ $1}" 'exit $?' 3775 3776 AUTOPOINT=$save_AUTOPOINT 3777 LIBTOOLIZE=$save_LIBTOOLIZE 3778} 3779 3780 3781# func_check_configuration VARNAME [CONFIGURE_MACRO] 3782# -------------------------------------------------- 3783# Exit with a suitable diagnostic for an important configuration change 3784# that needs to be made before bootstrap can run correctly. 3785func_check_configuration () 3786{ 3787 $debug_cmd 3788 3789 $require_configure_ac 3790 3791 eval 'test -n "$'$1'"' || { 3792 _G_error_msg="please set '$1' in 'bootstrap.conf'" 3793 if test -n "$configure_ac" && test -n "$2"; then 3794 func_append _G_error_msg " 3795or add the following (or similar) to your '$configure_ac': 3796$2" 3797 fi 3798 3799 func_fatal_error "$_G_error_msg" 3800 } 3801} 3802 3803 3804# func_clean_dangling_symlinks 3805# ---------------------------- 3806# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some 3807# gnulib-populated directories. Such .m4 files would cause aclocal to 3808# fail. The following requires GNU find 4.2.3 or newer. Considering 3809# the usual portability constraints of this script, that may seem a very 3810# demanding requirement, but it should be ok. Ignore any failure, 3811# which is fine, since this is only a convenience to help developers 3812# avoid the relatively unusual case where a symlinked-to .m4 file is 3813# git-removed from gnulib between successive runs of this script. 3814func_clean_dangling_symlinks () 3815{ 3816 $debug_cmd 3817 3818 $require_macro_dir 3819 $require_source_base 3820 3821 func_verbose "cleaning dangling symlinks" 3822 3823 find "$macro_dir" "$source_base" \ 3824 -depth \( -name '*.m4' -o -name '*.[ch]' \) \ 3825 -type l -xtype l -delete > /dev/null 2>&1 3826} 3827 3828 3829# func_clean_unused_macros 3830# ------------------------ 3831# Autopoint can result in over-zealously adding macros into $macro_dir 3832# even though they are not actually used, for example tests to help 3833# build the 'intl' directory even though you have specified 3834# 'AM_GNU_GETTEXT([external])' in your configure.ac. This function 3835# looks removes any macro files that can be found in gnulib, but 3836# are not 'm4_include'd by 'aclocal.m4'. 3837func_clean_unused_macros () 3838{ 3839 $debug_cmd 3840 3841 $require_gnulib_path 3842 $require_macro_dir 3843 3844 test -n "$gnulib_path" && test -f aclocal.m4 && { 3845 aclocal_m4s=`find . -name aclocal.m4 -print` 3846 3847 # We use 'ls|grep' instead of 'ls *.m4' to avoid exceeding 3848 # command line length limits in some shells. 3849 for file in `cd "$macro_dir" && ls -1 |$GREP '\.m4$'`; do 3850 3851 # Remove a macro file when aclocal.m4 does not m4_include it... 3852 func_grep_q 'm4_include([[]'$macro_dir/$file'])' $aclocal_m4s \ 3853 || test ! -f "$gnulib_path/m4/$file" || { 3854 3855 # ...and there is an identical file in gnulib... 3856 if func_cmp_s "$gnulib_path/m4/$file" "$macro_dir/$file"; then 3857 3858 # ...and it's not in the precious list ('echo' is needed 3859 # here to squash whitespace for the match expression). 3860 case " "`echo $gnulib_precious`" " in 3861 *" $file "*) ;; 3862 *) rm -f "$macro_dir/$file" 3863 func_verbose \ 3864 "removing unused gnulib file '$macro_dir/$file'" 3865 esac 3866 fi 3867 } 3868 done 3869 } 3870} 3871 3872 3873# func_skip_po_recommendation 3874# --------------------------- 3875# If there is a po directory, and '--skip-po' wasn't passed, let the 3876# user know that they can use '--skip-po' on subsequent invocations. 3877func_skip_po_recommendation () 3878{ 3879 $debug_cmd 3880 3881 test ! -d po \ 3882 || $opt_skip_po \ 3883 || func_warning recommend "\ 3884If your pofiles are up-to-date, you can rerun bootstrap 3885as '$progname --skip-po' to avoid redownloading." 3886} 3887 3888 3889# func_update_dotversion 3890# ---------------------- 3891# Even with 'gitlog-to-changelog' generated ChangeLogs, automake 3892# will not run to completion with no ChangeLog file. 3893func_update_dotversion () 3894{ 3895 $debug_cmd 3896 3897 test -f "$build_aux/git-version-gen" && { 3898 _G_message="updating .version" 3899 test -f .version && { 3900 mv .version .version~ 3901 func_append _G_message " (backup in .version~)" 3902 } 3903 func_verbose "updating .version" 3904 3905 $build_aux/git-version-gen dummy-arg > .version 3906 } 3907} 3908 3909 3910 3911## -------------------- ## 3912## Resource management. ## 3913## -------------------- ## 3914 3915# This section contains definitions for functions that each ensure a 3916# particular resource (a file, or a non-empty configuration variable for 3917# example) is available, and if appropriate to extract default values 3918# from pertinent package files. Where a variable already has a non- 3919# empty value (as set by the package's 'bootstrap.conf'), that value is 3920# used in preference to deriving the default. Call them using their 3921# associated 'require_*' variable to ensure that they are executed, at 3922# most, once. 3923 3924 3925# require_checkout_only_file 3926# -------------------------- 3927# Bail out if this package only bootstraps properly from a repository 3928# checkout. 3929require_checkout_only_file=func_require_checkout_only_file 3930func_require_checkout_only_file () 3931{ 3932 $debug_cmd 3933 3934 $opt_force || { 3935 test -n "$checkout_only_file" && test ! -f "$checkout_only_file" \ 3936 && func_fatal_error "\ 3937Bootstrapping from a non-checked-out distribution is risky. 3938If you wish to bootstrap anyway, use the '--force' option." 3939 } 3940 3941 require_checkout_only_file=: 3942} 3943 3944 3945# require_aclocal_amflags 3946# ----------------------- 3947# Ensure '$aclocal_amflags' has a sensible default, extracted from 3948# 'Makefile.am' if necessary. 3949require_aclocal_amflags=func_require_aclocal_amflags 3950func_require_aclocal_amflags () 3951{ 3952 $debug_cmd 3953 3954 $require_makefile_am 3955 3956 _G_sed_extract_aclocal_amflags='s|#.*$|| 3957 /^[ ]*ACLOCAL_AMFLAGS[ ]*=/ { 3958 s|^.*=[ ]*\(.*\)|aclocal_amflags="\1"| 3959 p 3960 }' 3961 3962 _G_aclocal_flags_cmd=`$SED -n "$_G_sed_extract_aclocal_amflags" \ 3963 "$makefile_am"` 3964 eval "$_G_aclocal_flags_cmd" 3965 3966 func_verbose "ACLOCAL_AMFLAGS='$aclocal_amflags'" 3967 3968 require_aclocal_amflags=: 3969} 3970 3971 3972# require_autoheader 3973# ------------------ 3974# Skip autoheader if it's not needed. 3975require_autoheader=func_require_autoheader 3976func_require_autoheader () 3977{ 3978 $debug_cmd 3979 3980 test true = "$AUTOHEADER" || { 3981 func_extract_trace AC_CONFIG_HEADERS 3982 test -n "$func_extract_trace_result" \ 3983 || func_extract_trace AC_CONFIG_HEADER 3984 3985 test -n "$func_extract_trace_result" || { 3986 AUTOHEADER=true 3987 3988 func_verbose "export AUTOHEADER='$AUTOHEADER'" 3989 3990 # Make sure the search result is visible to subshells 3991 export AUTOHEADER 3992 } 3993 } 3994 3995 require_autoheader=: 3996} 3997 3998 3999# require_automake_options 4000# ------------------------ 4001# Extract options from AM_AUTOMAKE_INIT. 4002require_automake_options=func_require_automake_options 4003func_require_automake_options () 4004{ 4005 $debug_cmd 4006 4007 func_extract_trace AM_INIT_AUTOMAKE 4008 automake_options=$func_extract_trace_result 4009 4010 require_automake_options=: 4011} 4012 4013 4014# require_autopoint 4015# ----------------- 4016# Skip autopoint if it's not needed. 4017require_autopoint=func_require_autopoint 4018func_require_autopoint () 4019{ 4020 $debug_cmd 4021 4022 test true = "$AUTOPOINT" || { 4023 func_extract_trace AM_GNU_GETTEXT_VERSION 4024 4025 test -n "$func_extract_trace_result" || { 4026 AUTOPOINT=true 4027 4028 func_verbose "export AUTOPOINT='$AUTOPOINT'" 4029 4030 # Make sure the search result is visible to subshells 4031 export AUTOPOINT 4032 } 4033 } 4034 4035 require_autopoint=: 4036} 4037 4038 4039# require_bootstrap_uptodate 4040# -------------------------- 4041# Complain if the version of bootstrap in the gnulib directory differs 4042# from the one we are running. 4043 4044func_require_bootstrap_uptodate () 4045{ 4046 $debug_cmd 4047 4048 $require_build_aux 4049 4050 _G_bootstrap_sources=" 4051 $build_aux/bootstrap.in 4052 $build_aux/extract-trace 4053 $build_aux/funclib.sh 4054 $build_aux/options-parser 4055 " 4056 4057 _G_missing_bootstrap_sources=false 4058 for _G_src in $_G_bootstrap_sources; do 4059 test -f "$_G_src" || _G_missing_bootstrap_sources=: 4060 done 4061 4062 if $_G_missing_bootstrap_sources; then 4063 func_warning upgrade "\ 4064Please add bootstrap to your gnulib_modules list in 4065'bootstrap.conf', so that I can tell you when there are 4066updates available." 4067 else 4068 rm -f bootstrap.new 4069 $build_aux/inline-source $build_aux/bootstrap.in > bootstrap.new 4070 4071 if func_cmp_s "$progpath" bootstrap.new; then 4072 rm -f bootstrap.new 4073 func_verbose "bootstrap script up to date" 4074 else 4075 chmod 555 bootstrap.new 4076 func_warning upgrade "\ 4077An updated bootstrap script has been generated for you in 4078'bootstrap.new'. After you've verified that you want 4079the changes, you can update with: 4080 mv -f bootstrap.new $progname 4081 ./$progname 4082 4083Or you can disable this check permanently by adding the 4084following to 'bootstrap.conf': 4085 require_bootstrap_uptodate=:" 4086 fi 4087 fi 4088 4089 require_bootstrap_uptodate=: 4090} 4091 4092 4093# require_build_aux 4094# ----------------- 4095# Ensure that '$build_aux' is set, and if it doesn't already point to an 4096# existing directory, create one. 4097require_build_aux=func_require_build_aux 4098func_require_build_aux () 4099{ 4100 $debug_cmd 4101 4102 test -n "$build_aux" || { 4103 func_extract_trace_first AC_CONFIG_AUX_DIR 4104 build_aux=$func_extract_trace_first_result 4105 func_check_configuration build_aux \ 4106 "AC_CONFIG_AUX_DIR([name of a directory for build scripts])" 4107 4108 func_verbose "build_aux='$build_aux'" 4109 } 4110 4111 $require_vc_ignore_files 4112 4113 # If the build_aux directory doesn't exist, create it now, and mark it 4114 # as ignored for the VCS. 4115 if test ! -d "$build_aux"; then 4116 func_show_eval "mkdir '$build_aux'" 4117 4118 test -n "$vc_ignore_files" \ 4119 || func_insert_if_absent "$build_aux" $vc_ignore_files 4120 fi 4121 4122 require_build_aux=: 4123} 4124 4125 4126# require_buildreq_autobuild 4127# -------------------------- 4128# Try to find whether the bootstrap requires autobuild. 4129require_buildreq_autobuild=func_require_buildreq_autobuild 4130func_require_buildreq_autobuild () 4131{ 4132 $debug_cmd 4133 4134 $require_macro_dir 4135 4136 test -f "$macro_dir/autobuild.m4" \ 4137 || printf '%s\n' "$buildreq" |func_grep_q '^[ ]*autobuild' \ 4138 || { 4139 func_extract_trace AB_INIT 4140 test -n "$func_extract_trace_result" && { 4141 func_append buildreq 'autobuild - http://josefsson.org/autobuild/ 4142' 4143 func_verbose "auto-adding 'autobuild' to build requirements" 4144 } 4145 } 4146 4147 require_buildreq_autobuild=: 4148} 4149 4150 4151# require_buildreq_autoconf 4152# require_buildreq_autopoint 4153# require_buildreq_libtoolize 4154# --------------------------- 4155# Try to find the minimum compatible version of autoconf/libtool 4156# required to bootstrap successfully, and add it to '$buildreq'. 4157for tool in autoconf libtoolize autopoint; do 4158 b=$tool 4159 v=require_buildreq_${tool} 4160 f=func_$v 4161 case $tool in 4162 autoconf) m=AC_PREREQ ;; 4163 libtoolize) m=LT_PREREQ; b=libtool ;; 4164 autopoint) m=AM_GNU_GETTEXT_VERSION b=gettext ;; 4165 esac 4166 4167 eval $v'='$f' 4168 '$f' () 4169 { 4170 $debug_cmd 4171 4172 # The following is ignored if undefined, but might be necessary 4173 # in order for `func_find_tool` to run. 4174 ${require_'$tool'-:} 4175 4176 printf '\''%s\n'\'' "$buildreq" |func_grep_q '\''^[ ]*'$tool\'' || { 4177 func_extract_trace '$m' 4178 _G_version=$func_extract_trace_result 4179 test -n "$_G_version" && { 4180 func_append buildreq "\ 4181 '$tool' $_G_version http://www.gnu.org/s/'$b' 4182" 4183 func_verbose \ 4184 "auto-adding '\'$tool'-$_G_version'\'' to build requirements" 4185 } 4186 } 4187 4188 '$v'=: 4189 } 4190' 4191done 4192 4193 4194# require_buildreq_automake 4195# ------------------------- 4196# Try to find the minimum compatible version of automake required to 4197# bootstrap successfully, and add it to '$buildreq'. 4198require_buildreq_automake=func_require_buildreq_automake 4199func_require_buildreq_automake () 4200{ 4201 $debug_cmd 4202 4203 # if automake is not already listed in $buildreq... 4204 printf '%s\n' "$buildreq" |func_grep_q automake || { 4205 func_extract_trace AM_INIT_AUTOMAKE 4206 4207 # ...and AM_INIT_AUTOMAKE is declared... 4208 test -n "$func_extract_trace_result" && { 4209 automake_version=`$ECHO "$func_extract_trace_result" \ 4210 |$SED -e 's|[^0-9]*||' -e 's| .*$||'` 4211 test -n "$automake_version" || automake_version=- 4212 4213 func_append buildreq "\ 4214 automake $automake_version http://www.gnu.org/s/automake 4215" 4216 func_verbose \ 4217 "auto-adding 'automake-$automake_version' to build requirements" 4218 } 4219 } 4220 4221 require_buildreq_automake=: 4222} 4223 4224 4225# require_buildreq_patch 4226# ---------------------- 4227# Automatically add a patch build-requirement if there are diff files 4228# in $local_gl_dir. 4229require_buildreq_patch=func_require_buildreq_patch 4230func_require_buildreq_patch () 4231{ 4232 $debug_cmd 4233 4234 $require_local_gl_dir 4235 4236 # This ensures PATCH is set appropriately by the time 4237 # func_check_versions enforces $buildreq. 4238 $require_patch 4239 4240 # If patch is not already listed in $buildreq... 4241 printf '%s\n' "$buildreq" |func_grep_q '^[ ]*patch' || { 4242 # The ugly find invocation is necessary to exit with non-zero 4243 # status for old find binaries that don't support -exec fully. 4244 if test ! -d "$local_gl_dir" \ 4245 || find "$local_gl_dir" -name "*.diff" -exec false {} \; ; then : 4246 else 4247 func_append buildreq 'patch - http://www.gnu.org/s/patch 4248' 4249 fi 4250 } 4251 4252 require_buildreq_patch=: 4253} 4254 4255 4256# require_buildtools_uptodate 4257# --------------------------- 4258# Ensure all the packages listed in BUILDREQS are available on the build 4259# machine at the minimum versions or better. 4260require_buildtools_uptodate=func_require_buildtools_uptodate 4261func_require_buildtools_uptodate () 4262{ 4263 $debug_cmd 4264 4265 $require_buildreq_autobuild 4266 $require_buildreq_autoconf 4267 $require_buildreq_automake 4268 $require_buildreq_libtoolize 4269 $require_buildreq_autopoint 4270 $require_buildreq_patch 4271 4272 test -n "$buildreq" && { 4273 _G_error_hdr= 4274 4275 func_check_versions $buildreq 4276 $func_check_versions_result || { 4277 test -n "$buildreq_readme" \ 4278 && test -f "$buildreq_readme" \ 4279 && _G_error_hdr="\ 4280$buildreq_readme explains how to obtain these prerequisite programs: 4281" 4282 func_strtable 0 11 12 36 \ 4283 "Program" "Min_version" "Homepage" $buildreq 4284 func_fatal_error "$_G_error_hdr$func_strtable_result" 4285 } 4286 } 4287 4288 require_buildtools_uptodate=: 4289} 4290 4291 4292# require_copyright_holder 4293# ------------------------ 4294# Ensure there is a sensible non-empty default value in '$copyright_holder'. 4295require_copyright_holder=func_require_copyright_holder 4296func_require_copyright_holder () 4297{ 4298 $debug_cmd 4299 4300 test -n "$copyright_holder" || { 4301 copyright_holder='Free Software Foundation, Inc.' 4302 func_warning settings "\ 4303Please set copyright_holder explicitly in 'bootstrap.conf'; 4304defaulting to '$copyright_holder'." 4305 } 4306 4307 require_copyright_holder=: 4308} 4309 4310 4311# require_doc_base 4312# ---------------- 4313# Ensure doc_base has a sensible value, extracted from 'gnulib-cache.m4' 4314# if possible, otherwise letting 'gnulib-tool' pick a default. 4315require_doc_base=func_require_doc_base 4316func_require_doc_base () 4317{ 4318 $debug_cmd 4319 4320 $require_gnulib_cache 4321 4322 test -f "$gnulib_cache" && test -z "$doc_base" && { 4323 func_extract_trace_first "gl_DOC_BASE" "$gnulib_cache" 4324 doc_base=$func_extract_trace_first_result 4325 4326 test -n "$doc_base" && func_verbose "doc_base='$doc_base'" 4327 } 4328 4329 require_doc_base=: 4330} 4331 4332 4333# require_dotgitmodules 4334# --------------------- 4335# Ensure we have a '.gitmodules' file, with appropriate 'gnulib' settings. 4336require_dotgitmodules=func_require_dotgitmodules 4337func_require_dotgitmodules () 4338{ 4339 $debug_cmd 4340 4341 $require_git 4342 4343 test true = "$GIT" || { 4344 # A gnulib entry in .gitmodules always takes precedence. 4345 _G_path=`$GIT config --file .gitmodules submodule.gnulib.path 2>/dev/null` 4346 4347 test -n "$_G_path" || { 4348 $require_vc_ignore_files 4349 4350 func_verbose "creating '.gitmodules'" 4351 4352 # If the .gitmodules file doesn't exist, create it now, and mark 4353 # it as ignored for the VCS. 4354 test -n "$gnulib_path" || gnulib_path=gnulib 4355 test -n "$gnulib_url" || gnulib_url=git://git.sv.gnu.org/gnulib 4356 4357 { 4358 echo '[submodule "gnulib"]' 4359 echo " path = $gnulib_path" 4360 echo " url = $gnulib_url" 4361 } >> .gitmodules 4362 4363 test -n "$vc_ignore_files" \ 4364 || func_insert_if_absent ".gitmodules" $vc_ignore_files 4365 } 4366 } 4367 4368 require_dotgitmodules=: 4369} 4370 4371 4372# require_extra_locale_categories 4373# ------------------------------- 4374# Ensure there is a default value in '$extra_locale_categories' 4375require_extra_locale_categories=func_require_extra_locale_categories 4376func_require_extra_locale_categories () 4377{ 4378 $debug_cmd 4379 4380 # Defaults to empty, so run with whatever value may have been set in 4381 # 'bootstrap.conf'. 4382 require_extra_locale_categories=: 4383} 4384 4385 4386# require_git 4387# ----------- 4388# Ignore git if it's not available, or we're not in a git checkout tree. 4389require_git=func_require_git 4390func_require_git () 4391{ 4392 $debug_cmd 4393 4394 $opt_skip_git && GIT=true 4395 4396 test true = "$GIT" || { 4397 if test -d .git/.; then 4398 ($GIT --version) >/dev/null 2>&1 || GIT=true 4399 fi 4400 } 4401 4402 func_verbose "GIT='$GIT'" 4403 4404 require_git=: 4405} 4406 4407 4408# require_gnulib_cache 4409# -------------------- 4410# Ensure there is a non-empty default for '$gnulib_cache', and that it 4411# names an existing file. 4412require_gnulib_cache=func_require_gnulib_cache 4413func_require_gnulib_cache () 4414{ 4415 $debug_cmd 4416 4417 $require_macro_dir 4418 4419 test -n "$gnulib_cache" \ 4420 || gnulib_cache=$macro_dir/gnulib-cache.m4 4421 4422 func_verbose "found '$gnulib_cache'" 4423 4424 require_gnulib_cache=: 4425} 4426 4427 4428# require_gnulib_copy_cmd 4429# ----------------------- 4430# Only calculate the options for copying files with gnulib once. 4431require_gnulib_copy_cmd=func_require_gnulib_copy_cmd 4432func_require_gnulib_copy_cmd () 4433{ 4434 $debug_cmd 4435 4436 $require_gnulib_tool 4437 $require_gnulib_tool_base_options 4438 4439 gnulib_copy_cmd="$gnulib_tool $gnulib_tool_base_options --copy-file" 4440 $opt_copy || func_append gnulib_copy_cmd " --symlink" 4441 $opt_quiet || func_append gnulib_copy_cmd " --verbose" 4442 4443 require_gnulib_copy_cmd=: 4444} 4445 4446 4447# require_gnulib_merge_changelog 4448# ------------------------------ 4449# See if we can use gnulib's git-merge-changelog merge driver. 4450require_gnulib_merge_changelog=func_require_gnulib_merge_changelog 4451func_require_gnulib_merge_changelog () 4452{ 4453 $debug_cmd 4454 4455 test -f ChangeLog && { 4456 $require_git 4457 4458 func_grep_q '^\(/\|\)ChangeLog$' .gitignore || test true = "$GIT" || { 4459 if $GIT config merge.merge-changelog.driver >/dev/null; then 4460 : 4461 elif (git-merge-changelog --version) >/dev/null 2>&1; then 4462 func_echo "initializing git-merge-changelog driver" 4463 $GIT config merge.merge-changelog.name 'GNU-style ChangeLog merge driver' 4464 $GIT config merge.merge-changelog.driver 'git-merge-changelog %O %A %B' 4465 else 4466 func_warning recommend \ 4467 "Consider installing git-merge-changelog from gnulib." 4468 fi 4469 } 4470 } 4471 4472 require_gnulib_merge_changelog=: 4473} 4474 4475 4476# require_gnulib_mk 4477# ----------------- 4478# Ensure gnulib_mk has a sensible value, extracted from 'gnulib-cache.m4' 4479# if possible, otherwise letting 'gnulib-tool' pick a default. 4480require_gnulib_mk=func_require_gnulib_mk 4481func_require_gnulib_mk () 4482{ 4483 $debug_cmd 4484 4485 $require_gnulib_cache 4486 4487 test -f "$gnulib_cache" && test -z "$gnulib_mk" && { 4488 func_extract_trace_first "gl_MAKEFILE_NAME" "$gnulib_cache" 4489 gnulib_mk=$func_extract_trace_first_result 4490 4491 test -n "$gnulib_mk" && func_verbose "gnulib_mk='$gnulib_mk'" 4492 } 4493 4494 require_gnulib_mk=: 4495} 4496 4497 4498# require_gnulib_name 4499# ------------------- 4500# Ensure gnulib_name has a sensible value, extracted from 'gnulib-cache.m4' 4501# if possible, otherwise letting 'gnulib-tool' pick a default. 4502require_gnulib_name=func_require_gnulib_name 4503func_require_gnulib_name () 4504{ 4505 $debug_cmd 4506 4507 $require_gnulib_cache 4508 4509 test -f "$gnulib_cache" && test -z "$gnulib_name" && { 4510 func_extract_trace_first "gl_LIB" "$gnulib_cache" 4511 gnulib_name=$func_extract_trace_first_result 4512 4513 test -n "$gnulib_name" && func_verbose "gnulib_name='$gnulib_name'" 4514 } 4515 4516 require_gnulib_name=: 4517} 4518 4519 4520# require_gnulib_path 4521# require_gnulib_url 4522# ------------------- 4523# Ensure 'gnulib_path' and 'gnulib_url' are set. 4524require_gnulib_path=func_require_dotgitmodules_parameters 4525require_gnulib_url=func_require_dotgitmodules_parameters 4526func_require_dotgitmodules_parameters () 4527{ 4528 $debug_cmd 4529 4530 $require_git 4531 4532 test true = "$GIT" && { 4533 # If we can't find git (or if the user specified '--skip-git'), 4534 # then use an existing gnulib directory specified with 4535 # '--gnulib-srcdir' if possible. 4536 test -n "$gnulib_path" \ 4537 || test ! -x "$opt_gnulib_srcdir/gnulib-tool" \ 4538 || gnulib_path=$opt_gnulib_srcdir 4539 } 4540 4541 4542 $require_dotgitmodules 4543 4544 test -f .gitmodules && { 4545 # Extract the parameters with sed, since git may be missing 4546 test -n "$gnulib_path" \ 4547 || gnulib_path=`$SED -e '/^.submodule "gnulib".$/,${ 4548 /[ ]*path *= */{ 4549 s|[ ]*||g;s|^[^=]*=||;p 4550 } 4551 } 4552 d' .gitmodules |$SED 1q` 4553 test -n "$gnulib_url" \ 4554 || gnulib_url=`$SED -e '/^.submodule "gnulib".$/,${ 4555 /[ ]*url *= */{ 4556 s|[ ]*||g;s|^[^=]*=||;p 4557 } 4558 } 4559 d' .gitmodules |$SED 1q` 4560 4561 func_verbose "gnulib_path='$gnulib_path'" 4562 func_verbose "gnulib_url='$gnulib_url'" 4563 } 4564 4565 require_gnulib_path=: 4566 require_gnulib_url=: 4567} 4568 4569 4570# require_gnulib_submodule 4571# ------------------------ 4572# Ensure that there is a current gnulib submodule at '$gnulib_path'. 4573require_gnulib_submodule=func_require_gnulib_submodule 4574func_require_gnulib_submodule () 4575{ 4576 $debug_cmd 4577 4578 $require_git 4579 4580 if test true = "$GIT"; then 4581 func_warning recommend \ 4582 "No 'git' found; imported gnulib modules may be outdated." 4583 else 4584 $require_gnulib_path 4585 $require_gnulib_url 4586 4587 if test -f .gitmodules && test -f "$gnulib_path/gnulib-tool"; then 4588 : All present and correct. 4589 4590 elif test -n "$opt_gnulib_srcdir"; then 4591 # Older git can't clone into an empty directory. 4592 rmdir "$gnulib_path" 2>/dev/null 4593 func_show_eval "$GIT clone --reference '$opt_gnulib_srcdir' \ 4594 '$gnulib_url' '$gnulib_path'" \ 4595 || func_fatal_error "Unable to fetch gnulib submodule." 4596 4597 # Without --gnulib-srcdir, and no existing checked out submodule, we 4598 # create a new shallow clone of the remote gnulib repository. 4599 else 4600 trap func_cleanup_gnulib 1 2 13 15 4601 4602 shallow= 4603 $GIT clone -h 2>&1 |func_grep_q -- --depth \ 4604 && shallow='--depth 365' 4605 4606 func_show_eval "$GIT clone $shallow '$gnulib_url' '$gnulib_path'" \ 4607 func_cleanup_gnulib 4608 4609 # FIXME: Solaris /bin/sh will try to execute '-' if any of 4610 # these signals are caught after this. 4611 trap - 1 2 13 15 4612 fi 4613 4614 # Make sure we've checked out the correct revision of gnulib. 4615 func_show_eval "$GIT submodule init -- $gnulib_path" \ 4616 && func_show_eval "$GIT submodule update -- $gnulib_path" \ 4617 || func_fatal_error "Unable to update gnulib submodule." 4618 fi 4619 4620 require_gnulib_submodule=: 4621} 4622 4623 4624# require_gnulib_tool 4625# ------------------- 4626# Ensure that '$gnulib_tool' is set, and points to an executable file, 4627# or else fall back to using the binary 'true' if the main gnulib 4628# files appear to have been imported already. 4629require_gnulib_tool=func_require_gnulib_tool 4630func_require_gnulib_tool () 4631{ 4632 $debug_cmd 4633 4634 test true = "$gnulib_tool" || { 4635 $require_gnulib_submodule 4636 $require_gnulib_path 4637 4638 test -n "$gnulib_tool" \ 4639 || gnulib_tool=$gnulib_path/gnulib-tool 4640 4641 test -x "$gnulib_tool" || { 4642 gnulib_tool=true 4643 func_warning recommend \ 4644 "No 'gnulib-tool' found; gnulib modules may be missing." 4645 } 4646 4647 test true = "$gnulib_tool" \ 4648 || func_verbose "found '$gnulib_tool'" 4649 } 4650 4651 require_gnulib_tool=: 4652} 4653 4654 4655# require_gnulib_tool_base_options 4656# -------------------------------- 4657# Ensure that '$gnulib_tool_base_options' contains all the base options 4658# required according to user configuration from bootstrap.conf. 4659require_gnulib_tool_base_options=func_require_gnulib_tool_base_options 4660func_require_gnulib_tool_base_options () 4661{ 4662 $debug_cmd 4663 4664 $require_gnulib_tool 4665 4666 gnulib_tool_base_options= 4667 4668 test true = "$gnulib_tool" || { 4669 # 'gnulib_modules' and others are maintained in 'bootstrap.conf': 4670 # Use 'gnulib --import' to fetch gnulib modules. 4671 $require_build_aux 4672 test -n "$build_aux" \ 4673 && func_append_uniq gnulib_tool_base_options " --aux-dir=$build_aux" 4674 $require_macro_dir 4675 test -n "$macro_dir" \ 4676 && func_append_uniq gnulib_tool_base_options " --m4-base=$macro_dir" 4677 $require_doc_base 4678 test -n "$doc_base" \ 4679 && func_append_uniq gnulib_tool_base_options " --doc-base=$doc_base" 4680 $require_gnulib_name 4681 test -n "$gnulib_name" \ 4682 && func_append_uniq gnulib_tool_base_options " --lib=$gnulib_name" 4683 $require_local_gl_dir 4684 test -n "$local_gl_dir" \ 4685 && func_append_uniq gnulib_tool_base_options " --local-dir=$local_gl_dir" 4686 $require_source_base 4687 test -n "$source_base" \ 4688 && func_append_uniq gnulib_tool_base_options " --source-base=$source_base" 4689 } 4690 4691 require_gnulib_tool_base_options=: 4692} 4693 4694 4695# require_libtoolize 4696# ------------------ 4697# Skip libtoolize if it's not needed. 4698require_libtoolize=func_require_libtoolize 4699func_require_libtoolize () 4700{ 4701 $debug_cmd 4702 4703 # Unless we're not searching for libtool use by this package, set 4704 # LIBTOOLIZE to true if none of 'LT_INIT', 'AC_PROG_LIBTOOL' and 4705 # 'AM_PROG_LIBTOOL' are used in configure. 4706 test true = "$LIBTOOLIZE" || { 4707 func_extract_trace LT_INIT 4708 test -n "$func_extract_trace_result" || func_extract_trace AC_PROG_LIBTOOL 4709 test -n "$func_extract_trace_result" || func_extract_trace AM_PROG_LIBTOOL 4710 test -n "$func_extract_trace_result" || LIBTOOLIZE=true 4711 } 4712 4713 test -n "$LIBTOOLIZE" || { 4714 # Find libtoolize, named glibtoolize in Mac Ports, but prefer 4715 # user-installed libtoolize to ancient glibtoolize shipped by 4716 # Apple with Mac OS X when Mac Ports is not installed. 4717 func_find_tool LIBTOOLIZE libtoolize glibtoolize 4718 } 4719 4720 test -n "$LIBTOOLIZE" || func_fatal_error "\ 4721Please install GNU Libtool, or 'export LIBTOOLIZE=/path/to/libtoolize'." 4722 4723 func_verbose "export LIBTOOLIZE='$LIBTOOLIZE'" 4724 4725 # Make sure the search result is visible to subshells 4726 export LIBTOOLIZE 4727 4728 require_libtoolize=: 4729} 4730 4731 4732# require_local_gl_dir 4733# -------------------- 4734# Ensure local_gl_dir has a sensible value, extracted from 'gnulib-cache.m4' 4735# if possible, otherwise letting 'gnulib-tool' pick a default. 4736require_local_gl_dir=func_require_local_gl_dir 4737func_require_local_gl_dir () 4738{ 4739 $debug_cmd 4740 4741 $require_gnulib_cache 4742 4743 test -f "$gnulib_cache" && test -z "$local_gl_dir" && { 4744 func_extract_trace_first "gl_LOCAL_DIR" "$gnulib_cache" 4745 local_gl_dir=$func_extract_trace_first_result 4746 4747 test -n "$local_gl_dir" && func_verbose "local_gl_dir='$local_gl_dir'" 4748 } 4749 4750 require_local_gl_dir=: 4751} 4752 4753 4754# require_macro_dir 4755# ----------------- 4756# Ensure that '$macro_dir' is set, and if it doesn't already point to an 4757# existing directory, create one. 4758require_macro_dir=func_require_macro_dir 4759func_require_macro_dir () 4760{ 4761 $debug_cmd 4762 4763 # Sometimes this is stored in 'configure.ac'. 4764 test -n "$macro_dir" || { 4765 # AC_CONFIG_MACRO_DIRS takes a space delimited list of directories, 4766 # but we only care about the first one in bootstrap. 4767 func_extract_trace_first AC_CONFIG_MACRO_DIRS 4768 macro_dir=`expr "x$func_extract_trace_first_result" : 'x\([^ ]*\)'` 4769 } 4770 test -n "$macro_dir" || { 4771 func_extract_trace_first AC_CONFIG_MACRO_DIR 4772 macro_dir=$func_extract_trace_first_result 4773 } 4774 4775 # Otherwise we might find it in 'Makefile.am'. 4776 test -n "$macro_dir" || { 4777 $require_aclocal_amflags 4778 4779 # Take the argument following the first '-I', if any. 4780 _G_minus_I_seen=false 4781 for _G_arg in $aclocal_amflags; do 4782 case $_G_minus_I_seen,$_G_arg in 4783 :,*) macro_dir=$_G_arg; break ;; 4784 *,-I) _G_minus_I_seen=: ;; 4785 *,-I*) macro_dir=`expr x$_G_arg : 'x-I\(.*\)$'`; break ;; 4786 esac 4787 done 4788 } 4789 4790 func_verbose "macro_dir='$macro_dir'" 4791 4792 func_check_configuration macro_dir \ 4793 "AC_CONFIG_MACRO_DIRS([name of a directory for configure m4 files])" 4794 4795 $require_vc_ignore_files 4796 4797 # If the macro_dir directory doesn't exist, create it now, and mark it 4798 # as ignored for the VCS. 4799 if test ! -d "$macro_dir"; then 4800 mkdir "$macro_dir" || func_permissions_error "$macro_dir" 4801 4802 test -n "$vc_ignore_files" \ 4803 || func_insert_if_absent "$macro_dir" $vc_ignore_files 4804 fi 4805 4806 require_macro_dir=: 4807} 4808 4809 4810# require_makefile_am 4811# ------------------- 4812# Ensure there is a 'Makefile.am' in the current directory. 4813require_makefile_am=func_require_makefile_am 4814func_require_makefile_am () 4815{ 4816 $debug_cmd 4817 4818 test -n "$makefile_am" \ 4819 || makefile_am=Makefile.am 4820 4821 <"$makefile_am" 4822 4823 func_verbose "found '$makefile_am'" 4824 4825 require_makefile_am=: 4826} 4827 4828 4829# require_package 4830# --------------- 4831# Ensure that '$package' contains a sensible default value. 4832require_package=func_require_package 4833func_require_package () 4834{ 4835 $debug_cmd 4836 4837 test -n "$package" || { 4838 $require_package_name 4839 4840 package=`echo "$package_name" \ 4841 |$SED -e 's/GNU //' \ 4842 -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` 4843 } 4844 4845 func_verbose "package='$package'" 4846 4847 require_package=: 4848} 4849 4850 4851# require_package_bugreport 4852# ------------------------- 4853# Ensure that this has a sensible value, extracted from 'configure.ac' 4854# if appropriate (and possible!). 4855require_package_bugreport=func_require_package_bugreport 4856func_require_package_bugreport () 4857{ 4858 $debug_cmd 4859 4860 func_extract_trace AC_INIT 4861 4862 save_ifs=$IFS 4863 IFS=: 4864 set dummy $func_extract_trace_result 4865 IFS=$save_ifs 4866 shift 4867 4868 test -n "$package_bugreport" || package_bugreport=$3 4869 func_check_configuration package_bugreport \ 4870 "AC_INIT([$package_name], [$package_version], [bug-$package@gnu.org])" 4871 func_verbose "package_bugreport='$package_bugreport'" 4872 4873 require_package_bugreport=: 4874} 4875 4876 4877# require_package_name 4878# -------------------- 4879# Ensure that this has a sensible value, extracted from 'configure.ac' 4880# if appropriate (and possible!). 4881require_package_name=func_require_package_name 4882func_require_package_name () 4883{ 4884 $debug_cmd 4885 4886 func_extract_trace AC_INIT 4887 4888 save_ifs=$IFS 4889 IFS=: 4890 set dummy $func_extract_trace_result 4891 IFS=$save_ifs 4892 shift 4893 4894 test -n "$package_name" || package_name=$1 4895 func_check_configuration package_name \ 4896 "AC_INIT([name of your package], [package version number])" 4897 func_verbose "package_name='$package_name'" 4898 4899 require_package_name=: 4900} 4901 4902 4903# require_package_version 4904# ----------------------- 4905# Ensure that this has a sensible value, extracted from 'configure.ac' 4906# if appropriate (and possible!). While we might have set all the 4907# parameters extracted from AC_INIT at once, 'package_version' in 4908# particular is not necessarily available as early as the others, since 4909# 'git-version-gen' is often involved, and until then we can't rely on 4910# getting a correct version number from an AC_INIT extraction. 4911require_package_version=func_require_package_version 4912func_require_package_version () 4913{ 4914 $debug_cmd 4915 4916 func_extract_trace AC_INIT 4917 4918 save_ifs=$IFS 4919 IFS=: 4920 set dummy $func_extract_trace_result 4921 IFS=$save_ifs 4922 shift 4923 4924 test -n "$package_version" || package_version=$2 4925 test -n "$package_version" || { 4926 # The embedded echo is to squash whitespace before globbing. 4927 case " "`echo $gnulib_modules`" " in 4928 *" git-version-gen "*) 4929 func_fatal_error "\ 4930cannot \$require_package_version in bootstrap.conf before 4931func_gnulib_tool has installed the 'git-version-gen' script." 4932 ;; 4933 *) 4934 func_check_configuration package_version \ 4935 "AC_INIT([name of your package], [package version number])" 4936 ;; 4937 esac 4938 } 4939 func_verbose "package_version='$package_version'" 4940 4941 require_package_version=: 4942} 4943 4944 4945# require_patch 4946# ------------- 4947# Find patch, according to the PATCH environment variable, or else 4948# searching the user's PATH. 4949require_patch=func_require_patch 4950func_require_patch () 4951{ 4952 $debug_cmd 4953 4954 test -n "$PATCH" || { 4955 # Find a patch program, preferring gpatch, which is usually better 4956 # than the vendor patch. 4957 func_find_tool PATCH gpatch patch 4958 } 4959 4960 test -n "$PATCH" || func_fatal_error "\ 4961Please install GNU Patch, or 'export PATCH=/path/to/gnu/patch'." 4962 4963 func_verbose "export PATCH='$PATCH'" 4964 4965 # Make sure the search result is visible to subshells 4966 export PATCH 4967 4968 require_patch=: 4969} 4970 4971 4972# require_source_base 4973# ------------------- 4974# Ensure that source_base has a sensible value, extracted from 4975# 'gnulib-cache.m4' if possible. 4976require_source_base=func_require_source_base 4977func_require_source_base () 4978{ 4979 $debug_cmd 4980 4981 $require_gnulib_cache 4982 4983 test -f "$gnulib_cache" && test -z "$source_base" && { 4984 func_extract_trace_first "gl_SOURCE_BASE" "$gnulib_cache" 4985 4986 source_base=$func_extract_trace_first_result 4987 4988 func_verbose "source_base='$source_base'" 4989 } 4990 4991 require_source_base=: 4992} 4993 4994 4995# require_vc_ignore_files 4996# ----------------------- 4997# Ensure that '$vc_ignore' has been processed to list VCS ignore files 4998# in '$vc_ignore_files' 4999require_vc_ignore_files=func_require_vc_ignore_files 5000func_require_vc_ignore_files () 5001{ 5002 $debug_cmd 5003 5004 test -n "$vc_ignore" || vc_ignore=auto 5005 5006 if test auto = "$vc_ignore" && test -z "$vc_ignore_files"; then 5007 vc_ignore_files= 5008 test -d .git && vc_ignore_files=.gitignore 5009 test -d CVS && vc_ignore_files="$vc_ignore_files .cvsignore" 5010 else 5011 vc_ignore_files=$vc_ignore 5012 fi 5013 5014 func_verbose "vc_ignore_files='$vc_ignore_files'" 5015 5016 require_vc_ignore_files=: 5017} 5018 5019 5020## ----------------- ## 5021## Helper functions. ## 5022## ----------------- ## 5023 5024# This section contains the helper functions used by the rest of 'bootstrap'. 5025 5026# func_len STRING 5027# --------------- 5028# STRING may not start with a hyphen. 5029if (eval 'x=123; test x${#x} = "x3"') 2>/dev/null 5030then 5031 # This is an XSI compatible shell, allowing a faster implementation... 5032 eval 'func_len () 5033 { 5034 $debug_cmd 5035 5036 func_len_result=${#1} 5037 }' 5038else 5039 # ...otherwise fall back to using expr, which is often a shell builtin. 5040 func_len () 5041 { 5042 $debug_cmd 5043 5044 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo 0` 5045 } 5046fi 5047 5048 5049# func_unset VAR 5050# -------------- 5051# Portably unset VAR. 5052# In some shells, an 'unset VAR' statement leaves a non-zero return 5053# status if VAR is already unset, which might be problematic if the 5054# statement is used at the end of a function (thus poisoning its return 5055# value) or when 'set -e' is active (causing even a spurious abort of 5056# the script in this case). 5057func_unset () 5058{ 5059 { eval $1=; unset $1; } 5060} 5061unset=func_unset 5062 5063 5064# func_cmp_s FILE1 FILE2 5065# ---------------------- 5066# Return non-zero exit status unless FILE1 and FILE2 are identical, without 5067# any output at all, even error messages. 5068func_cmp_s () 5069{ 5070 $debug_cmd 5071 5072 # This function relies on non-zero exit status, which will cause the 5073 # program to exit when running in 'set -e' mode. 5074 $CMP "$@" >/dev/null 2>&1 5075} 5076 5077 5078# func_grep_q EXPRESSION [FILENAME..] 5079# ----------------------------------- 5080# Check whether EXPRESSION matches any line of any listed FILENAME, 5081# without any output at all, even error messages. 5082func_grep_q () 5083{ 5084 $debug_cmd 5085 5086 # This function relies on non-zero exit status, which will cause the 5087 # program to exit when running in 'set -e' mode. 5088 $GREP "$@" >/dev/null 2>&1 5089} 5090 5091 5092# func_ifcontains LIST MEMBER YES-CMD [NO-CMD] 5093# -------------------------------------------- 5094# If whitespace-separated LIST contains MEMBER then execute YES-CMD, 5095# otherwise if NO-CMD was given, execute that. 5096func_ifcontains () 5097{ 5098 $debug_cmd 5099 5100 _G_wslist=$1 5101 _G_member=$2 5102 _G_yes_cmd=$3 5103 _G_no_cmd=${4-":"} 5104 5105 _G_found=false 5106 for _G_item in $_G_wslist; do 5107 test "x$_G_item" = "x$_G_member" && { 5108 _G_found=: 5109 break 5110 } 5111 done 5112 if $_G_found; then 5113 eval "$_G_yes_cmd" 5114 _G_status=$? 5115 else 5116 eval "$_G_no_cmd" 5117 _G_status=$? 5118 fi 5119 5120 test 0 -eq "$_G_status" || exit $_G_status 5121} 5122 5123 5124# func_strpad STR WIDTH CHAR 5125# -------------------------- 5126# Trim STR, or pad with CHAR to force a total length of WIDTH. 5127func_strpad () 5128{ 5129 $debug_cmd 5130 5131 _G_width=`expr "$2" - 1` 5132 func_strpad_result=`$ECHO "$1" |$SED ' 5133 :a 5134 s|^.\{0,'"$_G_width"'\}$|&'"$3"'| 5135 ta 5136 '` 5137} 5138 5139 5140# func_strrpad STR WIDTH CHAR 5141# --------------------------- 5142# Trim STR, or right-justify-pad with CHAR to force a total length of 5143# WIDTH. 5144func_strrpad () 5145{ 5146 $debug_cmd 5147 5148 _G_width=`expr "$2" - 1` 5149 func_strrpad_result=`$ECHO "$1" |$SED ' 5150 :a 5151 s|^.\{0,'"$_G_width"'\}$|'"$3"'&| 5152 ta 5153 '` 5154} 5155 5156 5157# func_strrow INDENT FIELD WIDTH [FIELDn WIDTHn]... 5158# ------------------------------------------------- 5159# Return a string containing each FIELD left justified to WIDTH, with 5160# the whole thing indented by INDENT spaces. This function is used to 5161# render one row of aligned columns for a table by func_strtable(). 5162func_strrow () 5163{ 5164 $debug_cmd 5165 5166 func_strrow_linelen=$1; shift 5167 5168 _G_row= 5169 while test $# -gt 0; do 5170 func_strrow_linelen=`expr $func_strrow_linelen + $2` 5171 func_strpad "$1" $2 " " 5172 func_append _G_row "$func_strpad_result" 5173 shift; shift 5174 done 5175 5176 func_strrpad "$_G_row" $func_strrow_linelen " " 5177 func_strrow_result=$func_strrpad_result 5178} 5179 5180 5181# func_strtable INDENT WIDTH1...WIDTHn HEADER1...HEADERn FIELD1...FIELDn 5182# ---------------------------------------------------------------------- 5183# Generate a string of newline-separated rows arranged in lined-up 5184# columns of the given WIDTHs, with the entire table indented by INDENT 5185# spaces. The number of columns is determined by the number of integer 5186# valued WIDTH arguments following INDENT. The next set (i.e. a number 5187# of arguments equal to the number of WIDTH arguments) of fields are 5188# treated as the table's column HEADERs, and are separated from the 5189# remainder of the table by an indented row of '-' characters. Remaining 5190# arguments are each aligned below the next available header, wrapping 5191# to a new row as necessary. Finally another row of '-' characters is 5192# added to mark the end of the table. 5193# 5194# For example an unindented 3 column table with 2 rows of data would be 5195# generated by this call: 5196# 5197# func_strtable 3 20 10 25 \ 5198# Header1 Header2 Header3 \ 5199# Row1Col1 Row1Col2 Row1Col3 \ 5200# Row2Col1 Row2Col2 Row2Col3 5201# 5202# returning the following string: 5203# 5204# " Header1 Header2 Header3 5205# ------------------------------------------------------- 5206# Row1Col1 Row1Col2 Row1Col3 5207# Row2Col1 Row2Col2 Row2Col3 5208# -------------------------------------------------------" 5209func_strtable () 5210{ 5211 $debug_cmd 5212 5213 # Save the indent value, we'll need it for each row we render. 5214 _G_indent=$1; shift 5215 5216 # Collect remaining numeric args into a list for reuse between 5217 # members of each row when we call func_strrow later. 5218 _G_widths=$1; shift 5219 while test 0 -lt `expr "$1" : '[1-9][0-9]*$'`; do 5220 func_append _G_widths " $1"; shift 5221 done 5222 5223 # Extract the same number of positional parameters as there are 5224 # width elements - we'll do the header rows separately so that 5225 # we can insert a divider line. 5226 _G_header=$_G_indent 5227 for _G_width in $_G_widths; do 5228 func_append _G_header " $1 $_G_width"; shift 5229 done 5230 func_strrow $_G_header 5231 5232 # Strip off the indent, and make a divider with '-' chars, then 5233 # reindent. 5234 _G_divider=`$ECHO "$func_strrow_result" \ 5235 |$SED 's|[^ ]|-|g 5236 :a 5237 s|- |--|g 5238 ta 5239 '` 5240 5241 # Append the header and divider to the running result. 5242 func_append func_strtable_result "\ 5243$func_strrow_result 5244$_G_divider 5245" 5246 5247 # The remaining rows are zipped between the width values we 5248 # unwound earlier just like the header row above. 5249 while test $# -gt 0; do 5250 _G_row=$_G_indent 5251 for _G_width in $_G_widths; do 5252 func_append _G_row " $1 $_G_width"; shift 5253 done 5254 func_strrow $_G_row 5255 func_append func_strtable_result "\ 5256$func_strrow_result 5257" 5258 done 5259 5260 # Mark the end of the table with a final divider line. 5261 func_append func_strtable_result "$_G_divider" 5262} 5263 5264 5265# func_internal_error ARG... 5266# -------------------------- 5267# Echo program name prefixed message to standard error, and exit. 5268func_internal_error () 5269{ 5270 func_fatal_error "\ 5271INTERNAL: " ${1+"$@"} " 5272 Please report this bug to 'bug-gnulib@gnu.org' 5273 in as much detail as possible." 5274} 5275 5276 5277# func_permissions_error FILE-OR-DIRECTORY 5278# ---------------------------------------- 5279# Echo program name prefixed permissions error message to standard 5280# error, and exit. 5281func_permissions_error () 5282{ 5283 $debug_cmd 5284 5285 func_fatal_error "Failed to create '$1', check permissions." 5286} 5287 5288 5289# func_show_eval CMD [FAIL_EXP] 5290# ----------------------------- 5291# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 5292# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 5293# is given, then evaluate it. 5294func_show_eval () 5295{ 5296 $debug_cmd 5297 5298 $require_term_colors 5299 5300 _G_cmd=$1 5301 _G_fail_exp=${2-':'} 5302 5303 ${opt_silent-'false'} || { 5304 func_quote_for_eval $_G_cmd 5305 eval func_truncate_cmd $func_quote_for_eval_result 5306 func_echo "running: $tc_bold$func_truncate_cmd_result$tc_reset" 5307 } 5308 5309 ${opt_dry_run-'false'} || { 5310 eval "$_G_cmd" 5311 _G_status=$? 5312 test 0 -eq "$_G_status" || eval "(exit $_G_status); $_G_fail_exp" 5313 } 5314} 5315 5316 5317# func_truncate_cmd CMD [ARG]... 5318# ------------------------------ 5319# For unreasonably long commands (such as a gnulib-tool invocation with 5320# the full module list for import), truncate CMD after the second non- 5321# option ARG. 5322func_truncate_cmd () 5323{ 5324 $debug_cmd 5325 5326 _G_last_arg_opt_p=false 5327 func_truncate_cmd_result= 5328 5329 set dummy "$@"; shift 5330 5331 while test $# -gt 0; do 5332 _G_opt=$1; shift 5333 5334 test -n "$func_truncate_cmd_result" \ 5335 && func_append func_truncate_cmd_result ' ' 5336 func_append func_truncate_cmd_result "$_G_opt" 5337 5338 func_len "x$func_truncate_cmd_result" 5339 5340 case $_G_opt in 5341 -*) _G_last_arg_opt_p=: ;; 5342 *) $_G_last_arg_opt_p \ 5343 || test "$min_cmd_len" -gt "$func_len_result" \ 5344 || break 5345 _G_last_arg_opt_p=false 5346 ;; 5347 esac 5348 done 5349 5350 test $# -gt 0 && func_append func_truncate_cmd_result "..." 5351} 5352 5353 5354# func_gitignore_entries FILE... 5355# ------------------------------ 5356# Strip blank and comment lines to leave significant entries. 5357func_gitignore_entries () 5358{ 5359 $debug_cmd 5360 5361 $SED -e '/^#/d' -e '/^$/d' "$@" 5362} 5363 5364 5365# func_insert_if_absent STR FILE... 5366# --------------------------------- 5367# If $STR is not already on a line by itself in $FILE, insert it, at the 5368# start. Entries are inserted at the start of the ignore list to ensure 5369# existing entries starting with ! are not overridden. Such entries 5370# support whilelisting exceptions after a more generic blacklist pattern. 5371# sorting the new contents of the file and replacing $FILE with the result. 5372func_insert_if_absent () 5373{ 5374 $debug_cmd 5375 5376 str=$1 5377 shift 5378 5379 for file 5380 do 5381 test -f "$file" || touch "$file" 5382 5383 duplicate_entries=`func_gitignore_entries "$file" |sort |uniq -d` 5384 test -n "$duplicate_entries" \ 5385 && func_error "duplicate entries in $file: " $duplicate_entries 5386 5387 func_grep_q "^$str\$" "$file" \ 5388 || func_verbose "inserting '$str' into '$file'" 5389 5390 linesold=`func_gitignore_entries "$file" |wc -l` 5391 linesnew=`{ $ECHO "$str"; cat "$file"; } \ 5392 |func_gitignore_entries |sort -u |wc -l` 5393 test "$linesold" -eq "$linesnew" \ 5394 || { $SED "1i\\$nl$str$nl" "$file" >"$file"T && mv "$file"T "$file"; } \ 5395 || func_permissions_error "$file" 5396 done 5397} 5398 5399 5400# func_get_version APP 5401# -------------------- 5402# echo the version number (if any) of APP, which is looked up along your 5403# PATH. 5404func_get_version () 5405{ 5406 $debug_cmd 5407 5408 _G_app=$1 5409 5410 # Rather than uncomment the sed script in-situ, strip the comments 5411 # programatically before passing the result to $SED for evaluation. 5412 sed_get_version=`$ECHO '# extract version within line 5413 s|.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1| 5414 t done 5415 5416 # extract version at start of line 5417 s|^\([0-9]\{1,\}\.[.a-z0-9-]*\).*|\1| 5418 t done 5419 5420 d 5421 5422 :done 5423 # the following essentially does s|5.005|5.5| 5424 s|\.0*\([1-9]\)|.\1|g 5425 p 5426 q' \ 5427 |$SED '/^[ ]*#.*$/d'` 5428 5429 func_tool_version_output $_G_app >/dev/null 5430 _G_status=$? 5431 5432 test 0 -ne "$_G_status" \ 5433 || $_G_app --version 2>&1 |$SED -n "$sed_get_version" 5434 5435 (exit $_G_status) 5436} 5437 5438 5439# func_check_tool APP 5440# ------------------- 5441# Search PATH for an executable at APP. 5442func_check_tool () 5443{ 5444 $debug_cmd 5445 5446 func_check_tool_result= 5447 5448 case $1 in 5449 *[\\/]*) 5450 test -x "$1" && func_check_tool_result=$1 5451 ;; 5452 *) 5453 save_IFS=$IFS 5454 IFS=${PATH_SEPARATOR-:} 5455 for _G_check_tool_path in $PATH; do 5456 IFS=$save_IFS 5457 if test -x "$_G_check_tool_path/$1"; then 5458 func_check_tool_result=$_G_check_tool_path/$1 5459 break 5460 fi 5461 done 5462 IFS=$save_IFS 5463 ;; 5464 esac 5465} 5466 5467 5468# func_check_versions APP1 VER1 URL1 ...[APPN VERN URLN] 5469# ------------------------------------------------------ 5470func_check_versions () 5471{ 5472 $debug_cmd 5473 5474 func_check_versions_result=: 5475 5476 while test $# -gt 0; do 5477 _G_app=$1; shift 5478 _G_reqver=$1; shift 5479 _G_url=$1; shift 5480 5481 # Diagnose bad buildreq formatting. 5482 case $_G_url in 5483 [a-z]*://*) ;; # looks like a url 5484 *) func_fatal_error "\ 5485'$_G_url' from the buildreq table in 5486'bootstrap.conf' does not look like the URL for downloading 5487$_G_app. Please ensure that buildreq is a strict newline 5488delimited list of triples; 'program min-version url'." 5489 ;; 5490 esac 5491 5492 # Honor $APP variables ($TAR, $AUTOCONF, etc.) 5493 _G_appvar=`echo $_G_app |tr '[a-z]' '[A-Z]'` 5494 test TAR = "$_G_appvar" && _G_appvar=AMTAR 5495 eval "_G_app=\${$_G_appvar-$_G_app}" 5496 5497 # Fail if no version specified, but the program can't be found. 5498 if test x- = "x$_G_reqver"; then 5499 func_check_tool $_G_app 5500 if test -z "$func_check_tool_result"; then 5501 func_error "Prerequisite '$_G_app' not not found. Please install it, or 5502'export $_G_appvar=/path/to/$_G_app'." 5503 func_check_versions_result=false 5504 else 5505 func_verbose "found '$func_check_tool_result' for $_G_appvar." 5506 fi 5507 else 5508 _G_instver=`func_get_version $_G_app` 5509 5510 # Fail if --version didn't work. 5511 if test -z "$_G_instver"; then 5512 func_error "Prerequisite '$_G_app' not found. Please install it, or 5513'export $_G_appvar=/path/to/$_G_app'." 5514 func_check_versions_result=false 5515 5516 # Fail if a newer version than what we have is required. 5517 else 5518 func_verbose "found '$_G_app' version $_G_instver." 5519 5520 case $_G_reqver in 5521 =*) 5522 # If $buildreq version starts with '=', version must 5523 # match the installed program exactly. 5524 test "x$_G_reqver" = "x=$_G_instver" || { 5525 func_error "\ 5526 '$_G_app' version == $_G_instver is too old 5527 'exactly $_G_app-$_G_reqver is required" 5528 func_check_versions_result=false 5529 } 5530 ;; 5531 *) 5532 # Otherwise, anything that is not older is a match. 5533 func_lt_ver "$_G_reqver" "$_G_instver" || { 5534 func_error "\ 5535 '$_G_app' version == $_G_instver is too old 5536 '$_G_app' version >= $_G_reqver is required" 5537 func_check_versions_result=false 5538 } 5539 ;; 5540 esac 5541 fi 5542 fi 5543 done 5544} 5545 5546 5547# func_cleanup_gnulib 5548# ------------------- 5549# Recursively delete everything below the path in the global variable 5550# GNULIB_PATH. 5551func_cleanup_gnulib () 5552{ 5553 $debug_cmd 5554 5555 _G_status=$? 5556 $RM -fr "$gnulib_path" 5557 exit $_G_status 5558} 5559 5560 5561# func_download_po_files SUBDIR DOMAIN 5562# ------------------------------------ 5563func_download_po_files () 5564{ 5565 $debug_cmd 5566 5567 func_echo "getting translations into $1 for $2..." 5568 _G_cmd=`printf "$po_download_command_format" "$2" "$1"` 5569 eval "$_G_cmd" 5570} 5571 5572 5573# func_update_po_files PO_DIR DOMAIN 5574# ---------------------------------- 5575# Mirror .po files to $po_dir/.reference and copy only the new 5576# or modified ones into $po_dir. Also update $po_dir/LINGUAS. 5577# Note po files that exist locally only are left in $po_dir but will 5578# not be included in LINGUAS and hence will not be distributed. 5579func_update_po_files () 5580{ 5581 $debug_cmd 5582 5583 # Directory containing primary .po files. 5584 # Overwrite them only when we're sure a .po file is new. 5585 _G_po_dir=$1 5586 _G_domain=$2 5587 5588 # Mirror *.po files into this dir. 5589 # Usually contains *.s1 checksum files. 5590 _G_ref_po_dir=$_G_po_dir/.reference 5591 5592 test -d "$_G_ref_po_dir" || mkdir $_G_ref_po_dir || return 5593 func_download_po_files $_G_ref_po_dir $_G_domain \ 5594 && ls "$_G_ref_po_dir"/*.po 2>/dev/null \ 5595 |$SED -e 's|.*/||' -e 's|\.po$||' > "$_G_po_dir/LINGUAS" || return 5596 5597 # Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6+. 5598 func_find_tool SHA1SUM sha1sum gsha1sum shasum sha1 5599 5600 test -n "$SHA1SUM" || func_fatal_error "\ 5601Please install GNU Coreutils, or 'export SHA1SUM=/path/to/sha1sum'." 5602 5603 _G_langs=`cd $_G_ref_po_dir && echo *.po|$SED 's|\.po||g'` 5604 test '*' = "$_G_langs" && _G_langs=x 5605 for _G_po in $_G_langs; do 5606 case $_G_po in x) continue;; esac 5607 _G_new_po=$_G_ref_po_dir/$_G_po.po 5608 _G_cksum_file=$_G_ref_po_dir/$_G_po.s1 5609 if ! test -f "$_G_cksum_file" || 5610 ! test -f "$_G_po_dir/$_G_po.po" || 5611 ! $SHA1SUM -c "$_G_cksum_file" \ 5612 < "$_G_new_po" > /dev/null; then 5613 echo "updated $_G_po_dir/$_G_po.po..." 5614 cp "$_G_new_po" "$_G_po_dir/$_G_po.po" \ 5615 && $SHA1SUM < "$_G_new_po" > "$_G_cksum_file" || return 5616 fi 5617 done 5618} 5619 5620 5621 5622## --------------- ## 5623## Option parsing. ## 5624## --------------- ## 5625 5626# Hook in the functions to make sure our own options are parsed during 5627# the option parsing loop. 5628 5629usage='$progpath [OPTION]...' 5630 5631# Short help message in response to '-h'. Add to this in 'bootstrap.conf' 5632# if you accept any additional options. 5633usage_message="Common Bootstrap Options: 5634 -c, --copy copy files instead of creating symbolic links. 5635 --debug enable verbose shell tracing 5636 -n, --dry-run print commands rather than running them 5637 -f, --force attempt to bootstrap even if the sources seem not 5638 to have been checked out. 5639 --gnulib-srcdir=DIRNAME 5640 specify a local directory where gnulib sources 5641 reside. Use this if you already have the gnulib 5642 sources on your machine, and don't want to waste 5643 your bandwidth downloading them again. Defaults to 5644 \$GNULIB_SRCDIR. 5645 --no-warnings equivalent to '-Wnone' 5646 --skip-git do not fetch files from remote repositories 5647 --skip-po do not download po files. 5648 -v, --verbose verbosely report processing 5649 --version print version information and exit 5650 -W, --warnings=CATEGORY 5651 report the warnings falling in CATEGORY [all] 5652 -h, --help print short or long help message and exit 5653" 5654 5655# Additional text appended to 'usage_message' in response to '--help'. 5656long_help_message=$long_help_message" 5657 'recommend' show warnings about missing recommended packages 5658 'settings' show warnings about missing '$progname.conf' settings 5659 'upgrade' show warnings about out-dated files 5660 5661If the file '$progname.conf' exists in the same directory as this 5662script, its contents are read as shell variables to configure the 5663bootstrap. 5664 5665For build prerequisites, environment variables like \$AUTOCONF and 5666\$AMTAR are honored. 5667 5668Running without arguments will suffice in most cases. 5669" 5670 5671# Warning categories used by 'bootstrap', append others if you use them 5672# in your 'bootstrap.conf'. 5673warning_categories='recommend settings upgrade' 5674 5675 5676# bootstrap_options_prep [ARG]... 5677# ------------------------------- 5678# Preparation for options parsed by Bootstrap. 5679bootstrap_options_prep () 5680{ 5681 $debug_cmd 5682 5683 # Option defaults: 5684 opt_copy=${copy-'false'} 5685 opt_dry_run=false 5686 opt_force=false 5687 opt_gnulib_srcdir=$GNULIB_SRCDIR 5688 opt_skip_git=false 5689 opt_skip_po=false 5690 5691 # Pass back the list of options we consumed. 5692 func_quote_for_eval ${1+"$@"} 5693 bootstrap_options_prep_result=$func_quote_for_eval_result 5694} 5695func_add_hook func_options_prep bootstrap_options_prep 5696 5697 5698# bootstrap_parse_options [ARG]... 5699# -------------------------------- 5700# Provide handling for Bootstrap specific options. 5701bootstrap_parse_options () 5702{ 5703 $debug_cmd 5704 5705 # Perform our own loop to consume as many options as possible in 5706 # each iteration. 5707 while test $# -gt 0; do 5708 _G_opt=$1 5709 shift 5710 case $_G_opt in 5711 --dry-run|--dryrun|-n) 5712 opt_dry_run=: ;; 5713 --copy|-c) opt_copy=: ;; 5714 --force|-f) opt_force=: ;; 5715 5716 --gnulib-srcdir) 5717 test $# = 0 && func_missing_arg $_G_opt && break 5718 opt_gnulib_srcdir=$1 5719 shift 5720 ;; 5721 5722 --skip-git|--no-git) 5723 opt_skip_git=: 5724 ;; 5725 5726 --skip-po|--no-po) 5727 opt_skip_po=: 5728 ;; 5729 5730 # Separate non-argument short options: 5731 -c*|-f*|-n*) 5732 func_split_short_opt "$_G_opt" 5733 set dummy "$func_split_short_opt_name" \ 5734 "-$func_split_short_opt_arg" ${1+"$@"} 5735 shift 5736 ;; 5737 5738 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 5739 esac 5740 done 5741 5742 # save modified positional parameters for caller 5743 func_quote_for_eval ${1+"$@"} 5744 bootstrap_parse_options_result=$func_quote_for_eval_result 5745} 5746func_add_hook func_parse_options bootstrap_parse_options 5747 5748 5749# bootstrap_validate_options [ARG]... 5750# ----------------------------------- 5751# Perform any sanity checks on option settings and/or unconsumed 5752# arguments. 5753bootstrap_validate_options () 5754{ 5755 $debug_cmd 5756 5757 # Validate options. 5758 test $# -gt 0 \ 5759 && func_fatal_help "too many arguments" 5760 5761 # Pass back the (empty) list of unconsumed options. 5762 func_quote_for_eval ${1+"$@"} 5763 bootstrap_validate_options_result=$func_quote_for_eval_result 5764} 5765func_add_hook func_validate_options bootstrap_validate_options 5766 5767 5768## -------------------------------------------------- ## 5769## Source package customisations in 'bootstrap.conf'. ## 5770## -------------------------------------------------- ## 5771 5772# Override the default configuration, if necessary. 5773# Make sure that bootstrap.conf is sourced from the current directory 5774# if we were invoked as "sh bootstrap". 5775case $0 in 5776 */*) test -r "$0.conf" && . "$0.conf" ;; 5777 *) test -r "$0.conf" && . ./"$0.conf" ;; 5778esac 5779 5780 5781## ------------------------------- ## 5782## Actually perform the bootstrap. ## 5783## ------------------------------- ## 5784 5785func_bootstrap ${1+"$@"} 5786 5787# The End. 5788exit ${exit_status-$EXIT_SUCCESS} 5789 5790# Local variables: 5791# mode: shell-script 5792# sh-indentation: 2 5793# eval: (add-hook 'before-save-hook 'time-stamp) 5794# time-stamp-pattern: "500/scriptversion=%:y-%02m-%02d.%02H; # UTC" 5795# time-stamp-time-zone: "UTC" 5796# End: 5797