Commit 30bc0edd 30bc0edd27e8d5eb6fa49aa26624c1dfb7cb2f38 by Sergey Poznyakoff

Add gnulib as a module

1 parent a41e62b9
...@@ -28,7 +28,6 @@ configure ...@@ -28,7 +28,6 @@ configure
28 core 28 core
29 git-describe 29 git-describe
30 git-describe.h 30 git-describe.h
31 gnulib
32 libtool 31 libtool
33 m4 32 m4
34 mailutils*.tar.* 33 mailutils*.tar.*
......
...@@ -4,3 +4,6 @@ ...@@ -4,3 +4,6 @@
4 [submodule "doc/imprimatur"] 4 [submodule "doc/imprimatur"]
5 path = doc/imprimatur 5 path = doc/imprimatur
6 url = git://git.gnu.org.ua/imprimatur.git 6 url = git://git.gnu.org.ua/imprimatur.git
7 [submodule "gnulib"]
8 path = gnulib
9 url = git://git.sv.gnu.org/gnulib.git
......
...@@ -15,7 +15,6 @@ version. ...@@ -15,7 +15,6 @@ version.
15 - M4 <http://www.gnu.org/software/m4/> 15 - M4 <http://www.gnu.org/software/m4/>
16 - Texinfo <http://www.gnu.org/software/texinfo> 16 - Texinfo <http://www.gnu.org/software/texinfo>
17 - Wget <http://www.gnu.org/software/wget/> 17 - Wget <http://www.gnu.org/software/wget/>
18 - Gnulib <http://www.gnu.org/software/gnulib>
19 - Git <http://git.or.cz> 18 - Git <http://git.or.cz>
20 19
21 * Bootstrapping 20 * Bootstrapping
......
1 #! /bin/sh 1 #! /bin/sh
2 # Print a version string.
3 scriptversion=2014-12-08.12; # UTC
2 4
3 # Bootstrap this package from checked-out sources. 5 # Bootstrap this package from checked-out sources.
4 6
5 # Copyright (C) 2003-2008, 2010-2012, 2014-2015 Free Software 7 # Copyright (C) 2003-2015 Free Software Foundation, Inc.
6 # Foundation, Inc.
7 8
8 # This program is free software: you can redistribute it and/or modify 9 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by 10 # it under the terms of the GNU General Public License as published by
...@@ -18,7 +19,15 @@ ...@@ -18,7 +19,15 @@
18 # You should have received a copy of the GNU General Public License 19 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. 20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 21
21 # Written by Paul Eggert. 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.
29
30 # Please report bugs or propose patches to bug-gnulib@gnu.org.
22 31
23 nl=' 32 nl='
24 ' 33 '
...@@ -27,36 +36,77 @@ nl=' ...@@ -27,36 +36,77 @@ nl='
27 LC_ALL=C 36 LC_ALL=C
28 export LC_ALL 37 export LC_ALL
29 38
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
42
30 local_gl_dir=gl 43 local_gl_dir=gl
31 44
32 # Temporary directory names. 45 # Honour $PERL, but work even if there is none
33 bt='._bootmp' 46 PERL="${PERL-perl}"
34 bt_regex=`echo "$bt"| sed 's/\./[.]/g'` 47
35 bt2=${bt}2 48 me=$0
36 49
37 usage() { 50 usage() {
38 echo >&2 "\ 51 cat <<EOF
39 Usage: $0 [OPTION]... 52 Usage: $me [OPTION]...
40 Bootstrap this package from the checked-out sources. 53 Bootstrap this package from the checked-out sources.
41 54
42 Options: 55 Options:
43 --gnulib-srcdir=DIRNAME Specify the local directory where gnulib 56 --gnulib-srcdir=DIRNAME specify the local directory where gnulib
44 sources reside. Use this if you already 57 sources reside. Use this if you already
45 have gnulib sources on your machine, and 58 have gnulib sources on your machine, and
46 do not want to waste your bandwidth downloading 59 do not want to waste your bandwidth downloading
47 them again. 60 them again. Defaults to \$GNULIB_SRCDIR
48 --copy Copy files instead of creating symbolic links. 61 --bootstrap-sync if this bootstrap script is not identical to
49 --force Attempt to bootstrap even if the sources seem 62 the version in the local gnulib sources,
50 not to have been checked out. 63 update this script, and then restart it with
51 --skip-po Do not download po files. 64 /bin/sh or the shell \$CONFIG_SHELL
52 65 --no-bootstrap-sync do not check whether bootstrap is out of sync
53 If the file bootstrap.conf exists in the current working directory, its 66 --copy copy files instead of creating symbolic links
67 --force attempt to bootstrap even if the sources seem
68 not to have been checked out
69 --no-git do not use git to update gnulib. Requires that
70 --gnulib-srcdir point to a correct gnulib snapshot
71 --skip-po do not download po files
72
73 If the file $me.conf exists in the same directory as this script, its
54 contents are read as shell variables to configure the bootstrap. 74 contents are read as shell variables to configure the bootstrap.
55 75
76 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
77 are honored.
78
56 Running without arguments will suffice in most cases. 79 Running without arguments will suffice in most cases.
57 " 80 EOF
58 } 81 }
59 82
83 # warnf_ FORMAT-STRING ARG1...
84 warnf_ ()
85 {
86 warnf_format_=$1
87 shift
88 nl='
89 '
90 case $* in
91 *$nl*) me_=$(printf "$me"|tr "$nl|" '??')
92 printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
93 *) printf "$me: $warnf_format_" "$@" ;;
94 esac >&2
95 }
96
97 # warn_ WORD1...
98 warn_ ()
99 {
100 # If IFS does not start with ' ', set it and emit the warning in a subshell.
101 case $IFS in
102 ' '*) warnf_ '%s\n' "$*";;
103 *) (IFS=' '; warn_ "$@");;
104 esac
105 }
106
107 # die WORD1...
108 die() { warn_ "$@"; exit 1; }
109
60 # Configuration. 110 # Configuration.
61 111
62 # Name of the Makefile.am 112 # Name of the Makefile.am
...@@ -68,32 +118,51 @@ gnulib_modules= ...@@ -68,32 +118,51 @@ gnulib_modules=
68 # Any gnulib files needed that are not in modules. 118 # Any gnulib files needed that are not in modules.
69 gnulib_files= 119 gnulib_files=
70 120
121 : ${AUTOPOINT=autopoint}
122 : ${AUTORECONF=autoreconf}
123
124 # A function to be called right after gnulib-tool is run.
125 # Override it via your own definition in bootstrap.conf.
126 bootstrap_post_import_hook() { :; }
127
128 # A function to be called after everything else in this script.
129 # Override it via your own definition in bootstrap.conf.
130 bootstrap_epilogue() { :; }
131
71 # The command to download all .po files for a specified domain into 132 # The command to download all .po files for a specified domain into
72 # a specified directory. Fill in the first %s is the domain name, and 133 # a specified directory. Fill in the first %s is the domain name, and
73 # the second with the destination directory. Use rsync's -L and -r 134 # the second with the destination directory. Use rsync's -L and -r
74 # options because the latest/%s directory and the .po files within are 135 # options because the latest/%s directory and the .po files within are
75 # all symlinks. 136 # all symlinks.
76 po_download_command_format=\ 137 po_download_command_format=\
77 "rsync -Lrtvz 'translationproject.org::tp/latest/%s/' '%s'" 138 "rsync --delete --exclude '*.s1' -Lrtvz \
139 'translationproject.org::tp/latest/%s/' '%s'"
78 140
141 # Fallback for downloading .po files (if rsync fails).
142 po_download_command_format2=\
143 "wget --mirror -nd -q -np -A.po -P '%s' \
144 http://translationproject.org/latest/%s/"
145
146 # Prefer a non-empty tarname (4th argument of AC_INIT if given), else
147 # fall back to the package name (1st argument with munging)
79 extract_package_name=' 148 extract_package_name='
80 /^AC_INIT(/{ 149 /^AC_INIT(\[*/{
81 /.*,.*,.*, */{ 150 s///
82 s/// 151 /^[^,]*,[^,]*,[^,]*,[ []*\([^][ ,)]\)/{
83 s/[][]//g 152 s//\1/
84 s/)$// 153 s/[],)].*//
85 p 154 p
86 q 155 q
87 } 156 }
88 s/AC_INIT(\[*// 157 s/[],)].*//
89 s/]*,.*//
90 s/^GNU // 158 s/^GNU //
91 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ 159 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
92 s/[^A-Za-z0-9_]/-/g 160 s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
93 p 161 p
94 } 162 }
95 ' 163 '
96 package=`sed -n "$extract_package_name" configure.ac` || exit 164 package=$(sed -n "$extract_package_name" configure.ac) \
165 || die 'cannot find package name in configure.ac'
97 gnulib_name=lib$package 166 gnulib_name=lib$package
98 167
99 build_aux=build-aux 168 build_aux=build-aux
...@@ -101,17 +170,7 @@ source_base=lib ...@@ -101,17 +170,7 @@ source_base=lib
101 m4_base=m4 170 m4_base=m4
102 doc_base=doc 171 doc_base=doc
103 tests_base=tests 172 tests_base=tests
104 173 gnulib_extra_files=''
105 # Extra files from gnulib, which override files from other sources.
106 gnulib_extra_files="
107 $build_aux/install-sh
108 $build_aux/mdate-sh
109 $build_aux/texinfo.tex
110 $build_aux/depcomp
111 $build_aux/config.guess
112 $build_aux/config.sub
113 doc/INSTALL
114 "
115 174
116 # Additional gnulib-tool options to use. Use "\newline" to break lines. 175 # Additional gnulib-tool options to use. Use "\newline" to break lines.
117 gnulib_tool_option_extras= 176 gnulib_tool_option_extras=
...@@ -126,7 +185,8 @@ XGETTEXT_OPTIONS='\\\ ...@@ -126,7 +185,8 @@ XGETTEXT_OPTIONS='\\\
126 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\ 185 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
127 ' 186 '
128 187
129 # Package bug report address for gettext files 188 # Package bug report address and copyright holder for gettext files
189 COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
130 MSGID_BUGS_ADDRESS=bug-$package@gnu.org 190 MSGID_BUGS_ADDRESS=bug-$package@gnu.org
131 191
132 # Files we don't want to import. 192 # Files we don't want to import.
...@@ -145,8 +205,76 @@ copy=false ...@@ -145,8 +205,76 @@ copy=false
145 # on which version control system (if any) is used in the source directory. 205 # on which version control system (if any) is used in the source directory.
146 vc_ignore=auto 206 vc_ignore=auto
147 207
208 # Set this to true in bootstrap.conf to enable --bootstrap-sync by
209 # default.
210 bootstrap_sync=false
211
212 # Use git to update gnulib sources
213 use_git=true
214
215 check_exists() {
216 if test "$1" = "--verbose"; then
217 ($2 --version </dev/null) >/dev/null 2>&1
218 if test $? -ge 126; then
219 # If not found, run with diagnostics as one may be
220 # presented with env variables to set to find the right version
221 ($2 --version </dev/null)
222 fi
223 else
224 ($1 --version </dev/null) >/dev/null 2>&1
225 fi
226
227 test $? -lt 126
228 }
229
230 # find_tool ENVVAR NAMES...
231 # -------------------------
232 # Search for a required program. Use the value of ENVVAR, if set,
233 # otherwise find the first of the NAMES that can be run.
234 # If found, set ENVVAR to the program name, die otherwise.
235 #
236 # FIXME: code duplication, see also gnu-web-doc-update.
237 find_tool ()
238 {
239 find_tool_envvar=$1
240 shift
241 find_tool_names=$@
242 eval "find_tool_res=\$$find_tool_envvar"
243 if test x"$find_tool_res" = x; then
244 for i; do
245 if check_exists $i; then
246 find_tool_res=$i
247 break
248 fi
249 done
250 fi
251 if test x"$find_tool_res" = x; then
252 warn_ "one of these is required: $find_tool_names;"
253 die "alternatively set $find_tool_envvar to a compatible tool"
254 fi
255 eval "$find_tool_envvar=\$find_tool_res"
256 eval "export $find_tool_envvar"
257 }
258
148 # Override the default configuration, if necessary. 259 # Override the default configuration, if necessary.
149 test -r bootstrap.conf && . ./bootstrap.conf 260 # Make sure that bootstrap.conf is sourced from the current directory
261 # if we were invoked as "sh bootstrap".
262 case "$0" in
263 */*) test -r "$0.conf" && . "$0.conf" ;;
264 *) test -r "$0.conf" && . ./"$0.conf" ;;
265 esac
266
267 # Extra files from gnulib, which override files from other sources.
268 test -z "${gnulib_extra_files}" && \
269 gnulib_extra_files="
270 build-aux/install-sh
271 build-aux/mdate-sh
272 build-aux/texinfo.tex
273 build-aux/depcomp
274 build-aux/config.guess
275 build-aux/config.sub
276 doc/INSTALL
277 "
150 278
151 if test "$vc_ignore" = auto; then 279 if test "$vc_ignore" = auto; then
152 vc_ignore= 280 vc_ignore=
...@@ -165,33 +293,70 @@ do ...@@ -165,33 +293,70 @@ do
165 usage 293 usage
166 exit;; 294 exit;;
167 --gnulib-srcdir=*) 295 --gnulib-srcdir=*)
168 GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;; 296 GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
169 --skip-po) 297 --skip-po)
170 SKIP_PO=t;; 298 SKIP_PO=t;;
171 --force) 299 --force)
172 checkout_only_file=;; 300 checkout_only_file=;;
173 --copy) 301 --copy)
174 copy=true;; 302 copy=true;;
303 --bootstrap-sync)
304 bootstrap_sync=true;;
305 --no-bootstrap-sync)
306 bootstrap_sync=false;;
307 --no-git)
308 use_git=false;;
175 *) 309 *)
176 echo >&2 "$0: $option: unknown option" 310 die "$option: unknown option";;
177 exit 1;;
178 esac 311 esac
179 done 312 done
180 313
314 $use_git || test -d "$GNULIB_SRCDIR" \
315 || die "Error: --no-git requires --gnulib-srcdir"
316
181 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then 317 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
182 echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2 318 die "Bootstrapping from a non-checked-out distribution is risky."
183 exit 1
184 fi 319 fi
185 320
186 # If $STR is not already on a line by itself in $FILE, insert it, 321 # Strip blank and comment lines to leave significant entries.
187 # sorting the new contents of the file and replacing $FILE with the result. 322 gitignore_entries() {
188 insert_sorted_if_absent() { 323 sed '/^#/d; /^$/d' "$@"
324 }
325
326 # If $STR is not already on a line by itself in $FILE, insert it at the start.
327 # Entries are inserted at the start of the ignore list to ensure existing
328 # entries starting with ! are not overridden. Such entries support
329 # whitelisting exceptions after a more generic blacklist pattern.
330 insert_if_absent() {
189 file=$1 331 file=$1
190 str=$2 332 str=$2
191 test -f $file || touch $file 333 test -f $file || touch $file
192 echo "$str" | sort -u - $file | cmp -s - $file \ 334 test -r $file || die "Error: failed to read ignore file: $file"
193 || echo "$str" | sort -u - $file -o $file \ 335 duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
194 || exit 1 336 if [ "$duplicate_entries" ] ; then
337 die "Error: Duplicate entries in $file: " $duplicate_entries
338 fi
339 linesold=$(gitignore_entries $file | wc -l)
340 linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
341 if [ $linesold != $linesnew ] ; then
342 { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
343 || die "insert_if_absent $file $str: failed"
344 fi
345 }
346
347 # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
348 # insert_if_absent.
349 insert_vc_ignore() {
350 vc_ignore_file="$1"
351 pattern="$2"
352 case $vc_ignore_file in
353 *.gitignore)
354 # A .gitignore entry that does not start with '/' applies
355 # recursively to subdirectories, so prepend '/' to every
356 # .gitignore entry.
357 pattern=$(echo "$pattern" | sed s,^,/,);;
358 esac
359 insert_if_absent "$vc_ignore_file" "$pattern"
195 } 360 }
196 361
197 # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac. 362 # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
...@@ -200,11 +365,8 @@ grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \ ...@@ -200,11 +365,8 @@ grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
200 >/dev/null && found_aux_dir=yes 365 >/dev/null && found_aux_dir=yes
201 grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \ 366 grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
202 >/dev/null && found_aux_dir=yes 367 >/dev/null && found_aux_dir=yes
203 if test $found_aux_dir = no; then 368 test $found_aux_dir = yes \
204 echo "$0: expected line not found in configure.ac. Add the following:" >&2 369 || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
205 echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
206 exit 1
207 fi
208 370
209 # If $build_aux doesn't exist, create it now, otherwise some bits 371 # If $build_aux doesn't exist, create it now, otherwise some bits
210 # below will malfunction. If creating it, also mark it as ignored. 372 # below will malfunction. If creating it, also mark it as ignored.
...@@ -212,76 +374,365 @@ if test ! -d $build_aux; then ...@@ -212,76 +374,365 @@ if test ! -d $build_aux; then
212 mkdir $build_aux 374 mkdir $build_aux
213 for dot_ig in x $vc_ignore; do 375 for dot_ig in x $vc_ignore; do
214 test $dot_ig = x && continue 376 test $dot_ig = x && continue
215 insert_sorted_if_absent $dot_ig $build_aux 377 insert_vc_ignore $dot_ig $build_aux
216 done 378 done
217 fi 379 fi
218 380
381 # Note this deviates from the version comparison in automake
382 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
383 # but this should suffice as we won't be specifying old
384 # version formats or redundant trailing .0 in bootstrap.conf.
385 # If we did want full compatibility then we should probably
386 # use m4_version_compare from autoconf.
387 sort_ver() { # sort -V is not generally available
388 ver1="$1"
389 ver2="$2"
390
391 # split on '.' and compare each component
392 i=1
393 while : ; do
394 p1=$(echo "$ver1" | cut -d. -f$i)
395 p2=$(echo "$ver2" | cut -d. -f$i)
396 if [ ! "$p1" ]; then
397 echo "$1 $2"
398 break
399 elif [ ! "$p2" ]; then
400 echo "$2 $1"
401 break
402 elif [ ! "$p1" = "$p2" ]; then
403 if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
404 echo "$2 $1"
405 elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
406 echo "$1 $2"
407 else # numeric, then lexicographic comparison
408 lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
409 if [ "$lp" = "$p2" ]; then
410 echo "$1 $2"
411 else
412 echo "$2 $1"
413 fi
414 fi
415 break
416 fi
417 i=$(($i+1))
418 done
419 }
420
421 get_version() {
422 app=$1
423
424 $app --version >/dev/null 2>&1 || { $app --version; return 1; }
425
426 $app --version 2>&1 |
427 sed -n '# Move version to start of line.
428 s/.*[v ]\([0-9]\)/\1/
429
430 # Skip lines that do not start with version.
431 /^[0-9]/!d
432
433 # Remove characters after the version.
434 s/[^.a-z0-9-].*//
435
436 # The first component must be digits only.
437 s/^\([0-9]*\)[a-z-].*/\1/
438
439 #the following essentially does s/5.005/5.5/
440 s/\.0*\([1-9]\)/.\1/g
441 p
442 q'
443 }
444
445 check_versions() {
446 ret=0
447
448 while read app req_ver; do
449 # We only need libtoolize from the libtool package.
450 if test "$app" = libtool; then
451 app=libtoolize
452 fi
453 # Exempt git if --no-git is in effect.
454 if test "$app" = git; then
455 $use_git || continue
456 fi
457 # Honor $APP variables ($TAR, $AUTOCONF, etc.)
458 appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_')
459 test "$appvar" = TAR && appvar=AMTAR
460 case $appvar in
461 GZIP) ;; # Do not use $GZIP: it contains gzip options.
462 PERL::*) ;; # Keep perl modules as-is
463 *) eval "app=\${$appvar-$app}" ;;
464 esac
465
466 # Handle the still-experimental Automake-NG programs specially.
467 # They remain named as the mainstream Automake programs ("automake",
468 # and "aclocal") to avoid gratuitous incompatibilities with
469 # pre-existing usages (by, say, autoreconf, or custom autogen.sh
470 # scripts), but correctly identify themselves (as being part of
471 # "GNU automake-ng") when asked their version.
472 case $app in
473 automake-ng|aclocal-ng)
474 app=${app%-ng}
475 ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
476 warn_ "Error: '$app' not found or not from Automake-NG"
477 ret=1
478 continue
479 } ;;
480 # Another check is for perl modules. These can be written as
481 # e.g. perl::XML::XPath in case of XML::XPath module, etc.
482 perl::*)
483 # Extract module name
484 app="${app#perl::}"
485 if ! $PERL -m"$app" -e 'exit 0' >/dev/null 2>&1; then
486 warn_ "Error: perl module '$app' not found"
487 ret=1
488 fi
489 continue
490 ;;
491 esac
492 if [ "$req_ver" = "-" ]; then
493 # Merely require app to exist; not all prereq apps are well-behaved
494 # so we have to rely on $? rather than get_version.
495 if ! check_exists --verbose $app; then
496 warn_ "Error: '$app' not found"
497 ret=1
498 fi
499 else
500 # Require app to produce a new enough version string.
501 inst_ver=$(get_version $app)
502 if [ ! "$inst_ver" ]; then
503 warn_ "Error: '$app' not found"
504 ret=1
505 else
506 latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
507 if [ ! "$latest_ver" = "$inst_ver" ]; then
508 warnf_ '%s\n' \
509 "Error: '$app' version == $inst_ver is too old" \
510 " '$app' version >= $req_ver is required"
511 ret=1
512 fi
513 fi
514 fi
515 done
516
517 return $ret
518 }
519
520 print_versions() {
521 echo "Program Min_version"
522 echo "----------------------"
523 printf %s "$buildreq"
524 echo "----------------------"
525 # can't depend on column -t
526 }
527
528 # Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6.
529 # Also find the compatible sha1 utility on the BSDs
530 if test x"$SKIP_PO" = x; then
531 find_tool SHA1SUM sha1sum gsha1sum shasum sha1
532 fi
533
534 use_libtool=0
535 # We'd like to use grep -E, to see if any of LT_INIT,
536 # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
537 # but that's not portable enough (e.g., for Solaris).
538 grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
539 && use_libtool=1
540 grep '^[ ]*LT_INIT' configure.ac >/dev/null \
541 && use_libtool=1
542 if test $use_libtool = 1; then
543 find_tool LIBTOOLIZE glibtoolize libtoolize
544 fi
545
546 # gnulib-tool requires at least automake and autoconf.
547 # If either is not listed, add it (with minimum version) as a prerequisite.
548 case $buildreq in
549 *automake*) ;;
550 *) buildreq="automake 1.9
551 $buildreq" ;;
552 esac
553 case $buildreq in
554 *autoconf*) ;;
555 *) buildreq="autoconf 2.59
556 $buildreq" ;;
557 esac
558
559 # When we can deduce that gnulib-tool will require patch,
560 # and when patch is not already listed as a prerequisite, add it, too.
561 if test -d "$local_gl_dir" \
562 && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then
563 case $buildreq in
564 *patch*) ;;
565 *) buildreq="patch -
566 $buildreq" ;;
567 esac
568 fi
569
570 if ! printf "$buildreq" | check_versions; then
571 echo >&2
572 if test -f README-prereq; then
573 die "See README-prereq for how to get the prerequisite programs"
574 else
575 die "Please install the prerequisite programs"
576 fi
577 fi
578
579 # Warn the user if autom4te appears to be broken; this causes known
580 # issues with at least gettext 0.18.3.
581 probe=$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -)
582 if test "x$probe" != xhi; then
583 warn_ "WARNING: your autom4te wrapper eats stdin;"
584 warn_ "if bootstrap fails, consider upgrading your autotools"
585 fi
586
219 echo "$0: Bootstrapping from checked-out $package sources..." 587 echo "$0: Bootstrapping from checked-out $package sources..."
220 588
589 # See if we can use gnulib's git-merge-changelog merge driver.
590 if $use_git && test -d .git && check_exists git; then
591 if git config merge.merge-changelog.driver >/dev/null ; then
592 :
593 elif check_exists git-merge-changelog; then
594 echo "$0: initializing git-merge-changelog driver"
595 git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
596 git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
597 else
598 echo "$0: consider installing git-merge-changelog from gnulib"
599 fi
600 fi
601
602
221 cleanup_gnulib() { 603 cleanup_gnulib() {
222 status=$? 604 status=$?
223 rm -fr gnulib 605 rm -fr "$gnulib_path"
224 exit $status 606 exit $status
225 } 607 }
226 608
227 # Get gnulib files. 609 git_modules_config () {
610 test -f .gitmodules && git config --file .gitmodules "$@"
611 }
612
613 if $use_git; then
614 gnulib_path=$(git_modules_config submodule.gnulib.path)
615 test -z "$gnulib_path" && gnulib_path=gnulib
616 fi
617
618 # Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a
619 # submodule, for use in the rest of the script.
228 620
229 case ${GNULIB_SRCDIR--} in 621 case ${GNULIB_SRCDIR--} in
230 -) 622 -)
231 if [ ! -d gnulib ]; then 623 # Note that $use_git is necessarily true in this case.
624 if git_modules_config submodule.gnulib.url >/dev/null; then
625 echo "$0: getting gnulib files..."
626 git submodule init -- "$gnulib_path" || exit $?
627 git submodule update -- "$gnulib_path" || exit $?
628
629 elif [ ! -d "$gnulib_path" ]; then
232 echo "$0: getting gnulib files..." 630 echo "$0: getting gnulib files..."
233 631
234 trap cleanup_gnulib 1 2 13 15 632 trap cleanup_gnulib 1 2 13 15
235 633
236 git clone --depth 2 git://git.sv.gnu.org/gnulib || 634 shallow=
635 git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
636 git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
237 cleanup_gnulib 637 cleanup_gnulib
238 638
239 trap - 1 2 13 15 639 trap - 1 2 13 15
240 fi 640 fi
241 GNULIB_SRCDIR=gnulib 641 GNULIB_SRCDIR=$gnulib_path
642 ;;
643 *)
644 # Use GNULIB_SRCDIR directly or as a reference.
645 if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
646 git_modules_config submodule.gnulib.url >/dev/null; then
647 echo "$0: getting gnulib files..."
648 if git submodule -h|grep -- --reference > /dev/null; then
649 # Prefer the one-liner available in git 1.6.4 or newer.
650 git submodule update --init --reference "$GNULIB_SRCDIR" \
651 "$gnulib_path" || exit $?
652 else
653 # This fallback allows at least git 1.5.5.
654 if test -f "$gnulib_path"/gnulib-tool; then
655 # Since file already exists, assume submodule init already complete.
656 git submodule update -- "$gnulib_path" || exit $?
657 else
658 # Older git can't clone into an empty directory.
659 rmdir "$gnulib_path" 2>/dev/null
660 git clone --reference "$GNULIB_SRCDIR" \
661 "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
662 && git submodule init -- "$gnulib_path" \
663 && git submodule update -- "$gnulib_path" \
664 || exit $?
665 fi
666 fi
667 GNULIB_SRCDIR=$gnulib_path
668 fi
669 ;;
242 esac 670 esac
243 671
672 # $GNULIB_SRCDIR now points to the version of gnulib to use, and
673 # we no longer need to use git or $gnulib_path below here.
674
675 if $bootstrap_sync; then
676 cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
677 echo "$0: updating bootstrap and restarting..."
678 case $(sh -c 'echo "$1"' -- a) in
679 a) ignored=--;;
680 *) ignored=ignored;;
681 esac
682 exec sh -c \
683 'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
684 $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
685 "$0" "$@" --no-bootstrap-sync
686 }
687 fi
688
244 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool 689 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
245 <$gnulib_tool || exit 690 <$gnulib_tool || exit $?
246 691
247 # Get translations. 692 # Get translations.
248 693
249 download_po_files() { 694 download_po_files() {
250 subdir=$1 695 subdir=$1
251 domain=$2 696 domain=$2
252 echo "$0: getting translations into $subdir for $domain..." 697 echo "$me: getting translations into $subdir for $domain..."
253 cmd=`printf "$po_download_command_format" "$domain" "$subdir"` 698 cmd=$(printf "$po_download_command_format" "$domain" "$subdir")
699 eval "$cmd" && return
700 # Fallback to HTTP.
701 cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
254 eval "$cmd" 702 eval "$cmd"
255 } 703 }
256 704
257 # Download .po files to $po_dir/.reference and copy only the new 705 # Mirror .po files to $po_dir/.reference and copy only the new
258 # or modified ones into $po_dir. Also update $po_dir/LINGUAS. 706 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
707 # Note po files that exist locally only are left in $po_dir but will
708 # not be included in LINGUAS and hence will not be distributed.
259 update_po_files() { 709 update_po_files() {
260 # Directory containing primary .po files. 710 # Directory containing primary .po files.
261 # Overwrite them only when we're sure a .po file is new. 711 # Overwrite them only when we're sure a .po file is new.
262 po_dir=$1 712 po_dir=$1
263 domain=$2 713 domain=$2
264 714
265 # Download *.po files into this dir. 715 # Mirror *.po files into this dir.
266 # Usually contains *.s1 checksum files. 716 # Usually contains *.s1 checksum files.
267 ref_po_dir="$po_dir/.reference" 717 ref_po_dir="$po_dir/.reference"
268 718
269 test -d $ref_po_dir || mkdir $ref_po_dir || return 719 test -d $ref_po_dir || mkdir $ref_po_dir || return
270 download_po_files $ref_po_dir $domain \ 720 download_po_files $ref_po_dir $domain \
271 && ls "$ref_po_dir"/*.po 2>/dev/null | 721 && ls "$ref_po_dir"/*.po 2>/dev/null |
272 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" 722 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
273 723
274 langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'` 724 langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g')
275 test "$langs" = '*' && langs=x 725 test "$langs" = '*' && langs=x
276 for po in `cd $ref_po_dir && echo *.po|sed 's/\.po//g'`; do 726 for po in $langs; do
277 case $po in x) continue;; esac 727 case $po in x) continue;; esac
278 new_po="$ref_po_dir/$po.po" 728 new_po="$ref_po_dir/$po.po"
279 cksum_file="$ref_po_dir/$po.s1" 729 cksum_file="$ref_po_dir/$po.s1"
280 if ! test -f "$cksum_file" || 730 if ! test -f "$cksum_file" ||
281 ! test -f "$po_dir/$po.po" || 731 ! test -f "$po_dir/$po.po" ||
282 ! sha1sum -c --status "$cksum_file" < "$new_po" > /dev/null; then 732 ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then
283 echo "updated $po_dir/$po.po..." 733 echo "$me: updated $po_dir/$po.po..."
284 cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file" 734 cp "$new_po" "$po_dir/$po.po" \
735 && $SHA1SUM < "$new_po" > "$cksum_file" || return
285 fi 736 fi
286 done 737 done
287 } 738 }
...@@ -306,349 +757,213 @@ symlink_to_dir() ...@@ -306,349 +757,213 @@ symlink_to_dir()
306 757
307 # If the destination directory doesn't exist, create it. 758 # If the destination directory doesn't exist, create it.
308 # This is required at least for "lib/uniwidth/cjk.h". 759 # This is required at least for "lib/uniwidth/cjk.h".
309 dst_dir=`dirname "$dst"` 760 dst_dir=$(dirname "$dst")
310 if ! test -d "$dst_dir"; then 761 if ! test -d "$dst_dir"; then
311 mkdir -p "$dst_dir" 762 mkdir -p "$dst_dir"
312 763
313 # If we've just created a directory like lib/uniwidth, 764 # If we've just created a directory like lib/uniwidth,
314 # tell version control system(s) it's ignorable. 765 # tell version control system(s) it's ignorable.
315 # FIXME: for now, this does only one level 766 # FIXME: for now, this does only one level
316 parent=`dirname "$dst_dir"` 767 parent=$(dirname "$dst_dir")
317 for dot_ig in x $vc_ignore; do 768 for dot_ig in x $vc_ignore; do
318 test $dot_ig = x && continue 769 test $dot_ig = x && continue
319 ig=$parent/$dot_ig 770 ig=$parent/$dot_ig
320 insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'` 771 insert_vc_ignore $ig "${dst_dir##*/}"
321 done 772 done
322 fi 773 fi
323 774
324 if $copy; then 775 if $copy; then
325 { 776 {
326 test ! -h "$dst" || { 777 test ! -h "$dst" || {
327 echo "$0: rm -f $dst" && 778 echo "$me: rm -f $dst" &&
328 rm -f "$dst" 779 rm -f "$dst"
329 } 780 }
330 } && 781 } &&
331 test -f "$dst" && 782 test -f "$dst" &&
332 cmp -s "$src" "$dst" || { 783 cmp -s "$src" "$dst" || {
333 echo "$0: cp -fp $src $dst" && 784 echo "$me: cp -fp $src $dst" &&
334 cp -fp "$src" "$dst" 785 cp -fp "$src" "$dst"
335 } 786 }
336 else 787 else
788 # Leave any existing symlink alone, if it already points to the source,
789 # so that broken build tools that care about symlink times
790 # aren't confused into doing unnecessary builds. Conversely, if the
791 # existing symlink's time stamp is older than the source, make it afresh,
792 # so that broken tools aren't confused into skipping needed builds. See
793 # <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
337 test -h "$dst" && 794 test -h "$dst" &&
338 src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 && 795 src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
339 dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 && 796 dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
340 test "$src_i" = "$dst_i" || { 797 test "$src_i" = "$dst_i" &&
341 dot_dots= 798 both_ls=$(ls -dt "$src" "$dst") &&
342 case $src in 799 test "X$both_ls" = "X$dst$nl$src" || {
343 /*) ;; 800 dot_dots=
344 *) 801 case $src in
345 case /$dst/ in 802 /*) ;;
346 *//* | */../* | */./* | /*/*/*/*/*/) 803 *)
347 echo >&2 "$0: invalid symlink calculation: $src -> $dst" 804 case /$dst/ in
348 exit 1;; 805 *//* | */../* | */./* | /*/*/*/*/*/)
349 /*/*/*/*/) dot_dots=../../../;; 806 die "invalid symlink calculation: $src -> $dst";;
350 /*/*/*/) dot_dots=../../;; 807 /*/*/*/*/) dot_dots=../../../;;
351 /*/*/) dot_dots=../;; 808 /*/*/*/) dot_dots=../../;;
352 esac;; 809 /*/*/) dot_dots=../;;
353 esac 810 esac;;
354 811 esac
355 echo "$0: ln -fs $dot_dots$src $dst" && 812
356 ln -fs "$dot_dots$src" "$dst" 813 echo "$me: ln -fs $dot_dots$src $dst" &&
814 ln -fs "$dot_dots$src" "$dst"
357 } 815 }
358 fi 816 fi
359 } 817 }
360 } 818 }
361 819
362 cp_mark_as_generated()
363 {
364 cp_src=$1
365 cp_dst=$2
366
367 if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
368 symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
369 elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
370 symlink_to_dir $local_gl_dir "$cp_dst"
371 else
372 case $cp_dst in
373 *.[ch]) c1='/* '; c2=' */';;
374 *.texi) c1='@c '; c2= ;;
375 *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
376 *) c1= ; c2= ;;
377 esac
378
379 # If the destination directory doesn't exist, create it.
380 # This is required at least for "lib/uniwidth/cjk.h".
381 dst_dir=`dirname "$cp_dst"`
382 test -d "$dst_dir" || mkdir -p "$dst_dir"
383
384 if test -z "$c1"; then
385 cmp -s "$cp_src" "$cp_dst" || {
386 echo "$0: cp -f $cp_src $cp_dst" &&
387 rm -f "$cp_dst" &&
388 sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst"
389 }
390 else
391 # Copy the file first to get proper permissions if it
392 # doesn't already exist. Then overwrite the copy.
393 cp "$cp_src" "$cp_dst-t" &&
394 (
395 echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
396 echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
397 sed "s!$bt_regex/!!g" "$cp_src"
398 ) > $cp_dst-t &&
399 if cmp -s "$cp_dst-t" "$cp_dst"; then
400 rm -f "$cp_dst-t"
401 else
402 echo "$0: cp $cp_src $cp_dst # with edits" &&
403 mv -f "$cp_dst-t" "$cp_dst"
404 fi
405 fi
406 fi
407 }
408
409 version_controlled_file() { 820 version_controlled_file() {
410 dir=$1 821 parent=$1
411 file=$2 822 file=$2
412 found=no 823 if test -d .git; then
413 if test -d CVS; then 824 git rm -n "$file" > /dev/null 2>&1
414 grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
415 grep '^/[^/]*/[0-9]' > /dev/null && found=yes
416 elif test -d .git; then
417 git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
418 elif test -d .svn; then 825 elif test -d .svn; then
419 svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes 826 svn log -r HEAD "$file" > /dev/null 2>&1
827 elif test -d CVS; then
828 grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
829 grep '^/[^/]*/[0-9]' > /dev/null
420 else 830 else
421 echo "$0: no version control for $dir/$file?" >&2 831 warn_ "no version control for $file?"
832 false
422 fi 833 fi
423 test $found = yes
424 } 834 }
425 835
426 # AWK program to convert a Makefile(.am) file rules to Automake 1.11 836 # NOTE: we have to be careful to run both autopoint and libtoolize
427 # silent mode. 837 # before gnulib-tool, since gnulib-tool is likely to provide newer
428 silent_rules_prog=' 838 # versions of files "installed" by these two programs.
429 # state = 0 - outside rules 839 # Then, *after* gnulib-tool (see below), we have to be careful to
430 # state = 1 - first line inside a rule 840 # run autoreconf in such a way that it does not run either of these
431 # state = 2 - subsequent lines inside a rule 841 # two just-pre-run programs.
432 # cont = 1 - this line is a continuation of the previous one 842
433 # defn = 1 - insert AM_V_GEN/AM_V_at definitions after the initail comment 843 # Import from gettext.
434 # Print comment lines 844 with_gettext=yes
435 /^[ \t]*#/ { print; next } 845 grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
436 # Insert AM_V_ definitions, if required. 846 with_gettext=no
437 state == 0 && defn == 1 {
438 print "AM_DEFAULT_VERBOSITY=0" # FIXME
439 print "AM_V_GEN = $(am__v_GEN_$(V))"
440 print "am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))"
441 print "am__v_GEN_0 = @echo \" GEN \" $@;"
442 print "AM_V_at = $(am__v_at_$(V))"
443 print "am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))"
444 print "am__v_at_0 = @"
445 defn = 0
446 }
447 # Start of a rule
448 /^[^ \t].*:/ { print; state = 1; cont = 0; next }
449 # First action within the rule
450 state == 1 && /^\t/ {
451 # Print silent rules without changes. The second match
452 # is necessary to handle @VAR@ substitutions.
453 if (!(match($1, /^@/) && !match($1, /.@$/)))
454 sub(/^\t[\t ]*/, "&$(AM_V_GEN)")
455 print
456 cont = match($0, /\\$/)
457 state = 2
458 next
459 }
460 # All non-continuation lines within the rule are prefixed
461 # with $(AM_V_at).
462 state == 2 && /^\t/ && NF > 0 {
463 if (!cont)
464 sub(/^\t[\t ]*/, "&$(AM_V_at)")
465 print
466 cont = match($0, /\\$/)
467 next
468 }
469 # Everything else is output verbatim
470 { print }
471 '
472 847
473 silent_rules=yes 848 if test $with_gettext = yes || test $use_libtool = 1; then
474 grep 'AM_SILENT_RULES' configure.ac > /dev/null ||
475 grep '^[ ]*AM_INIT_AUTOMAKE([^)][^)]*silent-rules' configure.ac > /dev/null ||
476 silent_rules=no
477 849
478 silentize() { 850 tempbase=.bootstrap$$
479 if test "$silent_rules" = yes; then 851 trap "rm -f $tempbase.0 $tempbase.1" 1 2 13 15
480 case $1 in 852
481 *.am) defn=0;; 853 > $tempbase.0 > $tempbase.1 &&
482 *.in) defn=1;; 854 find . ! -type d -print | sort > $tempbase.0 || exit
855
856 if test $with_gettext = yes; then
857 # Released autopoint has the tendency to install macros that have been
858 # obsoleted in current gnulib, so run this before gnulib-tool.
859 echo "$0: $AUTOPOINT --force"
860 $AUTOPOINT --force || exit
861 fi
862
863 # Autoreconf runs aclocal before libtoolize, which causes spurious
864 # warnings if the initial aclocal is confused by the libtoolized
865 # (or worse out-of-date) macro directory.
866 # libtoolize 1.9b added the --install option; but we support back
867 # to libtoolize 1.5.22, where the install action was default.
868 if test $use_libtool = 1; then
869 install=
870 case $($LIBTOOLIZE --help) in
871 *--install*) install=--install ;;
483 esac 872 esac
484 awk -v defn=$defn "$silent_rules_prog" $1 > ${1}-t && 873 echo "running: $LIBTOOLIZE $install --copy"
485 mv ${1}-t $1 874 $LIBTOOLIZE $install --copy
486 fi 875 fi
487 }
488 876
489 slurp() { 877 find . ! -type d -print | sort >$tempbase.1
490 for dir in . `(cd $1 && find * -type d -print)`; do 878 old_IFS=$IFS
491 copied= 879 IFS=$nl
492 sep= 880 for file in $(comm -13 $tempbase.0 $tempbase.1); do
493 for file in `ls -a $1/$dir`; do 881 IFS=$old_IFS
494 case $file in 882 parent=${file%/*}
495 .|..) continue;; 883 version_controlled_file "$parent" "$file" || {
496 .*) continue;; # FIXME: should all file names starting with "." be ignored? 884 for dot_ig in x $vc_ignore; do
497 esac 885 test $dot_ig = x && continue
498 test -d $1/$dir/$file && continue 886 ig=$parent/$dot_ig
499 for excluded_file in $excluded_files; do 887 insert_vc_ignore "$ig" "${file##*/}"
500 test "$dir/$file" = "$excluded_file" && continue 2
501 done 888 done
502 if test $file = Makefile.am; then 889 }
503 copied=$copied${sep}$gnulib_mk; sep=$nl
504 remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
505 sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
506 echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
507 rm -f $dir/$gnulib_mk &&
508 sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
509 }
510 elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
511 version_controlled_file $dir $file; then
512 echo "$0: $dir/$file overrides $1/$dir/$file"
513 else
514 copied=$copied$sep$file; sep=$nl
515 if test $file = gettext.m4; then
516 echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
517 rm -f $dir/$file
518 sed '
519 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
520 AC_DEFUN([AM_INTL_SUBDIR], [
521 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
522 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
523 $a\
524 AC_DEFUN([gl_LOCK_EARLY], [])
525 ' $1/$dir/$file >$dir/$file
526 else
527 cp_mark_as_generated $1/$dir/$file $dir/$file
528 fi
529 fi || exit
530 done
531
532 for dot_ig in x $vc_ignore; do
533 test $dot_ig = x && continue
534 ig=$dir/$dot_ig
535 if test -n "$copied"; then
536 insert_sorted_if_absent $ig "$copied"
537 # If an ignored file name ends with .in.h, then also add
538 # the name with just ".h". Many gnulib headers are generated,
539 # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
540 # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
541 f=`echo "$copied"|sed 's/\.in\.h$/.h/;s/\.sin$/.sed/;s/\.y$/.c/;s/\.gperf$/.h/'`
542 insert_sorted_if_absent $ig "$f"
543
544 # For files like sys_stat.in.h and sys_time.in.h, record as
545 # ignorable the directory we might eventually create: sys/.
546 f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
547 insert_sorted_if_absent $ig "$f"
548 fi
549 done
550 done 890 done
551 } 891 IFS=$old_IFS
552
553 892
554 # Create boot temporary directories to import from gnulib and gettext. 893 rm -f $tempbase.0 $tempbase.1
555 rm -fr $bt $bt2 && 894 trap - 1 2 13 15
556 mkdir $bt $bt2 || exit 895 fi
557 896
558 # Import from gnulib. 897 # Import from gnulib.
559 898
560 gnulib_tool_options="\ 899 gnulib_tool_options="\
561 --import\ 900 --import\
562 --no-changelog\ 901 --no-changelog\
563 --aux-dir $bt/$build_aux\ 902 --aux-dir $build_aux\
564 --doc-base $bt/$doc_base\ 903 --doc-base $doc_base\
565 --lib $gnulib_name\ 904 --lib $gnulib_name\
566 --m4-base $bt/$m4_base/\ 905 --m4-base $m4_base/\
567 --source-base $bt/$source_base/\ 906 --source-base $source_base/\
568 --tests-base $bt/$tests_base\ 907 --tests-base $tests_base\
569 --local-dir $local_gl_dir\ 908 --local-dir $local_gl_dir\
570 $gnulib_tool_option_extras\ 909 $gnulib_tool_option_extras\
571 " 910 "
911 if test $use_libtool = 1; then
912 case "$gnulib_tool_options " in
913 *' --libtool '*) ;;
914 *) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
915 esac
916 fi
572 echo "$0: $gnulib_tool $gnulib_tool_options --import ..." 917 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
573 $gnulib_tool $gnulib_tool_options --import $gnulib_modules && 918 $gnulib_tool $gnulib_tool_options --import $gnulib_modules \
574 slurp $bt || exit 919 || die "gnulib-tool failed"
575 920
576 for file in $gnulib_files; do 921 for file in $gnulib_files; do
577 symlink_to_dir "$GNULIB_SRCDIR" $file || exit 922 symlink_to_dir "$GNULIB_SRCDIR" $file \
923 || die "failed to symlink $file"
578 done 924 done
579 925
926 bootstrap_post_import_hook \
927 || die "bootstrap_post_import_hook failed"
580 928
581 # Import from gettext. 929 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
582 with_gettext=yes 930 # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
583 grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
584 with_gettext=no
585
586 if test $with_gettext = yes; then
587 echo "$0: (cd $bt2; autopoint) ..."
588 cp configure.ac $bt2 &&
589 (cd $bt2 && autopoint && rm configure.ac) &&
590 slurp $bt2 $bt || exit
591
592 rm -fr $bt $bt2 || exit
593 fi
594
595 # Coreutils is unusual in that it generates some of its test-related
596 # Makefile.am files. That must be done before invoking automake.
597 mam_template=tests/Makefile.am.in
598 if test -f $mam_template; then
599 PERL=perl
600 for tool in cut head join pr sort tac tail test tr uniq wc; do
601 m=tests/$tool/Makefile.am
602 t=${m}t
603 rm -f $m $t
604 sed -n '1,/^##test-files-begin/p' $mam_template > $t
605 echo "x = $tool" >> $t
606 srcdir=tests/$tool
607 $PERL -I$srcdir -w -- tests/mk-script $srcdir --list >> $t
608 sed -n '/^##test-files-end/,$p' $mam_template >> $t
609 chmod -w $t
610 mv $t $m
611 done
612 fi
613
614 # Remove any dangling symlink matching "*.m4" in the gnulib-populated
615 # $m4_base directory, since such a file would cause aclocal to fail.
616 # The following requires GNU find 4.2.3 or newer. Considering the usual 931 # The following requires GNU find 4.2.3 or newer. Considering the usual
617 # portability constraints of this script, that may seem a very demanding 932 # portability constraints of this script, that may seem a very demanding
618 # requirement, but it should be ok. Ignore any failure, which is fine, 933 # requirement, but it should be ok. Ignore any failure, which is fine,
619 # since this is only a convenience to help developers avoid the relatively 934 # since this is only a convenience to help developers avoid the relatively
620 # unusual case in which a symlinked-to .m4 file is git-removed from gnulib 935 # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
621 # between successive runs of this script. 936 # between successive runs of this script.
622 find "$m4_base" -name '*.m4' -depth -type l -xtype l -delete > /dev/null 2>&1 937 find "$m4_base" "$source_base" \
623 938 -depth \( -name '*.m4' -o -name '*.[ch]' \) \
624 # Reconfigure, getting other files. 939 -type l -xtype l -delete > /dev/null 2>&1
625 940
626 aclocal_flags=`sed -n 's/ACLOCAL_AMFLAGS *=//p' Makefile.am` 941 # Invoke autoreconf with --force --install to ensure upgrades of tools
627 for command in \ 942 # such as ylwrap.
628 libtool \ 943 AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS"
629 "aclocal --force $aclocal_flags" \ 944
630 'autoconf --force' \ 945 # Some systems (RHEL 5) are using ancient autotools, for which the
631 'autoheader --force' \ 946 # --no-recursive option had not been invented. Detect that lack and
632 'automake --add-missing --copy --force-missing'; 947 # omit the option when it's not supported. FIXME in 2017: remove this
633 do 948 # hack when RHEL 5 autotools are updated, or when they become irrelevant.
634 if test "$command" = libtool; then 949 case $($AUTORECONF --help) in
635 grep '^[ ]*AM_PROG_LIBTOOL\>' configure.ac >/dev/null || 950 *--no-recursive*) AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive";;
636 continue 951 esac
637 command='libtoolize -c -f'
638 fi
639 echo "$0: $command ..."
640 $command || exit
641 done
642 952
953 # Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
954 echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS"
955 AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \
956 || die "autoreconf failed"
643 957
644 # Get some extra files from gnulib, overriding existing files. 958 # Get some extra files from gnulib, overriding existing files.
645 for file in $gnulib_extra_files; do 959 for file in $gnulib_extra_files; do
646 case $file in 960 case $file in
647 */INSTALL) dst=INSTALL;; 961 */INSTALL) dst=INSTALL;;
648 build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;; 962 build-aux/*) dst=$build_aux/${file#build-aux/};;
649 *) dst=$file;; 963 *) dst=$file;;
650 esac 964 esac
651 symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit 965 symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
966 || die "failed to symlink $file"
652 done 967 done
653 968
654 if test $with_gettext = yes; then 969 if test $with_gettext = yes; then
...@@ -657,15 +972,27 @@ if test $with_gettext = yes; then ...@@ -657,15 +972,27 @@ if test $with_gettext = yes; then
657 rm -f po/Makevars 972 rm -f po/Makevars
658 sed ' 973 sed '
659 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/ 974 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
660 /^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
661 /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/ 975 /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
976 /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
662 /^XGETTEXT_OPTIONS *=/{ 977 /^XGETTEXT_OPTIONS *=/{
663 s/$/ \\/ 978 s/$/ \\/
664 a\ 979 a\
665 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+} 980 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
666 } 981 }
667 ' po/Makevars.template >po/Makevars 982 ' po/Makevars.template >po/Makevars \
668 silentize po/Makefile.in.in 983 || die 'cannot generate po/Makevars'
984
985 # If the 'gettext' module is in use, grab the latest Makefile.in.in.
986 # If only the 'gettext-h' module is in use, assume autopoint already
987 # put the correct version of this file into place.
988 case $gnulib_modules in
989 *gettext-h*) ;;
990 *gettext*)
991 cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
992 || die "cannot create po/Makefile.in.in"
993 ;;
994 esac
995
669 if test -d runtime-po; then 996 if test -d runtime-po; then
670 # Similarly for runtime-po/Makevars, but not quite the same. 997 # Similarly for runtime-po/Makevars, but not quite the same.
671 rm -f runtime-po/Makevars 998 rm -f runtime-po/Makevars
...@@ -673,17 +1000,27 @@ if test $with_gettext = yes; then ...@@ -673,17 +1000,27 @@ if test $with_gettext = yes; then
673 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/ 1000 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
674 /^subdir *=.*/s/=.*/= runtime-po/ 1001 /^subdir *=.*/s/=.*/= runtime-po/
675 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/ 1002 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
676 /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
677 /^XGETTEXT_OPTIONS *=/{ 1003 /^XGETTEXT_OPTIONS *=/{
678 s/$/ \\/ 1004 s/$/ \\/
679 a\ 1005 a\
680 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+} 1006 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
681 } 1007 }
682 ' <po/Makevars.template >runtime-po/Makevars 1008 ' po/Makevars.template >runtime-po/Makevars \
1009 || die 'cannot generate runtime-po/Makevars'
683 1010
684 # Copy identical files from po to runtime-po. 1011 # Copy identical files from po to runtime-po.
685 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po) 1012 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
686 fi 1013 fi
687 fi 1014 fi
688 1015
1016 bootstrap_epilogue
1017
689 echo "$0: done. Now you can run './configure'." 1018 echo "$0: done. Now you can run './configure'."
1019
1020 # Local variables:
1021 # eval: (add-hook 'write-file-hooks 'time-stamp)
1022 # time-stamp-start: "scriptversion="
1023 # time-stamp-format: "%:y-%02m-%02d.%02H"
1024 # time-stamp-time-zone: "UTC"
1025 # time-stamp-end: "; # UTC"
1026 # End:
......
gnulib @ a6aa0b6f
1 Subproject commit a6aa0b6f74864a94e940b310f6200e18f7d9dcc9