tail: honor --pid with fifos
[coreutils.git] / bootstrap
bloba0af39c2eb2f5d33e28a1bbf2cf6ae10b34c2fea
1 #! /bin/sh
2 # DO NOT EDIT! GENERATED AUTOMATICALLY!
4 # Bootstrap this package from checked-out sources.
6 scriptversion=2024-07-04.10; # UTC
8 # Copyright (C) 2003-2025 Free Software Foundation, Inc.
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <https://www.gnu.org/licenses/>.
23 # Originally written by Paul Eggert. The canonical version of this
24 # script is maintained as top/bootstrap in gnulib. However, to be
25 # useful to your package, you should place a copy of it under version
26 # control in the top-level directory of your package. The intent is
27 # that all customization can be done with a bootstrap.conf file also
28 # maintained in your version control; gnulib comes with a template
29 # build-aux/bootstrap.conf to get you started.
31 # Please report bugs or propose patches to bug-gnulib@gnu.org.
33 me="$0"
34 medir=`dirname "$me"`
36 # Read the function library and the configuration.
38 # A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
40 scriptlibversion=2024-11-12.21; # UTC
42 # Copyright (C) 2003-2025 Free Software Foundation, Inc.
44 # This program is free software: you can redistribute it and/or modify
45 # it under the terms of the GNU General Public License as published by
46 # the Free Software Foundation, either version 3 of the License, or
47 # (at your option) any later version.
49 # This program is distributed in the hope that it will be useful,
50 # but WITHOUT ANY WARRANTY; without even the implied warranty of
51 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52 # GNU General Public License for more details.
54 # You should have received a copy of the GNU General Public License
55 # along with this program. If not, see <https://www.gnu.org/licenses/>.
57 # Originally written by Paul Eggert. The canonical version of this
58 # script is maintained as top/bootstrap-funclib.sh in gnulib. However,
59 # to be useful to your package, you should place a copy of it under
60 # version control in the top-level directory of your package. The
61 # intent is that all customization can be done with a bootstrap.conf
62 # file also maintained in your version control; gnulib comes with a
63 # template build-aux/bootstrap.conf to get you started.
65 nl='
68 # Ensure file names are sorted consistently across platforms.
69 LC_ALL=C
70 export LC_ALL
72 # Honor $PERL, but work even if there is none.
73 PERL="${PERL-perl}"
75 default_gnulib_url=https://git.savannah.gnu.org/git/gnulib.git
77 # Copyright year, for the --version output.
78 copyright_year=`echo "$scriptlibversion" | sed -e 's/[^0-9].*//'`
79 copyright="Copyright (C) ${copyright_year} Free Software Foundation, Inc.
80 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
81 This is free software: you are free to change and redistribute it.
82 There is NO WARRANTY, to the extent permitted by law."
84 # warnf_ FORMAT-STRING ARG1...
85 warnf_ ()
87 warnf_format_=$1
88 shift
89 nl='
91 case $* in
92 *$nl*) me_=$(printf "$me"|tr "$nl|" '??')
93 printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
94 *) printf "$me: $warnf_format_" "$@" ;;
95 esac >&2
98 # warn_ WORD1...
99 warn_ ()
101 # If IFS does not start with ' ', set it and emit the warning in a subshell.
102 case $IFS in
103 ' '*) warnf_ '%s\n' "$*";;
104 *) (IFS=' '; warn_ "$@");;
105 esac
108 # die WORD1...
109 die() { warn_ "$@"; exit 1; }
111 # ------------------------------ Configuration. ------------------------------
113 # Directory that contains package-specific gnulib modules and/or overrides.
114 local_gl_dir=gl
116 # Name of the Makefile.am
117 # XXX Not used.
118 gnulib_mk=gnulib.mk
120 # List of gnulib modules needed.
121 gnulib_modules=
123 # Any gnulib files needed that are not in modules.
124 gnulib_files=
126 # A function to be called for each unrecognized option. Returns 0 if
127 # the option in $1 has been processed by the function. Returns 1 if
128 # the option has not been processed by the function. Override it via
129 # your own definition in bootstrap.conf
130 bootstrap_option_hook() { return 1; }
132 # A function to be called in order to print the --help information
133 # corresponding to user-defined command-line options.
134 bootstrap_print_option_usage_hook() { :; }
136 # A function to be called at the end of autopull.sh.
137 # Override it via your own definition in bootstrap.conf.
138 bootstrap_post_pull_hook() { :; }
140 # A function to be called right after gnulib-tool is run.
141 # Override it via your own definition in bootstrap.conf.
142 bootstrap_post_import_hook() { :; }
144 # A function to be called after everything else in this script.
145 # Override it via your own definition in bootstrap.conf.
146 bootstrap_epilogue() { :; }
148 # The command to download all .po files for a specified domain into a
149 # specified directory. Fill in the first %s with the destination
150 # directory and the second with the domain name.
151 po_download_command_format=\
152 "wget --mirror --level=1 -nd -nv -A.po -P '%s' \
153 https://translationproject.org/latest/%s/"
155 # Prefer a non-empty tarname (4th argument of AC_INIT if given), else
156 # fall back to the package name (1st argument with munging).
157 extract_package_name='
158 /^AC_INIT(\[*/{
159 s///
160 /^[^,]*,[^,]*,[^,]*,[ []*\([^][ ,)]\)/{
161 s//\1/
162 s/[],)].*//
166 s/[],)].*//
167 s/^GNU //
168 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
169 s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
173 package=$(${AUTOCONF:-autoconf} --trace AC_INIT:\$4 configure.ac 2>/dev/null)
174 if test -z "$package"; then
175 package=$(sed -n "$extract_package_name" configure.ac) \
176 || die 'cannot find package name in configure.ac'
178 gnulib_name=lib$package
180 build_aux=build-aux
181 source_base=lib
182 m4_base=m4
183 doc_base=doc
184 tests_base=tests
185 gnulib_extra_files="
186 build-aux/install-sh
187 build-aux/mdate-sh
188 build-aux/texinfo.tex
189 build-aux/depcomp
190 build-aux/config.guess
191 build-aux/config.sub
192 doc/INSTALL
195 # Additional gnulib-tool options to use. Use "\newline" to break lines.
196 gnulib_tool_option_extras=
198 # Other locale categories that need message catalogs.
199 EXTRA_LOCALE_CATEGORIES=
201 # Additional xgettext options to use. Use "\\\newline" to break lines.
202 XGETTEXT_OPTIONS='\\\
203 --flag=_:1:pass-c-format\\\
204 --flag=N_:1:pass-c-format\\\
205 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
208 # Package bug report address and copyright holder for gettext files
209 COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
210 MSGID_BUGS_ADDRESS=bug-$package@gnu.org
212 # Files we don't want to import.
213 # XXX Not used.
214 excluded_files=
216 # File that should exist in the top directory of a checked out hierarchy,
217 # but not in a distribution tarball.
218 checkout_only_file=README-hacking
220 # Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
221 # those files to be generated in directories like lib/, m4/, and po/.
222 # Or set it to 'auto' to make this script select which to use based
223 # on which version control system (if any) is used in the source directory.
224 vc_ignore=auto
226 # Set this to true in bootstrap.conf to enable --bootstrap-sync by
227 # default.
228 bootstrap_sync=false
230 # Override the default configuration, if necessary.
231 # Make sure that bootstrap.conf is sourced from the current directory
232 # if we were invoked as "sh bootstrap".
233 conffile=`dirname "$me"`/bootstrap.conf
234 test -r "$conffile" && . "$conffile"
236 # ------------------------- Build-time prerequisites -------------------------
238 check_exists() {
239 if test "$1" = "--verbose"; then
240 ($2 --version </dev/null) >/dev/null 2>&1
241 if test $? -ge 126; then
242 # If not found, run with diagnostics as one may be
243 # presented with env variables to set to find the right version
244 ($2 --version </dev/null)
246 else
247 ($1 --version </dev/null) >/dev/null 2>&1
250 test $? -lt 126
253 # Note this deviates from the version comparison in automake
254 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
255 # but this should suffice as we won't be specifying old
256 # version formats or redundant trailing .0 in bootstrap.conf.
257 # If we did want full compatibility then we should probably
258 # use m4_version_compare from autoconf.
259 sort_ver() { # sort -V is not generally available
260 ver1="$1"
261 ver2="$2"
263 # split on '.' and compare each component
265 while : ; do
266 p1=$(echo "$ver1" | cut -d. -f$i)
267 p2=$(echo "$ver2" | cut -d. -f$i)
268 if [ ! "$p1" ]; then
269 echo "$1 $2"
270 break
271 elif [ ! "$p2" ]; then
272 echo "$2 $1"
273 break
274 elif [ ! "$p1" = "$p2" ]; then
275 if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
276 echo "$2 $1"
277 elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
278 echo "$1 $2"
279 else # numeric, then lexicographic comparison
280 lp=$(printf "%s\n%s\n" "$p1" "$p2" | LANG=C sort -n | tail -n1)
281 if [ "$lp" = "$p2" ]; then
282 echo "$1 $2"
283 else
284 echo "$2 $1"
287 break
289 i=$(($i+1))
290 done
293 get_version_sed='
294 # Move version to start of line.
295 s/.*[v ]\([0-9]\)/\1/
297 # Skip lines that do not start with version.
298 /^[0-9]/!d
300 # Remove characters after the version.
301 s/[^.a-z0-9-].*//
303 # The first component must be digits only.
304 s/^\([0-9]*\)[a-z-].*/\1/
306 #the following essentially does s/5.005/5.5/
307 s/\.0*\([1-9]\)/.\1/g
311 get_version() {
312 app=$1
314 $app --version >/dev/null 2>&1 || { $app --version; return 1; }
316 $app --version 2>&1 | sed -n "$get_version_sed"
319 check_versions() {
320 ret=0
322 while read app req_ver; do
323 # We only need libtoolize from the libtool package.
324 if test "$app" = libtool; then
325 app=libtoolize
327 # Exempt git if git is not needed.
328 if test "$app" = git; then
329 $check_git || continue
331 # Honor $APP variables ($TAR, $AUTOCONF, etc.)
332 appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_')
333 test "$appvar" = TAR && appvar=AMTAR
334 case $appvar in
335 GZIP) ;; # Do not use $GZIP: it contains gzip options.
336 PERL::*) ;; # Keep perl modules as-is
337 *) eval "app=\${$appvar-$app}" ;;
338 esac
340 # Handle the still-experimental Automake-NG programs specially.
341 # They remain named as the mainstream Automake programs ("automake",
342 # and "aclocal") to avoid gratuitous incompatibilities with
343 # preexisting usages (by, say, autoreconf, or custom autogen.sh
344 # scripts), but correctly identify themselves (as being part of
345 # "GNU automake-ng") when asked their version.
346 case $app in
347 automake-ng|aclocal-ng)
348 app=${app%-ng}
349 ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
350 warn_ "Error: '$app' not found or not from Automake-NG"
351 ret=1
352 continue
353 } ;;
354 # Another check is for perl modules. These can be written as
355 # e.g. perl::XML::XPath in case of XML::XPath module, etc.
356 perl::*)
357 # Extract module name
358 app="${app#perl::}"
359 if ! $PERL -m"$app" -e 'exit 0' >/dev/null 2>&1; then
360 warn_ "Error: perl module '$app' not found"
361 ret=1
363 continue
365 esac
366 if [ "$req_ver" = "-" ]; then
367 # Merely require app to exist; not all prereq apps are well-behaved
368 # so we have to rely on $? rather than get_version.
369 if ! check_exists --verbose $app; then
370 warn_ "Error: '$app' not found"
371 ret=1
373 else
374 # Require app to produce a new enough version string.
375 inst_ver=$(get_version $app)
376 if [ ! "$inst_ver" ]; then
377 warn_ "Error: '$app' not found"
378 ret=1
379 else
380 latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
381 if [ ! "$latest_ver" = "$inst_ver" ]; then
382 warnf_ '%s\n' \
383 "Error: '$app' version == $inst_ver is too old" \
384 " '$app' version >= $req_ver is required"
385 ret=1
389 done
391 return $ret
394 print_versions() {
395 echo "Program Min_version"
396 echo "----------------------"
397 printf %s "$buildreq"
398 echo "----------------------"
399 # can't depend on column -t
402 # check_build_prerequisites check_git
403 check_build_prerequisites()
405 check_git="$1"
407 # gnulib-tool requires at least automake and autoconf.
408 # If either is not listed, add it (with minimum version) as a prerequisite.
409 case $buildreq in
410 *automake*) ;;
411 *) buildreq="automake 1.9
412 $buildreq" ;;
413 esac
414 case $buildreq in
415 *autoconf*) ;;
416 *) buildreq="autoconf 2.59
417 $buildreq" ;;
418 esac
420 # When we can deduce that gnulib-tool will require patch,
421 # and when patch is not already listed as a prerequisite, add it, too.
422 if test -d "$local_gl_dir" \
423 && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then
424 case $buildreq in
425 *patch*) ;;
426 *) buildreq="patch -
427 $buildreq" ;;
428 esac
431 if ! printf '%s' "$buildreq" | check_versions; then
432 echo >&2
433 if test -f README-prereq; then
434 die "See README-prereq for how to get the prerequisite programs"
435 else
436 die "Please install the prerequisite programs"
440 # Warn the user if autom4te appears to be broken; this causes known
441 # issues with at least gettext 0.18.3.
442 probe=$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -)
443 if test "x$probe" != xhi; then
444 warn_ "WARNING: your autom4te wrapper eats stdin;"
445 warn_ "if bootstrap fails, consider upgrading your autotools"
449 # find_tool ENVVAR NAMES...
450 # -------------------------
451 # Search for a required program. Use the value of ENVVAR, if set,
452 # otherwise find the first of the NAMES that can be run.
453 # If found, set ENVVAR to the program name, die otherwise.
455 # FIXME: code duplication, see also gnu-web-doc-update.
456 find_tool ()
458 find_tool_envvar=$1
459 shift
460 find_tool_names=$@
461 eval "find_tool_res=\$$find_tool_envvar"
462 if test x"$find_tool_res" = x; then
463 for i; do
464 if check_exists $i; then
465 find_tool_res=$i
466 break
468 done
470 if test x"$find_tool_res" = x; then
471 warn_ "one of these is required: $find_tool_names;"
472 die "alternatively set $find_tool_envvar to a compatible tool"
474 eval "$find_tool_envvar=\$find_tool_res"
475 eval "export $find_tool_envvar"
478 # --------------------- Preparing GNULIB_SRCDIR for use. ---------------------
479 # This is part of autopull.sh, but bootstrap needs it too, for self-upgrading.
481 # cleanup_gnulib fails, removing the directory $gnulib_path first.
482 cleanup_gnulib() {
483 status=$?
484 rm -fr "$gnulib_path"
485 exit $status
488 git_modules_config () {
489 test -f .gitmodules && git config --file .gitmodules "$@"
492 prepare_GNULIB_SRCDIR ()
494 if test -n "$GNULIB_SRCDIR"; then
495 # Use GNULIB_SRCDIR directly.
496 # We already checked that $GNULIB_SRCDIR references a directory.
497 # Verify that it contains a gnulib checkout.
498 test -f "$GNULIB_SRCDIR/gnulib-tool" \
499 || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \
500 "but does not contain gnulib-tool"
501 if test -n "$GNULIB_REVISION" && $use_git; then
502 # The 'git checkout "$GNULIB_REVISION"' command succeeds if the
503 # GNULIB_REVISION is a commit hash that exists locally, or if it is
504 # branch name that can be fetched from origin. It fails, however,
505 # if the GNULIB_REVISION is a commit hash that only exists in
506 # origin. In this case, we need a 'git fetch' and then retry
507 # 'git checkout "$GNULIB_REVISION"'.
508 git -C "$GNULIB_SRCDIR" checkout "$GNULIB_REVISION" 2>/dev/null \
509 || { git -C "$GNULIB_SRCDIR" fetch origin \
510 && git -C "$GNULIB_SRCDIR" checkout "$GNULIB_REVISION"; } \
511 || exit $?
513 else
514 if ! $use_git; then
515 die "Error: --no-git is specified," \
516 "but neither --gnulib-srcdir nor \$GNULIB_SRCDIR is specified"
518 if git submodule -h | grep -- --reference > /dev/null; then
520 else
521 die "git version is too old, git >= 1.6.4 is required"
523 gnulib_path=$(git_modules_config submodule.gnulib.path)
524 if test -n "$gnulib_path"; then
525 # A submodule 'gnulib' is configured.
526 # Get gnulib files. Populate $gnulib_path, updating the submodule.
527 if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git; then
528 # Use GNULIB_REFDIR as a reference.
529 echo "$0: getting gnulib files..."
530 git submodule update --init --reference "$GNULIB_REFDIR" "$gnulib_path"\
531 || exit $?
532 else
533 # GNULIB_REFDIR is not set or not usable. Ignore it.
534 if git_modules_config submodule.gnulib.url >/dev/null; then
535 echo "$0: getting gnulib files..."
536 git submodule init -- "$gnulib_path" || exit $?
537 git submodule update -- "$gnulib_path" || exit $?
538 else
539 die "Error: submodule 'gnulib' has no configured url"
542 else
543 gnulib_path='gnulib'
544 if test ! -d "$gnulib_path"; then
545 # The subdirectory 'gnulib' does not yet exist. Clone into it.
546 echo "$0: getting gnulib files..."
547 trap cleanup_gnulib HUP INT PIPE TERM
548 gnulib_url=${GNULIB_URL:-$default_gnulib_url}
549 if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git; then
550 # Use GNULIB_REFDIR as a reference.
551 git clone "$GNULIB_REFDIR" "$gnulib_path" \
552 && git -C "$gnulib_path" remote set-url origin "$gnulib_url" \
553 && if test -z "$GNULIB_REVISION"; then
554 git -C "$gnulib_path" pull origin \
555 && {
556 # We want the default branch of "$gnulib_url" (since that's
557 # the behaviour if GNULIB_REFDIR is not specified), not the
558 # current branch of "$GNULIB_REFDIR".
559 default_branch=`LC_ALL=C git -C "$gnulib_path" \
560 remote show origin \
561 | sed -n -e 's/^ *HEAD branch: //p'`
562 test -n "$default_branch" || default_branch='master'
563 git -C "$gnulib_path" checkout "$default_branch"
565 else
566 # The 'git checkout "$GNULIB_REVISION"' command succeeds if the
567 # GNULIB_REVISION is a commit hash that exists locally, or if it
568 # is a branch name that can be fetched from origin. It fails,
569 # however, if the GNULIB_REVISION is a commit hash that only
570 # exists in origin. In this case, we need a 'git fetch' and then
571 # retry 'git checkout "$GNULIB_REVISION"'.
572 git -C "$gnulib_path" checkout "$GNULIB_REVISION" 2>/dev/null \
573 || { git -C "$gnulib_path" fetch origin \
574 && git -C "$gnulib_path" checkout "$GNULIB_REVISION"; }
575 fi \
576 || cleanup_gnulib
577 else
578 # GNULIB_REFDIR is not set or not usable. Ignore it.
579 shallow=
580 if test -z "$GNULIB_REVISION"; then
581 if git clone -h 2>&1 | grep -- --depth > /dev/null; then
582 shallow='--depth 2'
584 git clone $shallow "$gnulib_url" "$gnulib_path" \
585 || cleanup_gnulib
586 else
587 if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
588 shallow='--depth 2'
590 mkdir -p "$gnulib_path"
591 # Only want a shallow checkout of $GNULIB_REVISION, but git does not
592 # support cloning by commit hash. So attempt a shallow fetch by
593 # commit hash to minimize the amount of data downloaded and changes
594 # needed to be processed, which can drastically reduce download and
595 # processing time for checkout. If the fetch by commit fails, a
596 # shallow fetch cannot be performed because we do not know what the
597 # depth of the commit is without fetching all commits. So fall back
598 # to fetching all commits.
599 git -C "$gnulib_path" init
600 git -C "$gnulib_path" remote add origin "$gnulib_url"
601 git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
602 || git -C "$gnulib_path" fetch origin \
603 || cleanup_gnulib
604 git -C "$gnulib_path" reset --hard FETCH_HEAD
605 git -C "$gnulib_path" checkout "$GNULIB_REVISION" || cleanup_gnulib
608 trap - HUP INT PIPE TERM
609 else
610 # The subdirectory 'gnulib' already exists.
611 if test -n "$GNULIB_REVISION"; then
612 if test -d "$gnulib_path/.git"; then
613 # The 'git checkout "$GNULIB_REVISION"' command succeeds if the
614 # GNULIB_REVISION is a commit hash that exists locally, or if it
615 # is a branch name that can be fetched from origin. It fails,
616 # however, if the GNULIB_REVISION is a commit hash that only
617 # exists in origin. In this case, we need a 'git fetch' and then
618 # retry 'git checkout "$GNULIB_REVISION"'.
619 git -C "$gnulib_path" checkout "$GNULIB_REVISION" 2>/dev/null \
620 || { git -C "$gnulib_path" fetch origin \
621 && git -C "$gnulib_path" checkout "$GNULIB_REVISION"; } \
622 || exit $?
623 else
624 die "Error: GNULIB_REVISION is specified in bootstrap.conf," \
625 "but '$gnulib_path' contains no git history"
630 # Verify that $gnulib_path contains a gnulib checkout.
631 test -f "$gnulib_path/gnulib-tool" \
632 || die "Error: '$gnulib_path' is supposed to contain a gnulib checkout," \
633 "but does not contain gnulib-tool"
634 GNULIB_SRCDIR=$gnulib_path
636 # $GNULIB_SRCDIR now points to the version of gnulib to use, and
637 # we no longer need to use git or $gnulib_path below here.
640 # -------- Upgrading bootstrap to the version found in GNULIB_SRCDIR. --------
642 upgrade_bootstrap ()
644 if test -f "$medir"/bootstrap-funclib.sh; then
645 update_lib=true
646 { cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/top/bootstrap" \
647 && cmp -s "$medir"/bootstrap-funclib.sh \
648 "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" \
649 && cmp -s "$medir"/autopull.sh "$GNULIB_SRCDIR/top/autopull.sh" \
650 && cmp -s "$medir"/autogen.sh "$GNULIB_SRCDIR/top/autogen.sh"; \
652 else
653 update_lib=false
654 cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/build-aux/bootstrap"
655 fi || {
656 if $update_lib; then
657 echo "$0: updating bootstrap & companions and restarting..."
658 else
659 echo "$0: updating bootstrap and restarting..."
661 case $(sh -c 'echo "$1"' -- a) in
662 a) ignored=--;;
663 *) ignored=ignored;;
664 esac
665 u=$update_lib
666 exec sh -c \
667 '{ if '$u' && test -f "$1"; then cp "$1" "$3"; else cp "$2" "$3"; fi; } &&
668 { if '$u' && test -f "$4"; then cp "$4" "$5"; else rm -f "$5"; fi; } &&
669 { if '$u' && test -f "$6"; then cp "$6" "$7"; else rm -f "$7"; fi; } &&
670 { if '$u' && test -f "$8"; then cp "$8" "$9"; else rm -f "$9"; fi; } &&
671 shift && shift && shift && shift && shift &&
672 shift && shift && shift && shift &&
673 exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
674 $ignored \
675 "$GNULIB_SRCDIR/top/bootstrap" "$GNULIB_SRCDIR/build-aux/bootstrap" \
676 "$medir/bootstrap" \
677 "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" "$medir/bootstrap-funclib.sh" \
678 "$GNULIB_SRCDIR/top/autopull.sh" "$medir/autopull.sh" \
679 "$GNULIB_SRCDIR/top/autogen.sh" "$medir/autogen.sh" \
680 "$0" "$@" --no-bootstrap-sync
684 # ----------------------------------------------------------------------------
686 if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then
687 use_gnulib=false
688 else
689 use_gnulib=true
692 # -------- Fetch auxiliary files from the network. --------------------------
694 autopull_usage() {
695 cat <<EOF
696 Usage: $me [OPTION]...
697 Bootstrap this package from the checked-out sources, phase 1:
698 Pull files from the network.
700 Optional environment variables:
701 GNULIB_SRCDIR Specifies the local directory where gnulib
702 sources reside. Use this if you already
703 have gnulib sources on your machine, and
704 you want to use these sources.
705 GNULIB_REFDIR Specifies the local directory where a gnulib
706 repository (with a .git subdirectory) resides.
707 Use this if you already have gnulib sources
708 and history on your machine, and do not want
709 to waste your bandwidth downloading them again.
710 GNULIB_URL URL of the gnulib repository. The default is
711 $default_gnulib_url,
712 which is Gnulib's upstream repository.
714 Options:
716 --bootstrap-sync If this bootstrap script is not identical to
717 the version in the local gnulib sources,
718 update this script, and then restart it with
719 /bin/sh or the shell \$CONFIG_SHELL.
720 --no-bootstrap-sync Do not check whether bootstrap is out of sync.
722 --force Attempt to bootstrap even if the sources seem
723 not to have been checked out.
724 --no-git Do not use git to update gnulib. Requires that
725 \$GNULIB_SRCDIR points to a gnulib repository
726 with the correct revision.
727 --skip-po Do not download *.po files.
729 bootstrap_print_option_usage_hook
730 cat <<EOF
731 If the file bootstrap.conf exists in the same directory as this script, its
732 contents are read as shell variables to configure the bootstrap.
734 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
735 are honored.
737 Gnulib sources can be fetched in various ways:
739 * If the environment variable GNULIB_SRCDIR is set, then sources are
740 fetched from that local directory. If it is a git repository and the
741 configuration variable GNULIB_REVISION is set in bootstrap.conf, then
742 that revision is checked out.
744 * Otherwise, if this package is in a git repository with a 'gnulib'
745 submodule configured, then that submodule is initialized and updated
746 and sources are fetched from there. If the environment variable
747 GNULIB_REFDIR is set and is a git repository, then it is used as a
748 reference.
750 * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
751 are cloned into that directory using git from \$GNULIB_URL, defaulting
752 to $default_gnulib_url; if GNULIB_REFDIR is set and is a git repository
753 its contents may be used to accelerate the process.
754 If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
755 then that revision is checked out.
757 * Otherwise, the existing Gnulib sources in the 'gnulib' directory are
758 used. If it is a git repository and the configuration variable
759 GNULIB_REVISION is set in bootstrap.conf, then that revision is
760 checked out.
762 If you maintain a package and want to pin a particular revision of the
763 Gnulib sources that has been tested with your package, then there are
764 two possible approaches: either configure a 'gnulib' submodule with the
765 appropriate revision, or set GNULIB_REVISION (and if necessary
766 GNULIB_URL) in bootstrap.conf.
768 Running without arguments will suffice in most cases.
772 # Fetch auxiliary files that are omitted from the version control
773 # repository of this package.
774 autopull()
776 # Ensure that CDPATH is not set. Otherwise, the output from cd
777 # would cause trouble in at least one use below.
778 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
780 # Parse options.
782 # Use git to update gnulib sources
783 use_git=true
785 for option
787 case $option in
788 --help)
789 autopull_usage
790 return;;
791 --version)
792 set -e
793 echo "autopull.sh $scriptlibversion"
794 echo "$copyright"
795 return 0
797 --skip-po)
798 SKIP_PO=t;;
799 --force)
800 checkout_only_file=;;
801 --bootstrap-sync)
802 bootstrap_sync=true;;
803 --no-bootstrap-sync)
804 bootstrap_sync=false;;
805 --no-git)
806 use_git=false;;
808 bootstrap_option_hook $option || die "$option: unknown option";;
809 esac
810 done
812 $use_git || test -n "$GNULIB_SRCDIR" \
813 || die "Error: --no-git requires \$GNULIB_SRCDIR environment variable" \
814 "or --gnulib-srcdir option"
815 test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
816 || die "Error: \$GNULIB_SRCDIR environment variable" \
817 "or --gnulib-srcdir option is specified," \
818 "but does not denote a directory"
820 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
821 die "Running this script from a non-checked-out distribution is risky."
824 check_build_prerequisites $use_git
826 if $use_gnulib || $bootstrap_sync; then
827 prepare_GNULIB_SRCDIR
828 if $bootstrap_sync; then
829 upgrade_bootstrap "$@"
833 # Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6.
834 # Also find the compatible sha1 utility on the BSDs
835 if test x"$SKIP_PO" = x; then
836 find_tool SHA1SUM sha1sum gsha1sum shasum sha1
839 # See if we can use gnulib's git-merge-changelog merge driver.
840 if $use_git && test -d .git && check_exists git; then
841 if git config merge.merge-changelog.driver >/dev/null ; then
843 elif check_exists git-merge-changelog; then
844 echo "$0: initializing git-merge-changelog driver"
845 git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
846 git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
847 else
848 echo "$0: consider installing git-merge-changelog from gnulib"
852 case $SKIP_PO in
854 if test -d po; then
855 update_po_files po $package || return
858 if test -d runtime-po; then
859 update_po_files runtime-po $package-runtime || return
860 fi;;
861 esac
863 # ---------------------------------------------------------------------------
865 bootstrap_post_pull_hook \
866 || die "bootstrap_post_pull_hook failed"
868 # Don't proceed if there are uninitialized submodules. In particular,
869 # autogen.sh will remove dangling links, which might be links into
870 # uninitialized submodules.
871 # But it's OK if the 'gnulib' submodule is uninitialized, as long as
872 # GNULIB_SRCDIR is set.
873 if $use_git; then
874 # Uninitialized submodules are listed with an initial dash.
875 uninitialized=`git submodule | grep '^-' | awk '{ print $2 }'`
876 if test -n "$GNULIB_SRCDIR"; then
877 uninitialized=`echo "$uninitialized" | grep -v '^gnulib$'`
879 if test -n "$uninitialized"; then
880 uninit_comma=`echo "$uninitialized" | tr '\n' ',' | sed -e 's|,$|.|'`
881 die "Some git submodules are not initialized: "$uninit_comma \
882 "Either use option '--no-git'," \
883 "or run 'git submodule update --init' and bootstrap again."
887 if test -f "$medir"/autogen.sh; then
888 echo "$0: done. Now you can run '$medir/autogen.sh'."
892 # ----------------------------- Get translations. -----------------------------
894 download_po_files() {
895 subdir=$1
896 domain=$2
897 echo "$me: getting translations into $subdir for $domain..."
898 cmd=$(printf "$po_download_command_format" "$subdir" "$domain")
899 eval "$cmd"
902 # Mirror .po files to $po_dir/.reference and copy only the new
903 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
904 # Note po files that exist locally only are left in $po_dir but will
905 # not be included in LINGUAS and hence will not be distributed.
906 update_po_files() {
907 # Directory containing primary .po files.
908 # Overwrite them only when we're sure a .po file is new.
909 po_dir=$1
910 domain=$2
912 # Mirror *.po files into this dir.
913 # Usually contains *.s1 checksum files.
914 ref_po_dir="$po_dir/.reference"
916 test -d $ref_po_dir || mkdir $ref_po_dir || return
917 download_po_files $ref_po_dir $domain \
918 && ls "$ref_po_dir"/*.po 2>/dev/null |
919 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
921 for po in x $(ls $ref_po_dir | sed -n 's/\.po$//p'); do
922 case $po in x) continue;; esac
923 new_po="$ref_po_dir/$po.po"
924 cksum_file="$ref_po_dir/$po.s1"
925 if ! test -f "$cksum_file" ||
926 ! test -f "$po_dir/$po.po" ||
927 ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then
928 echo "$me: updated $po_dir/$po.po..."
929 cp "$new_po" "$po_dir/$po.po" \
930 && $SHA1SUM < "$new_po" > "$cksum_file" || return
932 done
935 # -------- Generate files automatically from existing sources. --------------
937 autogen_usage() {
938 cat <<EOF
939 Usage: $me [OPTION]...
940 Bootstrap this package from the checked-out sources, phase 2:
941 Generate files from local files (no network access).
943 Optional environment variables:
944 GNULIB_SRCDIR Specifies the local directory where gnulib
945 sources reside. Use this if you already
946 have gnulib sources on your machine, and
947 you want to use these sources.
949 Options:
950 --copy Copy files instead of creating symbolic links.
951 --force Attempt to bootstrap even if the sources seem
952 not to have been checked out.
954 bootstrap_print_option_usage_hook
955 cat <<EOF
956 If the file bootstrap.conf exists in the same directory as this script, its
957 contents are read as shell variables to configure the bootstrap.
959 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
960 are honored.
962 Gnulib sources are assumed to be present:
963 * in \$GNULIB_SRCDIR, if that environment variable is set,
964 * otherwise, in the 'gnulib' submodule, if such a submodule is configured,
965 * otherwise, in the 'gnulib' subdirectory.
967 Running without arguments will suffice in most cases.
972 version_controlled_file() {
973 parent=$1
974 file=$2
975 if test -d .git; then
976 git rm -n "$file" > /dev/null 2>&1
977 elif test -d .svn; then
978 svn log -r HEAD "$file" > /dev/null 2>&1
979 elif test -d CVS; then
980 grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
981 grep '^/[^/]*/[0-9]' > /dev/null
982 else
983 warn_ "no version control for $file?"
984 false
988 # Strip blank and comment lines to leave significant entries.
989 gitignore_entries() {
990 sed '/^#/d; /^$/d' "$@"
993 # If $STR is not already on a line by itself in $FILE, insert it at the start.
994 # Entries are inserted at the start of the ignore list to ensure existing
995 # entries starting with ! are not overridden. Such entries support
996 # whitelisting exceptions after a more generic blacklist pattern.
997 insert_if_absent() {
998 file=$1
999 str=$2
1000 test -f $file || touch $file
1001 test -r $file || die "Error: failed to read ignore file: $file"
1002 duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
1003 if [ "$duplicate_entries" ] ; then
1004 die "Error: Duplicate entries in $file: " $duplicate_entries
1006 linesold=$(gitignore_entries $file | wc -l)
1007 linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
1008 if [ $linesold != $linesnew ] ; then
1009 { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
1010 || die "insert_if_absent $file $str: failed"
1014 # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
1015 # insert_if_absent.
1016 insert_vc_ignore() {
1017 vc_ignore_file="$1"
1018 pattern="$2"
1019 case $vc_ignore_file in
1020 *.gitignore)
1021 # A .gitignore entry that does not start with '/' applies
1022 # recursively to subdirectories, so prepend '/' to every
1023 # .gitignore entry.
1024 pattern=$(echo "$pattern" | sed s,^,/,);;
1025 esac
1026 insert_if_absent "$vc_ignore_file" "$pattern"
1029 symlink_to_dir()
1031 src=$1/$2
1032 dst=${3-$2}
1034 test -f "$src" && {
1036 # If the destination directory doesn't exist, create it.
1037 # This is required at least for "lib/uniwidth/cjk.h".
1038 dst_dir=$(dirname "$dst")
1039 if ! test -d "$dst_dir"; then
1040 mkdir -p "$dst_dir"
1042 # If we've just created a directory like lib/uniwidth,
1043 # tell version control system(s) it's ignorable.
1044 # FIXME: for now, this does only one level
1045 parent=$(dirname "$dst_dir")
1046 for dot_ig in x $vc_ignore; do
1047 test $dot_ig = x && continue
1048 ig=$parent/$dot_ig
1049 insert_vc_ignore $ig "${dst_dir##*/}/"
1050 done
1053 if $copy; then
1055 test ! -h "$dst" || {
1056 echo "$me: rm -f $dst" &&
1057 rm -f "$dst"
1059 } &&
1060 test -f "$dst" &&
1061 cmp -s "$src" "$dst" || {
1062 echo "$me: cp -fp $src $dst" &&
1063 cp -fp "$src" "$dst"
1065 else
1066 # Leave any existing symlink alone, if it already points to the source,
1067 # so that broken build tools that care about symlink times
1068 # aren't confused into doing unnecessary builds. Conversely, if the
1069 # existing symlink's timestamp is older than the source, make it afresh,
1070 # so that broken tools aren't confused into skipping needed builds. See
1071 # <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00326.html>.
1072 test -h "$dst" &&
1073 src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
1074 dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
1075 test "$src_i" = "$dst_i" &&
1076 both_ls=$(ls -dt "$src" "$dst") &&
1077 test "X$both_ls" = "X$dst$nl$src" || {
1078 dot_dots=
1079 case $src in
1080 /*) ;;
1082 case /$dst/ in
1083 *//* | */../* | */./* | /*/*/*/*/*/)
1084 die "invalid symlink calculation: $src -> $dst";;
1085 /*/*/*/*/) dot_dots=../../../;;
1086 /*/*/*/) dot_dots=../../;;
1087 /*/*/) dot_dots=../;;
1088 esac;;
1089 esac
1091 echo "$me: ln -fs $dot_dots$src $dst" &&
1092 ln -fs "$dot_dots$src" "$dst"
1098 # Regenerate all autogeneratable files that are omitted from the
1099 # version control repository. In particular, regenerate all
1100 # aclocal.m4, config.h.in, Makefile.in, configure files with new
1101 # versions of autoconf or automake.
1102 autogen()
1104 # Ensure that CDPATH is not set. Otherwise, the output from cd
1105 # would cause trouble in at least one use below.
1106 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1108 # Environment variables that may be set by the user.
1109 : "${AUTOPOINT=autopoint}"
1110 : "${AUTORECONF=autoreconf}"
1112 if test "$vc_ignore" = auto; then
1113 vc_ignore=
1114 test -d .git && vc_ignore=.gitignore
1115 test -d CVS && vc_ignore="$vc_ignore .cvsignore"
1119 # Parse options.
1121 # Whether to use copies instead of symlinks.
1122 copy=false
1124 for option
1126 case $option in
1127 --help)
1128 autogen_usage
1129 return;;
1130 --version)
1131 set -e
1132 echo "autogen.sh $scriptlibversion"
1133 echo "$copyright"
1134 return 0
1136 --force)
1137 checkout_only_file=;;
1138 --copy)
1139 copy=true;;
1141 bootstrap_option_hook $option || die "$option: unknown option";;
1142 esac
1143 done
1145 test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
1146 || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir" \
1147 "option is specified, but does not denote a directory"
1149 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
1150 die "Running this script from a non-checked-out distribution is risky."
1153 if $use_gnulib; then
1154 if test -z "$GNULIB_SRCDIR"; then
1155 gnulib_path=$(test -f .gitmodules &&
1156 git config --file .gitmodules submodule.gnulib.path)
1157 test -z "$gnulib_path" && gnulib_path=gnulib
1158 GNULIB_SRCDIR=$gnulib_path
1162 # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
1163 found_aux_dir=no
1164 grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'])' configure.ac \
1165 >/dev/null && found_aux_dir=yes
1166 grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
1167 >/dev/null && found_aux_dir=yes
1168 test $found_aux_dir = yes \
1169 || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
1171 # If $build_aux doesn't exist, create it now, otherwise some bits
1172 # below will malfunction. If creating it, also mark it as ignored.
1173 if test ! -d $build_aux; then
1174 mkdir $build_aux
1175 for dot_ig in x $vc_ignore; do
1176 test $dot_ig = x && continue
1177 insert_vc_ignore $dot_ig $build_aux/
1178 done
1181 check_build_prerequisites false
1183 use_libtool=0
1184 # We'd like to use grep -E, to see if any of LT_INIT,
1185 # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
1186 # but that's not portable enough (e.g., for Solaris).
1187 grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
1188 && use_libtool=1
1189 grep '^[ ]*LT_INIT' configure.ac >/dev/null \
1190 && use_libtool=1
1191 if test $use_libtool = 1; then
1192 find_tool LIBTOOLIZE glibtoolize libtoolize
1195 if $use_gnulib; then
1196 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
1197 <$gnulib_tool || return
1200 # NOTE: we have to be careful to run both autopoint and libtoolize
1201 # before gnulib-tool, since gnulib-tool is likely to provide newer
1202 # versions of files "installed" by these two programs.
1203 # Then, *after* gnulib-tool (see below), we have to be careful to
1204 # run autoreconf in such a way that it does not run either of these
1205 # two just-pre-run programs.
1207 # Import from gettext.
1208 with_gettext=yes
1209 grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
1210 with_gettext=no
1212 if test $with_gettext = yes || test $use_libtool = 1; then
1214 tempbase=.bootstrap$$
1215 trap "rm -f $tempbase.0 $tempbase.1" HUP INT PIPE TERM
1217 > $tempbase.0 > $tempbase.1 &&
1218 find . ! -type d -print | sort > $tempbase.0 || return
1220 if test $with_gettext = yes; then
1221 # Released autopoint has the tendency to install macros that have been
1222 # obsoleted in current gnulib, so run this before gnulib-tool.
1223 echo "$0: $AUTOPOINT --force"
1224 $AUTOPOINT --force || return
1227 # Autoreconf runs aclocal before libtoolize, which causes spurious
1228 # warnings if the initial aclocal is confused by the libtoolized
1229 # (or worse out-of-date) macro directory.
1230 # libtoolize 1.9b added the --install option; but we support back
1231 # to libtoolize 1.5.22, where the install action was default.
1232 if test $use_libtool = 1; then
1233 install=
1234 case $($LIBTOOLIZE --help) in
1235 *--install*) install=--install ;;
1236 esac
1237 echo "running: $LIBTOOLIZE $install --copy"
1238 $LIBTOOLIZE $install --copy
1241 find . ! -type d -print | sort >$tempbase.1
1242 old_IFS=$IFS
1243 IFS=$nl
1244 for file in $(comm -13 $tempbase.0 $tempbase.1); do
1245 IFS=$old_IFS
1246 parent=${file%/*}
1247 version_controlled_file "$parent" "$file" || {
1248 for dot_ig in x $vc_ignore; do
1249 test $dot_ig = x && continue
1250 ig=$parent/$dot_ig
1251 insert_vc_ignore "$ig" "${file##*/}"
1252 done
1254 done
1255 IFS=$old_IFS
1257 rm -f $tempbase.0 $tempbase.1
1258 trap - HUP INT PIPE TERM
1261 # Import from gnulib.
1263 if $use_gnulib; then
1264 gnulib_tool_options="\
1265 --no-changelog\
1266 --aux-dir=$build_aux\
1267 --doc-base=$doc_base\
1268 --lib=$gnulib_name\
1269 --m4-base=$m4_base/\
1270 --source-base=$source_base/\
1271 --tests-base=$tests_base\
1272 --local-dir=$local_gl_dir\
1273 $gnulib_tool_option_extras\
1275 if test $use_libtool = 1; then
1276 case "$gnulib_tool_options " in
1277 *' --libtool '*) ;;
1278 *) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
1279 esac
1281 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
1282 $gnulib_tool $gnulib_tool_options --import $gnulib_modules \
1283 || die "gnulib-tool failed"
1285 if test $with_gettext = yes && test ! -f $m4_base/gettext.m4; then
1286 # The gnulib-tool invocation has removed $m4_base/gettext.m4, that the
1287 # AUTOPOINT invocation had installed. This can occur when the gnulib
1288 # module 'gettext' was previously present but is now not present any more.
1289 # Repeat the AUTOPOINT invocation and the gnulib-tool invocation.
1291 echo "$0: $AUTOPOINT --force"
1292 $AUTOPOINT --force || return
1294 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
1295 $gnulib_tool $gnulib_tool_options --import $gnulib_modules \
1296 || die "gnulib-tool failed"
1299 for file in $gnulib_files; do
1300 symlink_to_dir "$GNULIB_SRCDIR" $file \
1301 || die "failed to symlink $file"
1302 done
1305 bootstrap_post_import_hook \
1306 || die "bootstrap_post_import_hook failed"
1308 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
1309 # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
1310 # The following requires GNU find 4.2.3 or newer. Considering the usual
1311 # portability constraints of this script, that may seem a very demanding
1312 # requirement, but it should be ok. Ignore any failure, which is fine,
1313 # since this is only a convenience to help developers avoid the relatively
1314 # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
1315 # between successive runs of this script.
1316 find "$m4_base" "$source_base" \
1317 -depth \( -name '*.m4' -o -name '*.[ch]' \) \
1318 -type l -xtype l -delete > /dev/null 2>&1
1320 # Invoke autoreconf with --force --install to ensure upgrades of tools
1321 # such as ylwrap.
1322 AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS"
1323 AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive"
1325 # Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
1326 echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS"
1327 AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \
1328 || die "autoreconf failed"
1330 # Get some extra files from gnulib, overriding existing files.
1331 for file in $gnulib_extra_files; do
1332 case $file in
1333 */INSTALL) dst=INSTALL;;
1334 build-aux/*) dst=$build_aux/${file#build-aux/};;
1335 *) dst=$file;;
1336 esac
1337 symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
1338 || die "failed to symlink $file"
1339 done
1341 if test $with_gettext = yes; then
1342 # Create gettext configuration.
1343 echo "$0: Creating po/Makevars from po/Makevars.template ..."
1344 rm -f po/Makevars
1345 sed '
1346 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
1347 /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
1348 /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
1349 /^XGETTEXT_OPTIONS *=/{
1350 s/$/ \\/
1352 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
1354 ' po/Makevars.template >po/Makevars \
1355 || die 'cannot generate po/Makevars'
1357 # If the 'gettext' module is in use, grab the latest Makefile.in.in.
1358 # If only the 'gettext-h' module is in use, assume autopoint already
1359 # put the correct version of this file into place.
1360 case $gnulib_modules in
1361 *gettext-h*) ;;
1362 *gettext*)
1363 cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
1364 || die "cannot create po/Makefile.in.in"
1366 esac
1368 if test -d runtime-po; then
1369 # Similarly for runtime-po/Makevars, but not quite the same.
1370 rm -f runtime-po/Makevars
1371 sed '
1372 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
1373 /^subdir *=.*/s/=.*/= runtime-po/
1374 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
1375 /^XGETTEXT_OPTIONS *=/{
1376 s/$/ \\/
1378 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
1380 ' po/Makevars.template >runtime-po/Makevars \
1381 || die 'cannot generate runtime-po/Makevars'
1383 # Copy identical files from po to runtime-po.
1384 cp -p po/Makefile.in.in po/*-quot po/*.header po/*.sed po/*.sin runtime-po
1388 bootstrap_epilogue
1390 echo "$0: done. Now you can run './configure'."
1393 # ----------------------------------------------------------------------------
1395 # Local Variables:
1396 # eval: (add-hook 'before-save-hook 'time-stamp nil t)
1397 # time-stamp-start: "scriptlibversion="
1398 # time-stamp-format: "%:y-%02m-%02d.%02H"
1399 # time-stamp-time-zone: "UTC0"
1400 # time-stamp-end: "; # UTC"
1401 # End:
1403 usage() {
1404 cat <<EOF
1405 Usage: $me [OPTION]...
1406 Bootstrap this package from the checked-out sources.
1408 Optional environment variables:
1409 GNULIB_SRCDIR Specifies the local directory where gnulib
1410 sources reside. Use this if you already
1411 have gnulib sources on your machine, and
1412 you want to use these sources.
1413 GNULIB_REFDIR Specifies the local directory where a gnulib
1414 repository (with a .git subdirectory) resides.
1415 Use this if you already have gnulib sources
1416 and history on your machine, and do not want
1417 to waste your bandwidth downloading them again.
1418 Only used for phase 1 (--pull).
1419 GNULIB_URL URL of the gnulib repository. The default is
1420 $default_gnulib_url,
1421 which is Gnulib's upstream repository.
1422 Only used for phase 1 (--pull).
1424 Options:
1426 --pull Do phase 1: Pull files from the network.
1427 --gen Do phase 2: Generate files from local files
1428 (no network access).
1429 (The default is to do both phases.)
1431 --gnulib-srcdir=DIRNAME Specifies the local directory where gnulib
1432 sources reside. Use this if you already
1433 have gnulib sources on your machine, and
1434 you want to use these sources. Defaults
1435 to \$GNULIB_SRCDIR.
1436 --gnulib-refdir=DIRNAME Specifies the local directory where a gnulib
1437 repository (with a .git subdirectory) resides.
1438 Use this if you already have gnulib sources
1439 and history on your machine, and do not want
1440 to waste your bandwidth downloading them again.
1441 Defaults to \$GNULIB_REFDIR.
1442 Only used for phase 1 (--pull).
1444 --bootstrap-sync If this bootstrap script is not identical to
1445 the version in the local gnulib sources,
1446 update this script, and then restart it with
1447 /bin/sh or the shell \$CONFIG_SHELL.
1448 --no-bootstrap-sync Do not check whether bootstrap is out of sync.
1450 --copy Copy files instead of creating symbolic links.
1451 Only used for phase 2 (--gen).
1452 --force Attempt to bootstrap even if the sources seem
1453 not to have been checked out.
1454 --no-git Do not use git to update gnulib. Requires that
1455 \$GNULIB_SRCDIR or the --gnulib-srcdir option
1456 points to a gnulib repository with the correct
1457 revision.
1458 Only used for phase 1 (--pull).
1459 --skip-po Do not download *.po files.
1460 Only used for phase 1 (--pull).
1462 bootstrap_print_option_usage_hook
1463 cat <<EOF
1464 If the file bootstrap.conf exists in the same directory as this script, its
1465 contents are read as shell variables to configure the bootstrap.
1467 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
1468 are honored.
1470 Gnulib sources can be fetched in various ways:
1472 * If GNULIB_SRCDIR is set (either as an environment variable or via the
1473 --gnulib-srcdir option), then sources are fetched from that local
1474 directory. If it is a git repository and the configuration variable
1475 GNULIB_REVISION is set in bootstrap.conf, then that revision is
1476 checked out.
1478 * Otherwise, if this package is in a git repository with a 'gnulib'
1479 submodule configured, then that submodule is initialized and updated
1480 and sources are fetched from there. If GNULIB_REFDIR is set (either
1481 as an environment variable or via the --gnulib-refdir option) and is
1482 a git repository, then it is used as a reference.
1484 * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
1485 are cloned into that directory using git from \$GNULIB_URL, defaulting
1486 to $default_gnulib_url; if GNULIB_REFDIR is set and is a git repository
1487 its contents may be used to accelerate the process.
1488 If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
1489 then that revision is checked out.
1491 * Otherwise, the existing Gnulib sources in the 'gnulib' directory are
1492 used. If it is a git repository and the configuration variable
1493 GNULIB_REVISION is set in bootstrap.conf, then that revision is
1494 checked out.
1496 If you maintain a package and want to pin a particular revision of the
1497 Gnulib sources that has been tested with your package, then there are
1498 two possible approaches: either configure a 'gnulib' submodule with the
1499 appropriate revision, or set GNULIB_REVISION (and if necessary
1500 GNULIB_URL) in bootstrap.conf.
1502 Running without arguments will suffice in most cases.
1506 # Parse options.
1508 # Whether to pull and generate.
1509 pull=false
1510 gen=false
1512 # Whether to use copies instead of symlinks.
1513 copy=false
1515 # Use git to update gnulib sources
1516 use_git=true
1518 for option
1520 case $option in
1521 --help)
1522 usage
1523 exit;;
1524 --version)
1525 set -e
1526 echo "bootstrap $scriptversion lib $scriptlibversion"
1527 echo "$copyright"
1528 exit 0
1530 --pull)
1531 pull=true;;
1532 --gen)
1533 gen=true;;
1534 --gnulib-srcdir=*)
1535 GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
1536 --gnulib-refdir=*)
1537 GNULIB_REFDIR=${option#--gnulib-refdir=};;
1538 --skip-po)
1539 SKIP_PO=t;;
1540 --force)
1541 checkout_only_file=;;
1542 --copy)
1543 copy=true;;
1544 --bootstrap-sync)
1545 bootstrap_sync=true;;
1546 --no-bootstrap-sync)
1547 bootstrap_sync=false;;
1548 --no-git)
1549 use_git=false;;
1551 bootstrap_option_hook $option || die "$option: unknown option";;
1552 esac
1553 done
1555 # Default is to do both.
1556 $pull || $gen || pull=true gen=true
1558 $use_git || test -n "$GNULIB_SRCDIR" \
1559 || die "Error: --no-git requires \$GNULIB_SRCDIR environment variable" \
1560 "or --gnulib-srcdir option"
1561 test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
1562 || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir" \
1563 "option is specified, but does not denote a directory"
1565 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
1566 die "Bootstrapping from a non-checked-out distribution is risky."
1569 check_build_prerequisites $use_git
1571 if $bootstrap_sync; then
1572 prepare_GNULIB_SRCDIR
1573 upgrade_bootstrap "$@"
1574 # Since we have now upgraded if needed, no need to try it a second time below.
1575 bootstrap_sync=false
1578 echo "$0: Bootstrapping from checked-out $package sources..."
1580 # Pass GNULIB_SRCDIR and GNULIB_REFDIR to any subsidiary commands that care.
1581 export GNULIB_SRCDIR
1582 export GNULIB_REFDIR
1584 if $pull && { $use_git || test -z "$SKIP_PO"; }; then
1585 autopull \
1586 `if $bootstrap_sync; then
1587 echo ' --bootstrap-sync'
1588 else
1589 echo ' --no-bootstrap-sync'
1590 fi` \
1591 `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
1592 `if ! $use_git; then echo ' --no-git'; fi` \
1593 `if test -n "$SKIP_PO"; then echo ' --skip-po'; fi` \
1594 || die "could not fetch auxiliary files"
1597 if $gen; then
1598 autogen \
1599 `if $copy; then echo ' --copy'; fi` \
1600 `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
1601 || die "could not generate auxiliary files"
1604 # ----------------------------------------------------------------------------
1606 # Local Variables:
1607 # eval: (add-hook 'before-save-hook 'time-stamp nil t)
1608 # time-stamp-start: "scriptversion="
1609 # time-stamp-format: "%:y-%02m-%02d.%02H"
1610 # time-stamp-time-zone: "UTC0"
1611 # time-stamp-end: "; # UTC"
1612 # End: