maint: use Gnulib's stat-time over our own version
[diffutils.git] / bootstrap
blobd78c8c306487a1015280528adabca091507ab54b
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-2024 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-06-29.23; # UTC
42 # Copyright (C) 2003-2024 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 (cd "$GNULIB_SRCDIR" \
509 && { git checkout "$GNULIB_REVISION" 2>/dev/null \
510 || { git fetch origin && git checkout "$GNULIB_REVISION"; }
512 ) || exit $?
514 else
515 if ! $use_git; then
516 die "Error: --no-git is specified," \
517 "but neither --gnulib-srcdir nor \$GNULIB_SRCDIR is specified"
519 if git submodule -h | grep -- --reference > /dev/null; then
521 else
522 die "git version is too old, git >= 1.6.4 is required"
524 gnulib_path=$(git_modules_config submodule.gnulib.path)
525 if test -n "$gnulib_path"; then
526 # A submodule 'gnulib' is configured.
527 # Get gnulib files. Populate $gnulib_path, updating the submodule.
528 if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git; then
529 # Use GNULIB_REFDIR as a reference.
530 echo "$0: getting gnulib files..."
531 git submodule update --init --reference "$GNULIB_REFDIR" "$gnulib_path"\
532 || exit $?
533 else
534 # GNULIB_REFDIR is not set or not usable. Ignore it.
535 if git_modules_config submodule.gnulib.url >/dev/null; then
536 echo "$0: getting gnulib files..."
537 git submodule init -- "$gnulib_path" || exit $?
538 git submodule update -- "$gnulib_path" || exit $?
539 else
540 die "Error: submodule 'gnulib' has no configured url"
543 else
544 gnulib_path='gnulib'
545 if test ! -d "$gnulib_path"; then
546 # The subdirectory 'gnulib' does not yet exist. Clone into it.
547 echo "$0: getting gnulib files..."
548 trap cleanup_gnulib HUP INT PIPE TERM
549 gnulib_url=${GNULIB_URL:-$default_gnulib_url}
550 shallow=
551 if test -z "$GNULIB_REVISION"; then
552 if git clone -h 2>&1 | grep -- --depth > /dev/null; then
553 shallow='--depth 2'
555 git clone $shallow "$gnulib_url" "$gnulib_path" \
556 || cleanup_gnulib
557 else
558 if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
559 shallow='--depth 2'
561 mkdir -p "$gnulib_path"
562 # Only want a shallow checkout of $GNULIB_REVISION, but git does not
563 # support cloning by commit hash. So attempt a shallow fetch by commit
564 # hash to minimize the amount of data downloaded and changes needed to
565 # be processed, which can drastically reduce download and processing
566 # time for checkout. If the fetch by commit fails, a shallow fetch can
567 # not be performed because we do not know what the depth of the commit
568 # is without fetching all commits. So fall back to fetching all
569 # commits.
570 git -C "$gnulib_path" init
571 git -C "$gnulib_path" remote add origin "$gnulib_url"
572 git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
573 || git -C "$gnulib_path" fetch origin \
574 || cleanup_gnulib
575 git -C "$gnulib_path" reset --hard FETCH_HEAD
576 (cd "$gnulib_path" && git checkout "$GNULIB_REVISION") \
577 || cleanup_gnulib
579 trap - HUP INT PIPE TERM
580 else
581 # The subdirectory 'gnulib' already exists.
582 if test -n "$GNULIB_REVISION"; then
583 if test -d "$gnulib_path/.git"; then
584 # The 'git checkout "$GNULIB_REVISION"' command succeeds if the
585 # GNULIB_REVISION is a commit hash that exists locally, or if it is
586 # branch name that can be fetched from origin. It fails, however,
587 # if the GNULIB_REVISION is a commit hash that only exists in
588 # origin. In this case, we need a 'git fetch' and then retry
589 # 'git checkout "$GNULIB_REVISION"'.
590 (cd "$gnulib_path" \
591 && { git checkout "$GNULIB_REVISION" 2>/dev/null \
592 || { git fetch origin && git checkout "$GNULIB_REVISION"; }
594 ) || exit $?
595 else
596 die "Error: GNULIB_REVISION is specified in bootstrap.conf," \
597 "but '$gnulib_path' contains no git history"
602 # Verify that $gnulib_path contains a gnulib checkout.
603 test -f "$gnulib_path/gnulib-tool" \
604 || die "Error: '$gnulib_path' is supposed to contain a gnulib checkout," \
605 "but does not contain gnulib-tool"
606 GNULIB_SRCDIR=$gnulib_path
608 # $GNULIB_SRCDIR now points to the version of gnulib to use, and
609 # we no longer need to use git or $gnulib_path below here.
612 # -------- Upgrading bootstrap to the version found in GNULIB_SRCDIR. --------
614 upgrade_bootstrap ()
616 if test -f "$medir"/bootstrap-funclib.sh; then
617 update_lib=true
618 { cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/top/bootstrap" \
619 && cmp -s "$medir"/bootstrap-funclib.sh \
620 "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" \
621 && cmp -s "$medir"/autopull.sh "$GNULIB_SRCDIR/top/autopull.sh" \
622 && cmp -s "$medir"/autogen.sh "$GNULIB_SRCDIR/top/autogen.sh"; \
624 else
625 update_lib=false
626 cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/build-aux/bootstrap"
627 fi || {
628 if $update_lib; then
629 echo "$0: updating bootstrap & companions and restarting..."
630 else
631 echo "$0: updating bootstrap and restarting..."
633 case $(sh -c 'echo "$1"' -- a) in
634 a) ignored=--;;
635 *) ignored=ignored;;
636 esac
637 u=$update_lib
638 exec sh -c \
639 '{ if '$u' && test -f "$1"; then cp "$1" "$3"; else cp "$2" "$3"; fi; } &&
640 { if '$u' && test -f "$4"; then cp "$4" "$5"; else rm -f "$5"; fi; } &&
641 { if '$u' && test -f "$6"; then cp "$6" "$7"; else rm -f "$7"; fi; } &&
642 { if '$u' && test -f "$8"; then cp "$8" "$9"; else rm -f "$9"; fi; } &&
643 shift && shift && shift && shift && shift &&
644 shift && shift && shift && shift &&
645 exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
646 $ignored \
647 "$GNULIB_SRCDIR/top/bootstrap" "$GNULIB_SRCDIR/build-aux/bootstrap" \
648 "$medir/bootstrap" \
649 "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" "$medir/bootstrap-funclib.sh" \
650 "$GNULIB_SRCDIR/top/autopull.sh" "$medir/autopull.sh" \
651 "$GNULIB_SRCDIR/top/autogen.sh" "$medir/autogen.sh" \
652 "$0" "$@" --no-bootstrap-sync
656 # ----------------------------------------------------------------------------
658 if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then
659 use_gnulib=false
660 else
661 use_gnulib=true
664 # -------- Fetch auxiliary files from the network. --------------------------
666 autopull_usage() {
667 cat <<EOF
668 Usage: $me [OPTION]...
669 Bootstrap this package from the checked-out sources, phase 1:
670 Pull files from the network.
672 Optional environment variables:
673 GNULIB_SRCDIR Specifies the local directory where gnulib
674 sources reside. Use this if you already
675 have gnulib sources on your machine, and
676 you want to use these sources.
677 GNULIB_REFDIR Specifies the local directory where a gnulib
678 repository (with a .git subdirectory) resides.
679 Use this if you already have gnulib sources
680 and history on your machine, and do not want
681 to waste your bandwidth downloading them again.
682 GNULIB_URL URL of the gnulib repository. The default is
683 $default_gnulib_url,
684 which is Gnulib's upstream repository.
686 Options:
688 --bootstrap-sync If this bootstrap script is not identical to
689 the version in the local gnulib sources,
690 update this script, and then restart it with
691 /bin/sh or the shell \$CONFIG_SHELL.
692 --no-bootstrap-sync Do not check whether bootstrap is out of sync.
694 --force Attempt to bootstrap even if the sources seem
695 not to have been checked out.
696 --no-git Do not use git to update gnulib. Requires that
697 \$GNULIB_SRCDIR points to a gnulib repository
698 with the correct revision.
699 --skip-po Do not download *.po files.
701 bootstrap_print_option_usage_hook
702 cat <<EOF
703 If the file bootstrap.conf exists in the same directory as this script, its
704 contents are read as shell variables to configure the bootstrap.
706 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
707 are honored.
709 Gnulib sources can be fetched in various ways:
711 * If the environment variable GNULIB_SRCDIR is set, then sources are
712 fetched from that local directory. If it is a git repository and the
713 configuration variable GNULIB_REVISION is set in bootstrap.conf, then
714 that revision is checked out.
716 * Otherwise, if this package is in a git repository with a 'gnulib'
717 submodule configured, then that submodule is initialized and updated
718 and sources are fetched from there. If the environment variable
719 GNULIB_REFDIR is set and is a git repository, then it is used as a
720 reference.
722 * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
723 are cloned into that directory using git from \$GNULIB_URL, defaulting
724 to $default_gnulib_url.
725 If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
726 then that revision is checked out.
728 * Otherwise, the existing Gnulib sources in the 'gnulib' directory are
729 used. If it is a git repository and the configuration variable
730 GNULIB_REVISION is set in bootstrap.conf, then that revision is
731 checked out.
733 If you maintain a package and want to pin a particular revision of the
734 Gnulib sources that has been tested with your package, then there are
735 two possible approaches: either configure a 'gnulib' submodule with the
736 appropriate revision, or set GNULIB_REVISION (and if necessary
737 GNULIB_URL) in bootstrap.conf.
739 Running without arguments will suffice in most cases.
743 # Fetch auxiliary files that are omitted from the version control
744 # repository of this package.
745 autopull()
747 # Ensure that CDPATH is not set. Otherwise, the output from cd
748 # would cause trouble in at least one use below.
749 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
751 # Parse options.
753 # Use git to update gnulib sources
754 use_git=true
756 for option
758 case $option in
759 --help)
760 autopull_usage
761 return;;
762 --version)
763 set -e
764 echo "autopull.sh $scriptlibversion"
765 echo "$copyright"
766 return 0
768 --skip-po)
769 SKIP_PO=t;;
770 --force)
771 checkout_only_file=;;
772 --bootstrap-sync)
773 bootstrap_sync=true;;
774 --no-bootstrap-sync)
775 bootstrap_sync=false;;
776 --no-git)
777 use_git=false;;
779 bootstrap_option_hook $option || die "$option: unknown option";;
780 esac
781 done
783 $use_git || test -n "$GNULIB_SRCDIR" \
784 || die "Error: --no-git requires \$GNULIB_SRCDIR environment variable" \
785 "or --gnulib-srcdir option"
786 test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
787 || die "Error: \$GNULIB_SRCDIR environment variable" \
788 "or --gnulib-srcdir option is specified," \
789 "but does not denote a directory"
791 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
792 die "Running this script from a non-checked-out distribution is risky."
795 check_build_prerequisites $use_git
797 if $use_gnulib || $bootstrap_sync; then
798 prepare_GNULIB_SRCDIR
799 if $bootstrap_sync; then
800 upgrade_bootstrap "$@"
804 # Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6.
805 # Also find the compatible sha1 utility on the BSDs
806 if test x"$SKIP_PO" = x; then
807 find_tool SHA1SUM sha1sum gsha1sum shasum sha1
810 # See if we can use gnulib's git-merge-changelog merge driver.
811 if $use_git && test -d .git && check_exists git; then
812 if git config merge.merge-changelog.driver >/dev/null ; then
814 elif check_exists git-merge-changelog; then
815 echo "$0: initializing git-merge-changelog driver"
816 git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
817 git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
818 else
819 echo "$0: consider installing git-merge-changelog from gnulib"
823 case $SKIP_PO in
825 if test -d po; then
826 update_po_files po $package || return
829 if test -d runtime-po; then
830 update_po_files runtime-po $package-runtime || return
831 fi;;
832 esac
834 # ---------------------------------------------------------------------------
836 bootstrap_post_pull_hook \
837 || die "bootstrap_post_pull_hook failed"
839 # Don't proceed if there are uninitialized submodules. In particular,
840 # autogen.sh will remove dangling links, which might be links into
841 # uninitialized submodules.
842 # But it's OK if the 'gnulib' submodule is uninitialized, as long as
843 # GNULIB_SRCDIR is set.
844 if $use_git; then
845 # Uninitialized submodules are listed with an initial dash.
846 uninitialized=`git submodule | grep '^-' | awk '{ print $2 }'`
847 if test -n "$GNULIB_SRCDIR"; then
848 uninitialized=`echo "$uninitialized" | grep -v '^gnulib$'`
850 if test -n "$uninitialized"; then
851 uninit_comma=`echo "$uninitialized" | tr '\n' ',' | sed -e 's|,$|.|'`
852 die "Some git submodules are not initialized: "$uninit_comma \
853 "Either use option '--no-git'," \
854 "or run 'git submodule update --init' and bootstrap again."
858 if test -f "$medir"/autogen.sh; then
859 echo "$0: done. Now you can run '$medir/autogen.sh'."
863 # ----------------------------- Get translations. -----------------------------
865 download_po_files() {
866 subdir=$1
867 domain=$2
868 echo "$me: getting translations into $subdir for $domain..."
869 cmd=$(printf "$po_download_command_format" "$subdir" "$domain")
870 eval "$cmd"
873 # Mirror .po files to $po_dir/.reference and copy only the new
874 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
875 # Note po files that exist locally only are left in $po_dir but will
876 # not be included in LINGUAS and hence will not be distributed.
877 update_po_files() {
878 # Directory containing primary .po files.
879 # Overwrite them only when we're sure a .po file is new.
880 po_dir=$1
881 domain=$2
883 # Mirror *.po files into this dir.
884 # Usually contains *.s1 checksum files.
885 ref_po_dir="$po_dir/.reference"
887 test -d $ref_po_dir || mkdir $ref_po_dir || return
888 download_po_files $ref_po_dir $domain \
889 && ls "$ref_po_dir"/*.po 2>/dev/null |
890 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
892 langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g')
893 test "$langs" = '*' && langs=x
894 for po in $langs; do
895 case $po in x) continue;; esac
896 new_po="$ref_po_dir/$po.po"
897 cksum_file="$ref_po_dir/$po.s1"
898 if ! test -f "$cksum_file" ||
899 ! test -f "$po_dir/$po.po" ||
900 ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then
901 echo "$me: updated $po_dir/$po.po..."
902 cp "$new_po" "$po_dir/$po.po" \
903 && $SHA1SUM < "$new_po" > "$cksum_file" || return
905 done
908 # -------- Generate files automatically from existing sources. --------------
910 autogen_usage() {
911 cat <<EOF
912 Usage: $me [OPTION]...
913 Bootstrap this package from the checked-out sources, phase 2:
914 Generate files from local files (no network access).
916 Optional environment variables:
917 GNULIB_SRCDIR Specifies the local directory where gnulib
918 sources reside. Use this if you already
919 have gnulib sources on your machine, and
920 you want to use these sources.
922 Options:
923 --copy Copy files instead of creating symbolic links.
924 --force Attempt to bootstrap even if the sources seem
925 not to have been checked out.
927 bootstrap_print_option_usage_hook
928 cat <<EOF
929 If the file bootstrap.conf exists in the same directory as this script, its
930 contents are read as shell variables to configure the bootstrap.
932 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
933 are honored.
935 Gnulib sources are assumed to be present:
936 * in \$GNULIB_SRCDIR, if that environment variable is set,
937 * otherwise, in the 'gnulib' submodule, if such a submodule is configured,
938 * otherwise, in the 'gnulib' subdirectory.
940 Running without arguments will suffice in most cases.
945 version_controlled_file() {
946 parent=$1
947 file=$2
948 if test -d .git; then
949 git rm -n "$file" > /dev/null 2>&1
950 elif test -d .svn; then
951 svn log -r HEAD "$file" > /dev/null 2>&1
952 elif test -d CVS; then
953 grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
954 grep '^/[^/]*/[0-9]' > /dev/null
955 else
956 warn_ "no version control for $file?"
957 false
961 # Strip blank and comment lines to leave significant entries.
962 gitignore_entries() {
963 sed '/^#/d; /^$/d' "$@"
966 # If $STR is not already on a line by itself in $FILE, insert it at the start.
967 # Entries are inserted at the start of the ignore list to ensure existing
968 # entries starting with ! are not overridden. Such entries support
969 # whitelisting exceptions after a more generic blacklist pattern.
970 insert_if_absent() {
971 file=$1
972 str=$2
973 test -f $file || touch $file
974 test -r $file || die "Error: failed to read ignore file: $file"
975 duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
976 if [ "$duplicate_entries" ] ; then
977 die "Error: Duplicate entries in $file: " $duplicate_entries
979 linesold=$(gitignore_entries $file | wc -l)
980 linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
981 if [ $linesold != $linesnew ] ; then
982 { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
983 || die "insert_if_absent $file $str: failed"
987 # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
988 # insert_if_absent.
989 insert_vc_ignore() {
990 vc_ignore_file="$1"
991 pattern="$2"
992 case $vc_ignore_file in
993 *.gitignore)
994 # A .gitignore entry that does not start with '/' applies
995 # recursively to subdirectories, so prepend '/' to every
996 # .gitignore entry.
997 pattern=$(echo "$pattern" | sed s,^,/,);;
998 esac
999 insert_if_absent "$vc_ignore_file" "$pattern"
1002 symlink_to_dir()
1004 src=$1/$2
1005 dst=${3-$2}
1007 test -f "$src" && {
1009 # If the destination directory doesn't exist, create it.
1010 # This is required at least for "lib/uniwidth/cjk.h".
1011 dst_dir=$(dirname "$dst")
1012 if ! test -d "$dst_dir"; then
1013 mkdir -p "$dst_dir"
1015 # If we've just created a directory like lib/uniwidth,
1016 # tell version control system(s) it's ignorable.
1017 # FIXME: for now, this does only one level
1018 parent=$(dirname "$dst_dir")
1019 for dot_ig in x $vc_ignore; do
1020 test $dot_ig = x && continue
1021 ig=$parent/$dot_ig
1022 insert_vc_ignore $ig "${dst_dir##*/}/"
1023 done
1026 if $copy; then
1028 test ! -h "$dst" || {
1029 echo "$me: rm -f $dst" &&
1030 rm -f "$dst"
1032 } &&
1033 test -f "$dst" &&
1034 cmp -s "$src" "$dst" || {
1035 echo "$me: cp -fp $src $dst" &&
1036 cp -fp "$src" "$dst"
1038 else
1039 # Leave any existing symlink alone, if it already points to the source,
1040 # so that broken build tools that care about symlink times
1041 # aren't confused into doing unnecessary builds. Conversely, if the
1042 # existing symlink's timestamp is older than the source, make it afresh,
1043 # so that broken tools aren't confused into skipping needed builds. See
1044 # <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00326.html>.
1045 test -h "$dst" &&
1046 src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
1047 dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
1048 test "$src_i" = "$dst_i" &&
1049 both_ls=$(ls -dt "$src" "$dst") &&
1050 test "X$both_ls" = "X$dst$nl$src" || {
1051 dot_dots=
1052 case $src in
1053 /*) ;;
1055 case /$dst/ in
1056 *//* | */../* | */./* | /*/*/*/*/*/)
1057 die "invalid symlink calculation: $src -> $dst";;
1058 /*/*/*/*/) dot_dots=../../../;;
1059 /*/*/*/) dot_dots=../../;;
1060 /*/*/) dot_dots=../;;
1061 esac;;
1062 esac
1064 echo "$me: ln -fs $dot_dots$src $dst" &&
1065 ln -fs "$dot_dots$src" "$dst"
1071 # Regenerate all autogeneratable files that are omitted from the
1072 # version control repository. In particular, regenerate all
1073 # aclocal.m4, config.h.in, Makefile.in, configure files with new
1074 # versions of autoconf or automake.
1075 autogen()
1077 # Ensure that CDPATH is not set. Otherwise, the output from cd
1078 # would cause trouble in at least one use below.
1079 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1081 # Environment variables that may be set by the user.
1082 : "${AUTOPOINT=autopoint}"
1083 : "${AUTORECONF=autoreconf}"
1085 if test "$vc_ignore" = auto; then
1086 vc_ignore=
1087 test -d .git && vc_ignore=.gitignore
1088 test -d CVS && vc_ignore="$vc_ignore .cvsignore"
1092 # Parse options.
1094 # Whether to use copies instead of symlinks.
1095 copy=false
1097 for option
1099 case $option in
1100 --help)
1101 autogen_usage
1102 return;;
1103 --version)
1104 set -e
1105 echo "autogen.sh $scriptlibversion"
1106 echo "$copyright"
1107 return 0
1109 --force)
1110 checkout_only_file=;;
1111 --copy)
1112 copy=true;;
1114 bootstrap_option_hook $option || die "$option: unknown option";;
1115 esac
1116 done
1118 test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
1119 || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir" \
1120 "option is specified, but does not denote a directory"
1122 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
1123 die "Running this script from a non-checked-out distribution is risky."
1126 if $use_gnulib; then
1127 if test -z "$GNULIB_SRCDIR"; then
1128 gnulib_path=$(test -f .gitmodules &&
1129 git config --file .gitmodules submodule.gnulib.path)
1130 test -z "$gnulib_path" && gnulib_path=gnulib
1131 GNULIB_SRCDIR=$gnulib_path
1135 # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
1136 found_aux_dir=no
1137 grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'])' configure.ac \
1138 >/dev/null && found_aux_dir=yes
1139 grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
1140 >/dev/null && found_aux_dir=yes
1141 test $found_aux_dir = yes \
1142 || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
1144 # If $build_aux doesn't exist, create it now, otherwise some bits
1145 # below will malfunction. If creating it, also mark it as ignored.
1146 if test ! -d $build_aux; then
1147 mkdir $build_aux
1148 for dot_ig in x $vc_ignore; do
1149 test $dot_ig = x && continue
1150 insert_vc_ignore $dot_ig $build_aux/
1151 done
1154 check_build_prerequisites false
1156 use_libtool=0
1157 # We'd like to use grep -E, to see if any of LT_INIT,
1158 # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
1159 # but that's not portable enough (e.g., for Solaris).
1160 grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
1161 && use_libtool=1
1162 grep '^[ ]*LT_INIT' configure.ac >/dev/null \
1163 && use_libtool=1
1164 if test $use_libtool = 1; then
1165 find_tool LIBTOOLIZE glibtoolize libtoolize
1168 if $use_gnulib; then
1169 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
1170 <$gnulib_tool || return
1173 # NOTE: we have to be careful to run both autopoint and libtoolize
1174 # before gnulib-tool, since gnulib-tool is likely to provide newer
1175 # versions of files "installed" by these two programs.
1176 # Then, *after* gnulib-tool (see below), we have to be careful to
1177 # run autoreconf in such a way that it does not run either of these
1178 # two just-pre-run programs.
1180 # Import from gettext.
1181 with_gettext=yes
1182 grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
1183 with_gettext=no
1185 if test $with_gettext = yes || test $use_libtool = 1; then
1187 tempbase=.bootstrap$$
1188 trap "rm -f $tempbase.0 $tempbase.1" HUP INT PIPE TERM
1190 > $tempbase.0 > $tempbase.1 &&
1191 find . ! -type d -print | sort > $tempbase.0 || return
1193 if test $with_gettext = yes; then
1194 # Released autopoint has the tendency to install macros that have been
1195 # obsoleted in current gnulib, so run this before gnulib-tool.
1196 echo "$0: $AUTOPOINT --force"
1197 $AUTOPOINT --force || return
1200 # Autoreconf runs aclocal before libtoolize, which causes spurious
1201 # warnings if the initial aclocal is confused by the libtoolized
1202 # (or worse out-of-date) macro directory.
1203 # libtoolize 1.9b added the --install option; but we support back
1204 # to libtoolize 1.5.22, where the install action was default.
1205 if test $use_libtool = 1; then
1206 install=
1207 case $($LIBTOOLIZE --help) in
1208 *--install*) install=--install ;;
1209 esac
1210 echo "running: $LIBTOOLIZE $install --copy"
1211 $LIBTOOLIZE $install --copy
1214 find . ! -type d -print | sort >$tempbase.1
1215 old_IFS=$IFS
1216 IFS=$nl
1217 for file in $(comm -13 $tempbase.0 $tempbase.1); do
1218 IFS=$old_IFS
1219 parent=${file%/*}
1220 version_controlled_file "$parent" "$file" || {
1221 for dot_ig in x $vc_ignore; do
1222 test $dot_ig = x && continue
1223 ig=$parent/$dot_ig
1224 insert_vc_ignore "$ig" "${file##*/}"
1225 done
1227 done
1228 IFS=$old_IFS
1230 rm -f $tempbase.0 $tempbase.1
1231 trap - HUP INT PIPE TERM
1234 # Import from gnulib.
1236 if $use_gnulib; then
1237 gnulib_tool_options="\
1238 --no-changelog\
1239 --aux-dir=$build_aux\
1240 --doc-base=$doc_base\
1241 --lib=$gnulib_name\
1242 --m4-base=$m4_base/\
1243 --source-base=$source_base/\
1244 --tests-base=$tests_base\
1245 --local-dir=$local_gl_dir\
1246 $gnulib_tool_option_extras\
1248 if test $use_libtool = 1; then
1249 case "$gnulib_tool_options " in
1250 *' --libtool '*) ;;
1251 *) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
1252 esac
1254 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
1255 $gnulib_tool $gnulib_tool_options --import $gnulib_modules \
1256 || die "gnulib-tool failed"
1258 for file in $gnulib_files; do
1259 symlink_to_dir "$GNULIB_SRCDIR" $file \
1260 || die "failed to symlink $file"
1261 done
1264 bootstrap_post_import_hook \
1265 || die "bootstrap_post_import_hook failed"
1267 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
1268 # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
1269 # The following requires GNU find 4.2.3 or newer. Considering the usual
1270 # portability constraints of this script, that may seem a very demanding
1271 # requirement, but it should be ok. Ignore any failure, which is fine,
1272 # since this is only a convenience to help developers avoid the relatively
1273 # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
1274 # between successive runs of this script.
1275 find "$m4_base" "$source_base" \
1276 -depth \( -name '*.m4' -o -name '*.[ch]' \) \
1277 -type l -xtype l -delete > /dev/null 2>&1
1279 # Invoke autoreconf with --force --install to ensure upgrades of tools
1280 # such as ylwrap.
1281 AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS"
1282 AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive"
1284 # Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
1285 echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS"
1286 AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \
1287 || die "autoreconf failed"
1289 # Get some extra files from gnulib, overriding existing files.
1290 for file in $gnulib_extra_files; do
1291 case $file in
1292 */INSTALL) dst=INSTALL;;
1293 build-aux/*) dst=$build_aux/${file#build-aux/};;
1294 *) dst=$file;;
1295 esac
1296 symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
1297 || die "failed to symlink $file"
1298 done
1300 if test $with_gettext = yes; then
1301 # Create gettext configuration.
1302 echo "$0: Creating po/Makevars from po/Makevars.template ..."
1303 rm -f po/Makevars
1304 sed '
1305 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
1306 /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
1307 /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
1308 /^XGETTEXT_OPTIONS *=/{
1309 s/$/ \\/
1311 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
1313 ' po/Makevars.template >po/Makevars \
1314 || die 'cannot generate po/Makevars'
1316 # If the 'gettext' module is in use, grab the latest Makefile.in.in.
1317 # If only the 'gettext-h' module is in use, assume autopoint already
1318 # put the correct version of this file into place.
1319 case $gnulib_modules in
1320 *gettext-h*) ;;
1321 *gettext*)
1322 cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
1323 || die "cannot create po/Makefile.in.in"
1325 esac
1327 if test -d runtime-po; then
1328 # Similarly for runtime-po/Makevars, but not quite the same.
1329 rm -f runtime-po/Makevars
1330 sed '
1331 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
1332 /^subdir *=.*/s/=.*/= runtime-po/
1333 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
1334 /^XGETTEXT_OPTIONS *=/{
1335 s/$/ \\/
1337 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
1339 ' po/Makevars.template >runtime-po/Makevars \
1340 || die 'cannot generate runtime-po/Makevars'
1342 # Copy identical files from po to runtime-po.
1343 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
1347 bootstrap_epilogue
1349 echo "$0: done. Now you can run './configure'."
1352 # ----------------------------------------------------------------------------
1354 # Local Variables:
1355 # eval: (add-hook 'before-save-hook 'time-stamp nil t)
1356 # time-stamp-start: "scriptlibversion="
1357 # time-stamp-format: "%:y-%02m-%02d.%02H"
1358 # time-stamp-time-zone: "UTC0"
1359 # time-stamp-end: "; # UTC"
1360 # End:
1362 usage() {
1363 cat <<EOF
1364 Usage: $me [OPTION]...
1365 Bootstrap this package from the checked-out sources.
1367 Optional environment variables:
1368 GNULIB_SRCDIR Specifies the local directory where gnulib
1369 sources reside. Use this if you already
1370 have gnulib sources on your machine, and
1371 you want to use these sources.
1372 GNULIB_REFDIR Specifies the local directory where a gnulib
1373 repository (with a .git subdirectory) resides.
1374 Use this if you already have gnulib sources
1375 and history on your machine, and do not want
1376 to waste your bandwidth downloading them again.
1377 Only used for phase 1 (--pull).
1378 GNULIB_URL URL of the gnulib repository. The default is
1379 $default_gnulib_url,
1380 which is Gnulib's upstream repository.
1381 Only used for phase 1 (--pull).
1383 Options:
1385 --pull Do phase 1: Pull files from the network.
1386 --gen Do phase 2: Generate files from local files
1387 (no network access).
1388 (The default is to do both phases.)
1390 --gnulib-srcdir=DIRNAME Specifies the local directory where gnulib
1391 sources reside. Use this if you already
1392 have gnulib sources on your machine, and
1393 you want to use these sources. Defaults
1394 to \$GNULIB_SRCDIR.
1395 --gnulib-refdir=DIRNAME Specifies the local directory where a gnulib
1396 repository (with a .git subdirectory) resides.
1397 Use this if you already have gnulib sources
1398 and history on your machine, and do not want
1399 to waste your bandwidth downloading them again.
1400 Defaults to \$GNULIB_REFDIR.
1401 Only used for phase 1 (--pull).
1403 --bootstrap-sync If this bootstrap script is not identical to
1404 the version in the local gnulib sources,
1405 update this script, and then restart it with
1406 /bin/sh or the shell \$CONFIG_SHELL.
1407 --no-bootstrap-sync Do not check whether bootstrap is out of sync.
1409 --copy Copy files instead of creating symbolic links.
1410 Only used for phase 2 (--gen).
1411 --force Attempt to bootstrap even if the sources seem
1412 not to have been checked out.
1413 --no-git Do not use git to update gnulib. Requires that
1414 \$GNULIB_SRCDIR or the --gnulib-srcdir option
1415 points to a gnulib repository with the correct
1416 revision.
1417 Only used for phase 1 (--pull).
1418 --skip-po Do not download *.po files.
1419 Only used for phase 1 (--pull).
1421 bootstrap_print_option_usage_hook
1422 cat <<EOF
1423 If the file bootstrap.conf exists in the same directory as this script, its
1424 contents are read as shell variables to configure the bootstrap.
1426 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
1427 are honored.
1429 Gnulib sources can be fetched in various ways:
1431 * If GNULIB_SRCDIR is set (either as an environment variable or via the
1432 --gnulib-srcdir option), then sources are fetched from that local
1433 directory. If it is a git repository and the configuration variable
1434 GNULIB_REVISION is set in bootstrap.conf, then that revision is
1435 checked out.
1437 * Otherwise, if this package is in a git repository with a 'gnulib'
1438 submodule configured, then that submodule is initialized and updated
1439 and sources are fetched from there. If GNULIB_REFDIR is set (either
1440 as an environment variable or via the --gnulib-refdir option) and is
1441 a git repository, then it is used as a reference.
1443 * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
1444 are cloned into that directory using git from \$GNULIB_URL, defaulting
1445 to $default_gnulib_url.
1446 If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
1447 then that revision is checked out.
1449 * Otherwise, the existing Gnulib sources in the 'gnulib' directory are
1450 used. If it is a git repository and the configuration variable
1451 GNULIB_REVISION is set in bootstrap.conf, then that revision is
1452 checked out.
1454 If you maintain a package and want to pin a particular revision of the
1455 Gnulib sources that has been tested with your package, then there are
1456 two possible approaches: either configure a 'gnulib' submodule with the
1457 appropriate revision, or set GNULIB_REVISION (and if necessary
1458 GNULIB_URL) in bootstrap.conf.
1460 Running without arguments will suffice in most cases.
1464 # Parse options.
1466 # Whether to pull and generate.
1467 pull=false
1468 gen=false
1470 # Whether to use copies instead of symlinks.
1471 copy=false
1473 # Use git to update gnulib sources
1474 use_git=true
1476 for option
1478 case $option in
1479 --help)
1480 usage
1481 exit;;
1482 --version)
1483 set -e
1484 echo "bootstrap $scriptversion lib $scriptlibversion"
1485 echo "$copyright"
1486 exit 0
1488 --pull)
1489 pull=true;;
1490 --gen)
1491 gen=true;;
1492 --gnulib-srcdir=*)
1493 GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
1494 --gnulib-refdir=*)
1495 GNULIB_REFDIR=${option#--gnulib-refdir=};;
1496 --skip-po)
1497 SKIP_PO=t;;
1498 --force)
1499 checkout_only_file=;;
1500 --copy)
1501 copy=true;;
1502 --bootstrap-sync)
1503 bootstrap_sync=true;;
1504 --no-bootstrap-sync)
1505 bootstrap_sync=false;;
1506 --no-git)
1507 use_git=false;;
1509 bootstrap_option_hook $option || die "$option: unknown option";;
1510 esac
1511 done
1513 # Default is to do both.
1514 $pull || $gen || pull=true gen=true
1516 $use_git || test -n "$GNULIB_SRCDIR" \
1517 || die "Error: --no-git requires \$GNULIB_SRCDIR environment variable" \
1518 "or --gnulib-srcdir option"
1519 test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
1520 || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir" \
1521 "option is specified, but does not denote a directory"
1523 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
1524 die "Bootstrapping from a non-checked-out distribution is risky."
1527 check_build_prerequisites $use_git
1529 if $bootstrap_sync; then
1530 prepare_GNULIB_SRCDIR
1531 upgrade_bootstrap "$@"
1532 # Since we have now upgraded if needed, no need to try it a second time below.
1533 bootstrap_sync=false
1536 echo "$0: Bootstrapping from checked-out $package sources..."
1538 # Pass GNULIB_SRCDIR and GNULIB_REFDIR to any subsidiary commands that care.
1539 export GNULIB_SRCDIR
1540 export GNULIB_REFDIR
1542 if $pull && { $use_git || test -z "$SKIP_PO"; }; then
1543 autopull \
1544 `if $bootstrap_sync; then
1545 echo ' --bootstrap-sync'
1546 else
1547 echo ' --no-bootstrap-sync'
1548 fi` \
1549 `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
1550 `if ! $use_git; then echo ' --no-git'; fi` \
1551 `if test -n "$SKIP_PO"; then echo ' --skip-po'; fi` \
1552 || die "could not fetch auxiliary files"
1555 if $gen; then
1556 autogen \
1557 `if $copy; then echo ' --copy'; fi` \
1558 `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
1559 || die "could not generate auxiliary files"
1562 # ----------------------------------------------------------------------------
1564 # Local Variables:
1565 # eval: (add-hook 'before-save-hook 'time-stamp nil t)
1566 # time-stamp-start: "scriptversion="
1567 # time-stamp-format: "%:y-%02m-%02d.%02H"
1568 # time-stamp-time-zone: "UTC0"
1569 # time-stamp-end: "; # UTC"
1570 # End: