Make documentation compile with pandoc 1.14 and newer.
[ttfautohint.git] / bootstrap
blob4f0493ad9a185a14f238b8a76778d89218a396c7
1 #! /bin/sh
2 # Print a version string.
3 scriptversion=2013-12-05.23; # UTC
5 # Bootstrap this package from checked-out sources.
7 # Copyright (C) 2003-2014 Free Software Foundation, Inc.
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # Originally written by Paul Eggert. The canonical version of this
23 # script is maintained as build-aux/bootstrap in gnulib, however, to
24 # be useful to your project, you should place a copy of it under
25 # version control in the top-level directory of your project. The
26 # intent is that all customization can be done with a bootstrap.conf
27 # file also maintained in your version control; gnulib comes with a
28 # template build-aux/bootstrap.conf to get you started.
30 # Please report bugs or propose patches to bug-gnulib@gnu.org.
32 nl='
35 # Ensure file names are sorted consistently across platforms.
36 LC_ALL=C
37 export LC_ALL
39 # Ensure that CDPATH is not set. Otherwise, the output from cd
40 # would cause trouble in at least one use below.
41 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
43 local_gl_dir=gl
45 me=$0
47 usage() {
48 cat <<EOF
49 Usage: $me [OPTION]...
50 Bootstrap this package from the checked-out sources.
52 Options:
53 --gnulib-srcdir=DIRNAME specify the local directory where gnulib
54 sources reside. Use this if you already
55 have gnulib sources on your machine, and
56 do not want to waste your bandwidth downloading
57 them again. Defaults to \$GNULIB_SRCDIR
58 --bootstrap-sync if this bootstrap script is not identical to
59 the version in the local gnulib sources,
60 update this script, and then restart it with
61 /bin/sh or the shell \$CONFIG_SHELL
62 --no-bootstrap-sync do not check whether bootstrap is out of sync
63 --copy copy files instead of creating symbolic links
64 --force attempt to bootstrap even if the sources seem
65 not to have been checked out
66 --no-git do not use git to update gnulib. Requires that
67 --gnulib-srcdir point to a correct gnulib snapshot
68 --skip-po do not download po files
70 If the file $me.conf exists in the same directory as this script, its
71 contents are read as shell variables to configure the bootstrap.
73 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
74 are honored.
76 Running without arguments will suffice in most cases.
77 EOF
80 # warnf_ FORMAT-STRING ARG1...
81 warnf_ ()
83 warnf_format_=$1
84 shift
85 nl='
87 case $* in
88 *$nl*) me_=$(printf "$me"|tr "$nl|" '??')
89 printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
90 *) printf "$me: $warnf_format_" "$@" ;;
91 esac >&2
94 # warn_ WORD1...
95 warn_ ()
97 # If IFS does not start with ' ', set it and emit the warning in a subshell.
98 case $IFS in
99 ' '*) warnf_ '%s\n' "$*";;
100 *) (IFS=' '; warn_ "$@");;
101 esac
104 # die WORD1...
105 die() { warn_ "$@"; exit 1; }
107 # Configuration.
109 # Name of the Makefile.am
110 gnulib_mk=gnulib.mk
112 # List of gnulib modules needed.
113 gnulib_modules=
115 # Any gnulib files needed that are not in modules.
116 gnulib_files=
118 : ${AUTOPOINT=autopoint}
119 : ${AUTORECONF=autoreconf}
121 # A function to be called right after gnulib-tool is run.
122 # Override it via your own definition in bootstrap.conf.
123 bootstrap_post_import_hook() { :; }
125 # A function to be called after everything else in this script.
126 # Override it via your own definition in bootstrap.conf.
127 bootstrap_epilogue() { :; }
129 # The command to download all .po files for a specified domain into
130 # a specified directory. Fill in the first %s is the domain name, and
131 # the second with the destination directory. Use rsync's -L and -r
132 # options because the latest/%s directory and the .po files within are
133 # all symlinks.
134 po_download_command_format=\
135 "rsync --delete --exclude '*.s1' -Lrtvz \
136 'translationproject.org::tp/latest/%s/' '%s'"
138 # Fallback for downloading .po files (if rsync fails).
139 po_download_command_format2=\
140 "wget --mirror -nd -q -np -A.po -P '%s' \
141 http://translationproject.org/latest/%s/"
143 # Prefer a non-empty tarname (4th argument of AC_INIT if given), else
144 # fall back to the package name (1st argument with munging)
145 extract_package_name='
146 /^AC_INIT(\[*/{
147 s///
148 /^[^,]*,[^,]*,[^,]*,[ []*\([^][ ,)]\)/{
149 s//\1/
150 s/[],)].*//
154 s/[],)].*//
155 s/^GNU //
156 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
157 s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
161 package=$(sed -n "$extract_package_name" configure.ac) \
162 || die 'cannot find package name in configure.ac'
163 gnulib_name=lib$package
165 build_aux=build-aux
166 source_base=lib
167 m4_base=m4
168 doc_base=doc
169 tests_base=tests
170 gnulib_extra_files=''
172 # Additional gnulib-tool options to use. Use "\newline" to break lines.
173 gnulib_tool_option_extras=
175 # Other locale categories that need message catalogs.
176 EXTRA_LOCALE_CATEGORIES=
178 # Additional xgettext options to use. Use "\\\newline" to break lines.
179 XGETTEXT_OPTIONS='\\\
180 --flag=_:1:pass-c-format\\\
181 --flag=N_:1:pass-c-format\\\
182 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
185 # Package bug report address and copyright holder for gettext files
186 COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
187 MSGID_BUGS_ADDRESS=bug-$package@gnu.org
189 # Files we don't want to import.
190 excluded_files=
192 # File that should exist in the top directory of a checked out hierarchy,
193 # but not in a distribution tarball.
194 checkout_only_file=README-hacking
196 # Whether to use copies instead of symlinks.
197 copy=false
199 # Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
200 # those files to be generated in directories like lib/, m4/, and po/.
201 # Or set it to 'auto' to make this script select which to use based
202 # on which version control system (if any) is used in the source directory.
203 vc_ignore=auto
205 # Set this to true in bootstrap.conf to enable --bootstrap-sync by
206 # default.
207 bootstrap_sync=false
209 # Use git to update gnulib sources
210 use_git=true
212 check_exists() {
213 if test "$1" = "--verbose"; then
214 ($2 --version </dev/null) >/dev/null 2>&1
215 if test $? -ge 126; then
216 # If not found, run with diagnostics as one may be
217 # presented with env variables to set to find the right version
218 ($2 --version </dev/null)
220 else
221 ($1 --version </dev/null) >/dev/null 2>&1
224 test $? -lt 126
227 # find_tool ENVVAR NAMES...
228 # -------------------------
229 # Search for a required program. Use the value of ENVVAR, if set,
230 # otherwise find the first of the NAMES that can be run.
231 # If found, set ENVVAR to the program name, die otherwise.
233 # FIXME: code duplication, see also gnu-web-doc-update.
234 find_tool ()
236 find_tool_envvar=$1
237 shift
238 find_tool_names=$@
239 eval "find_tool_res=\$$find_tool_envvar"
240 if test x"$find_tool_res" = x; then
241 for i; do
242 if check_exists $i; then
243 find_tool_res=$i
244 break
246 done
248 if test x"$find_tool_res" = x; then
249 warn_ "one of these is required: $find_tool_names;"
250 die "alternatively set $find_tool_envvar to a compatible tool"
252 eval "$find_tool_envvar=\$find_tool_res"
253 eval "export $find_tool_envvar"
256 # Override the default configuration, if necessary.
257 # Make sure that bootstrap.conf is sourced from the current directory
258 # if we were invoked as "sh bootstrap".
259 case "$0" in
260 */*) test -r "$0.conf" && . "$0.conf" ;;
261 *) test -r "$0.conf" && . ./"$0.conf" ;;
262 esac
264 # Extra files from gnulib, which override files from other sources.
265 test -z "${gnulib_extra_files}" && \
266 gnulib_extra_files="
267 build-aux/install-sh
268 build-aux/mdate-sh
269 build-aux/texinfo.tex
270 build-aux/depcomp
271 build-aux/config.guess
272 build-aux/config.sub
273 doc/INSTALL
276 if test "$vc_ignore" = auto; then
277 vc_ignore=
278 test -d .git && vc_ignore=.gitignore
279 test -d CVS && vc_ignore="$vc_ignore .cvsignore"
282 # Translate configuration into internal form.
284 # Parse options.
286 for option
288 case $option in
289 --help)
290 usage
291 exit;;
292 --gnulib-srcdir=*)
293 GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
294 --skip-po)
295 SKIP_PO=t;;
296 --force)
297 checkout_only_file=;;
298 --copy)
299 copy=true;;
300 --bootstrap-sync)
301 bootstrap_sync=true;;
302 --no-bootstrap-sync)
303 bootstrap_sync=false;;
304 --no-git)
305 use_git=false;;
307 die "$option: unknown option";;
308 esac
309 done
311 $use_git || test -d "$GNULIB_SRCDIR" \
312 || die "Error: --no-git requires --gnulib-srcdir"
314 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
315 die "Bootstrapping from a non-checked-out distribution is risky."
318 # Strip blank and comment lines to leave significant entries.
319 gitignore_entries() {
320 sed '/^#/d; /^$/d' "$@"
323 # If $STR is not already on a line by itself in $FILE, insert it at the start.
324 # Entries are inserted at the start of the ignore list to ensure existing
325 # entries starting with ! are not overridden. Such entries support
326 # whitelisting exceptions after a more generic blacklist pattern.
327 insert_if_absent() {
328 file=$1
329 str=$2
330 test -f $file || touch $file
331 test -r $file || die "Error: failed to read ignore file: $file"
332 duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
333 if [ "$duplicate_entries" ] ; then
334 die "Error: Duplicate entries in $file: " $duplicate_entries
336 linesold=$(gitignore_entries $file | wc -l)
337 linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
338 if [ $linesold != $linesnew ] ; then
339 { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
340 || die "insert_if_absent $file $str: failed"
344 # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
345 # insert_if_absent.
346 insert_vc_ignore() {
347 vc_ignore_file="$1"
348 pattern="$2"
349 case $vc_ignore_file in
350 *.gitignore)
351 # A .gitignore entry that does not start with '/' applies
352 # recursively to subdirectories, so prepend '/' to every
353 # .gitignore entry.
354 pattern=$(echo "$pattern" | sed s,^,/,);;
355 esac
356 insert_if_absent "$vc_ignore_file" "$pattern"
359 # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
360 found_aux_dir=no
361 grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
362 >/dev/null && found_aux_dir=yes
363 grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
364 >/dev/null && found_aux_dir=yes
365 test $found_aux_dir = yes \
366 || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
368 # If $build_aux doesn't exist, create it now, otherwise some bits
369 # below will malfunction. If creating it, also mark it as ignored.
370 if test ! -d $build_aux; then
371 mkdir $build_aux
372 for dot_ig in x $vc_ignore; do
373 test $dot_ig = x && continue
374 insert_vc_ignore $dot_ig $build_aux
375 done
378 # Note this deviates from the version comparison in automake
379 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
380 # but this should suffice as we won't be specifying old
381 # version formats or redundant trailing .0 in bootstrap.conf.
382 # If we did want full compatibility then we should probably
383 # use m4_version_compare from autoconf.
384 sort_ver() { # sort -V is not generally available
385 ver1="$1"
386 ver2="$2"
388 # split on '.' and compare each component
390 while : ; do
391 p1=$(echo "$ver1" | cut -d. -f$i)
392 p2=$(echo "$ver2" | cut -d. -f$i)
393 if [ ! "$p1" ]; then
394 echo "$1 $2"
395 break
396 elif [ ! "$p2" ]; then
397 echo "$2 $1"
398 break
399 elif [ ! "$p1" = "$p2" ]; then
400 if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
401 echo "$2 $1"
402 elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
403 echo "$1 $2"
404 else # numeric, then lexicographic comparison
405 lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
406 if [ "$lp" = "$p2" ]; then
407 echo "$1 $2"
408 else
409 echo "$2 $1"
412 break
414 i=$(($i+1))
415 done
418 get_version() {
419 app=$1
421 $app --version >/dev/null 2>&1 || { $app --version; return 1; }
423 $app --version 2>&1 |
424 sed -n '# Move version to start of line.
425 s/.*[v ]\([0-9]\)/\1/
427 # Skip lines that do not start with version.
428 /^[0-9]/!d
430 # Remove characters after the version.
431 s/[^.a-z0-9-].*//
433 # The first component must be digits only.
434 s/^\([0-9]*\)[a-z-].*/\1/
436 #the following essentially does s/5.005/5.5/
437 s/\.0*\([1-9]\)/.\1/g
442 check_versions() {
443 ret=0
445 while read app req_ver; do
446 # We only need libtoolize from the libtool package.
447 if test "$app" = libtool; then
448 app=libtoolize
450 # Exempt git if --no-git is in effect.
451 if test "$app" = git; then
452 $use_git || continue
454 # Honor $APP variables ($TAR, $AUTOCONF, etc.)
455 appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_')
456 test "$appvar" = TAR && appvar=AMTAR
457 case $appvar in
458 GZIP) ;; # Do not use $GZIP: it contains gzip options.
459 *) eval "app=\${$appvar-$app}" ;;
460 esac
462 # Handle the still-experimental Automake-NG programs specially.
463 # They remain named as the mainstream Automake programs ("automake",
464 # and "aclocal") to avoid gratuitous incompatibilities with
465 # pre-existing usages (by, say, autoreconf, or custom autogen.sh
466 # scripts), but correctly identify themselves (as being part of
467 # "GNU automake-ng") when asked their version.
468 case $app in
469 automake-ng|aclocal-ng)
470 app=${app%-ng}
471 ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
472 warn_ "Error: '$app' not found or not from Automake-NG"
473 ret=1
474 continue
475 } ;;
476 esac
477 if [ "$req_ver" = "-" ]; then
478 # Merely require app to exist; not all prereq apps are well-behaved
479 # so we have to rely on $? rather than get_version.
480 if ! check_exists --verbose $app; then
481 warn_ "Error: '$app' not found"
482 ret=1
484 else
485 # Require app to produce a new enough version string.
486 inst_ver=$(get_version $app)
487 if [ ! "$inst_ver" ]; then
488 warn_ "Error: '$app' not found"
489 ret=1
490 else
491 latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
492 if [ ! "$latest_ver" = "$inst_ver" ]; then
493 warnf_ '%s\n' \
494 "Error: '$app' version == $inst_ver is too old" \
495 " '$app' version >= $req_ver is required"
496 ret=1
500 done
502 return $ret
505 print_versions() {
506 echo "Program Min_version"
507 echo "----------------------"
508 printf %s "$buildreq"
509 echo "----------------------"
510 # can't depend on column -t
513 # Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6.
514 # Also find the compatible sha1 utility on the BSDs
515 if test x"$SKIP_PO" = x; then
516 find_tool SHA1SUM sha1sum gsha1sum shasum sha1
519 use_libtool=0
520 # We'd like to use grep -E, to see if any of LT_INIT,
521 # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
522 # but that's not portable enough (e.g., for Solaris).
523 grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
524 && use_libtool=1
525 grep '^[ ]*LT_INIT' configure.ac >/dev/null \
526 && use_libtool=1
527 if test $use_libtool = 1; then
528 find_tool LIBTOOLIZE glibtoolize libtoolize
531 # gnulib-tool requires at least automake and autoconf.
532 # If either is not listed, add it (with minimum version) as a prerequisite.
533 case $buildreq in
534 *automake*) ;;
535 *) buildreq="automake 1.9
536 $buildreq" ;;
537 esac
538 case $buildreq in
539 *autoconf*) ;;
540 *) buildreq="autoconf 2.59
541 $buildreq" ;;
542 esac
544 # When we can deduce that gnulib-tool will require patch,
545 # and when patch is not already listed as a prerequisite, add it, too.
546 if test -d "$local_gl_dir" \
547 && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then
548 case $buildreq in
549 *patch*) ;;
550 *) buildreq="patch -
551 $buildreq" ;;
552 esac
555 if ! printf "$buildreq" | check_versions; then
556 echo >&2
557 if test -f README-prereq; then
558 die "See README-prereq for how to get the prerequisite programs"
559 else
560 die "Please install the prerequisite programs"
564 # Warn the user if autom4te appears to be broken; this causes known
565 # issues with at least gettext 0.18.3.
566 probe=$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -)
567 if test "x$probe" != xhi; then
568 warn_ "WARNING: your autom4te wrapper eats stdin;"
569 warn_ "if bootstrap fails, consider upgrading your autotools"
572 echo "$0: Bootstrapping from checked-out $package sources..."
574 # See if we can use gnulib's git-merge-changelog merge driver.
575 if $use_git && test -d .git && check_exists git; then
576 if git config merge.merge-changelog.driver >/dev/null ; then
578 elif check_exists git-merge-changelog; then
579 echo "$0: initializing git-merge-changelog driver"
580 git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
581 git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
582 else
583 echo "$0: consider installing git-merge-changelog from gnulib"
588 cleanup_gnulib() {
589 status=$?
590 rm -fr "$gnulib_path"
591 exit $status
594 git_modules_config () {
595 test -f .gitmodules && git config --file .gitmodules "$@"
598 if $use_git; then
599 gnulib_path=$(git_modules_config submodule.gnulib.path)
600 test -z "$gnulib_path" && gnulib_path=gnulib
603 # Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a
604 # submodule, for use in the rest of the script.
606 case ${GNULIB_SRCDIR--} in
608 # Note that $use_git is necessarily true in this case.
609 if git_modules_config submodule.gnulib.url >/dev/null; then
610 echo "$0: getting gnulib files..."
611 git submodule init -- "$gnulib_path" || exit $?
612 git submodule update -- "$gnulib_path" || exit $?
614 elif [ ! -d "$gnulib_path" ]; then
615 echo "$0: getting gnulib files..."
617 trap cleanup_gnulib 1 2 13 15
619 shallow=
620 git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
621 git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
622 cleanup_gnulib
624 trap - 1 2 13 15
626 GNULIB_SRCDIR=$gnulib_path
629 # Use GNULIB_SRCDIR directly or as a reference.
630 if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
631 git_modules_config submodule.gnulib.url >/dev/null; then
632 echo "$0: getting gnulib files..."
633 if git submodule -h|grep -- --reference > /dev/null; then
634 # Prefer the one-liner available in git 1.6.4 or newer.
635 git submodule update --init --reference "$GNULIB_SRCDIR" \
636 "$gnulib_path" || exit $?
637 else
638 # This fallback allows at least git 1.5.5.
639 if test -f "$gnulib_path"/gnulib-tool; then
640 # Since file already exists, assume submodule init already complete.
641 git submodule update -- "$gnulib_path" || exit $?
642 else
643 # Older git can't clone into an empty directory.
644 rmdir "$gnulib_path" 2>/dev/null
645 git clone --reference "$GNULIB_SRCDIR" \
646 "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
647 && git submodule init -- "$gnulib_path" \
648 && git submodule update -- "$gnulib_path" \
649 || exit $?
652 GNULIB_SRCDIR=$gnulib_path
655 esac
657 # $GNULIB_SRCDIR now points to the version of gnulib to use, and
658 # we no longer need to use git or $gnulib_path below here.
660 if $bootstrap_sync; then
661 cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
662 echo "$0: updating bootstrap and restarting..."
663 case $(sh -c 'echo "$1"' -- a) in
664 a) ignored=--;;
665 *) ignored=ignored;;
666 esac
667 exec sh -c \
668 'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
669 $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
670 "$0" "$@" --no-bootstrap-sync
674 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
675 <$gnulib_tool || exit $?
677 # Get translations.
679 download_po_files() {
680 subdir=$1
681 domain=$2
682 echo "$me: getting translations into $subdir for $domain..."
683 cmd=$(printf "$po_download_command_format" "$domain" "$subdir")
684 eval "$cmd" && return
685 # Fallback to HTTP.
686 cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
687 eval "$cmd"
690 # Mirror .po files to $po_dir/.reference and copy only the new
691 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
692 # Note po files that exist locally only are left in $po_dir but will
693 # not be included in LINGUAS and hence will not be distributed.
694 update_po_files() {
695 # Directory containing primary .po files.
696 # Overwrite them only when we're sure a .po file is new.
697 po_dir=$1
698 domain=$2
700 # Mirror *.po files into this dir.
701 # Usually contains *.s1 checksum files.
702 ref_po_dir="$po_dir/.reference"
704 test -d $ref_po_dir || mkdir $ref_po_dir || return
705 download_po_files $ref_po_dir $domain \
706 && ls "$ref_po_dir"/*.po 2>/dev/null |
707 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
709 langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g')
710 test "$langs" = '*' && langs=x
711 for po in $langs; do
712 case $po in x) continue;; esac
713 new_po="$ref_po_dir/$po.po"
714 cksum_file="$ref_po_dir/$po.s1"
715 if ! test -f "$cksum_file" ||
716 ! test -f "$po_dir/$po.po" ||
717 ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then
718 echo "$me: updated $po_dir/$po.po..."
719 cp "$new_po" "$po_dir/$po.po" \
720 && $SHA1SUM < "$new_po" > "$cksum_file" || return
722 done
725 case $SKIP_PO in
727 if test -d po; then
728 update_po_files po $package || exit
731 if test -d runtime-po; then
732 update_po_files runtime-po $package-runtime || exit
733 fi;;
734 esac
736 symlink_to_dir()
738 src=$1/$2
739 dst=${3-$2}
741 test -f "$src" && {
743 # If the destination directory doesn't exist, create it.
744 # This is required at least for "lib/uniwidth/cjk.h".
745 dst_dir=$(dirname "$dst")
746 if ! test -d "$dst_dir"; then
747 mkdir -p "$dst_dir"
749 # If we've just created a directory like lib/uniwidth,
750 # tell version control system(s) it's ignorable.
751 # FIXME: for now, this does only one level
752 parent=$(dirname "$dst_dir")
753 for dot_ig in x $vc_ignore; do
754 test $dot_ig = x && continue
755 ig=$parent/$dot_ig
756 insert_vc_ignore $ig "${dst_dir##*/}"
757 done
760 if $copy; then
762 test ! -h "$dst" || {
763 echo "$me: rm -f $dst" &&
764 rm -f "$dst"
766 } &&
767 test -f "$dst" &&
768 cmp -s "$src" "$dst" || {
769 echo "$me: cp -fp $src $dst" &&
770 cp -fp "$src" "$dst"
772 else
773 # Leave any existing symlink alone, if it already points to the source,
774 # so that broken build tools that care about symlink times
775 # aren't confused into doing unnecessary builds. Conversely, if the
776 # existing symlink's time stamp is older than the source, make it afresh,
777 # so that broken tools aren't confused into skipping needed builds. See
778 # <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
779 test -h "$dst" &&
780 src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
781 dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
782 test "$src_i" = "$dst_i" &&
783 both_ls=$(ls -dt "$src" "$dst") &&
784 test "X$both_ls" = "X$dst$nl$src" || {
785 dot_dots=
786 case $src in
787 /*) ;;
789 case /$dst/ in
790 *//* | */../* | */./* | /*/*/*/*/*/)
791 die "invalid symlink calculation: $src -> $dst";;
792 /*/*/*/*/) dot_dots=../../../;;
793 /*/*/*/) dot_dots=../../;;
794 /*/*/) dot_dots=../;;
795 esac;;
796 esac
798 echo "$me: ln -fs $dot_dots$src $dst" &&
799 ln -fs "$dot_dots$src" "$dst"
805 version_controlled_file() {
806 parent=$1
807 file=$2
808 if test -d .git; then
809 git rm -n "$file" > /dev/null 2>&1
810 elif test -d .svn; then
811 svn log -r HEAD "$file" > /dev/null 2>&1
812 elif test -d CVS; then
813 grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
814 grep '^/[^/]*/[0-9]' > /dev/null
815 else
816 warn_ "no version control for $file?"
817 false
821 # NOTE: we have to be careful to run both autopoint and libtoolize
822 # before gnulib-tool, since gnulib-tool is likely to provide newer
823 # versions of files "installed" by these two programs.
824 # Then, *after* gnulib-tool (see below), we have to be careful to
825 # run autoreconf in such a way that it does not run either of these
826 # two just-pre-run programs.
828 # Import from gettext.
829 with_gettext=yes
830 grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
831 with_gettext=no
833 if test $with_gettext = yes || test $use_libtool = 1; then
835 tempbase=.bootstrap$$
836 trap "rm -f $tempbase.0 $tempbase.1" 1 2 13 15
838 > $tempbase.0 > $tempbase.1 &&
839 find . ! -type d -print | sort > $tempbase.0 || exit
841 if test $with_gettext = yes; then
842 # Released autopoint has the tendency to install macros that have been
843 # obsoleted in current gnulib, so run this before gnulib-tool.
844 echo "$0: $AUTOPOINT --force"
845 $AUTOPOINT --force || exit
848 # Autoreconf runs aclocal before libtoolize, which causes spurious
849 # warnings if the initial aclocal is confused by the libtoolized
850 # (or worse out-of-date) macro directory.
851 # libtoolize 1.9b added the --install option; but we support back
852 # to libtoolize 1.5.22, where the install action was default.
853 if test $use_libtool = 1; then
854 install=
855 case $($LIBTOOLIZE --help) in
856 *--install*) install=--install ;;
857 esac
858 echo "running: $LIBTOOLIZE $install --copy"
859 $LIBTOOLIZE $install --copy
862 find . ! -type d -print | sort >$tempbase.1
863 old_IFS=$IFS
864 IFS=$nl
865 for file in $(comm -13 $tempbase.0 $tempbase.1); do
866 IFS=$old_IFS
867 parent=${file%/*}
868 version_controlled_file "$parent" "$file" || {
869 for dot_ig in x $vc_ignore; do
870 test $dot_ig = x && continue
871 ig=$parent/$dot_ig
872 insert_vc_ignore "$ig" "${file##*/}"
873 done
875 done
876 IFS=$old_IFS
878 rm -f $tempbase.0 $tempbase.1
879 trap - 1 2 13 15
882 # Import from gnulib.
884 gnulib_tool_options="\
885 --import\
886 --no-changelog\
887 --aux-dir $build_aux\
888 --doc-base $doc_base\
889 --lib $gnulib_name\
890 --m4-base $m4_base/\
891 --source-base $source_base/\
892 --tests-base $tests_base\
893 --local-dir $local_gl_dir\
894 $gnulib_tool_option_extras\
896 if test $use_libtool = 1; then
897 case "$gnulib_tool_options " in
898 *' --libtool '*) ;;
899 *) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
900 esac
902 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
903 $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
905 for file in $gnulib_files; do
906 symlink_to_dir "$GNULIB_SRCDIR" $file \
907 || die "failed to symlink $file"
908 done
910 bootstrap_post_import_hook \
911 || die "bootstrap_post_import_hook failed"
913 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
914 # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
915 # The following requires GNU find 4.2.3 or newer. Considering the usual
916 # portability constraints of this script, that may seem a very demanding
917 # requirement, but it should be ok. Ignore any failure, which is fine,
918 # since this is only a convenience to help developers avoid the relatively
919 # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
920 # between successive runs of this script.
921 find "$m4_base" "$source_base" \
922 -depth \( -name '*.m4' -o -name '*.[ch]' \) \
923 -type l -xtype l -delete > /dev/null 2>&1
925 # Invoke autoreconf with --force --install to ensure upgrades of tools
926 # such as ylwrap.
927 AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS"
929 # Some systems (RHEL 5) are using ancient autotools, for which the
930 # --no-recursive option had not been invented. Detect that lack and
931 # omit the option when it's not supported. FIXME in 2017: remove this
932 # hack when RHEL 5 autotools are updated, or when they become irrelevant.
933 case $($AUTORECONF --help) in
934 *--no-recursive*) AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive";;
935 esac
937 # Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
938 echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS"
939 AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \
940 || die "autoreconf failed"
942 # Get some extra files from gnulib, overriding existing files.
943 for file in $gnulib_extra_files; do
944 case $file in
945 */INSTALL) dst=INSTALL;;
946 build-aux/*) dst=$build_aux/${file#build-aux/};;
947 *) dst=$file;;
948 esac
949 symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
950 || die "failed to symlink $file"
951 done
953 if test $with_gettext = yes; then
954 # Create gettext configuration.
955 echo "$0: Creating po/Makevars from po/Makevars.template ..."
956 rm -f po/Makevars
957 sed '
958 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
959 /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
960 /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
961 /^XGETTEXT_OPTIONS *=/{
962 s/$/ \\/
964 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
966 ' po/Makevars.template >po/Makevars \
967 || die 'cannot generate po/Makevars'
969 # If the 'gettext' module is in use, grab the latest Makefile.in.in.
970 # If only the 'gettext-h' module is in use, assume autopoint already
971 # put the correct version of this file into place.
972 case $gnulib_modules in
973 *gettext-h*) ;;
974 *gettext*)
975 cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
976 || die "cannot create po/Makefile.in.in"
978 esac
980 if test -d runtime-po; then
981 # Similarly for runtime-po/Makevars, but not quite the same.
982 rm -f runtime-po/Makevars
983 sed '
984 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
985 /^subdir *=.*/s/=.*/= runtime-po/
986 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
987 /^XGETTEXT_OPTIONS *=/{
988 s/$/ \\/
990 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
992 ' po/Makevars.template >runtime-po/Makevars \
993 || die 'cannot generate runtime-po/Makevars'
995 # Copy identical files from po to runtime-po.
996 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
1000 bootstrap_epilogue
1002 echo "$0: done. Now you can run './configure'."
1004 # Local variables:
1005 # eval: (add-hook 'write-file-hooks 'time-stamp)
1006 # time-stamp-start: "scriptversion="
1007 # time-stamp-format: "%:y-%02m-%02d.%02H"
1008 # time-stamp-time-zone: "UTC"
1009 # time-stamp-end: "; # UTC"
1010 # End: