Debian Codegraph @

bootstrap

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