]> git.saurik.com Git - bison.git/blob - bootstrap
Do not use date ranges in copyright notices.
[bison.git] / bootstrap
1 #! /bin/sh
2
3 # Bootstrap this package from checked-out sources.
4
5 # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
6 # Software Foundation, Inc.
7
8 # 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 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17
18 # 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
21 # Written by Paul Eggert.
22
23 nl='
24 '
25
26 # Ensure file names are sorted consistently across platforms.
27 # Also, ensure diagnostics are in English, e.g., "wget --help" below.
28 LC_ALL=C
29 export LC_ALL
30
31 local_gl_dir=gl
32
33 # Temporary directory names.
34 bt='._bootmp'
35 bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
36 bt2=${bt}2
37
38 usage() {
39 cat <<EOF
40 Usage: $0 [OPTION]...
41 Bootstrap this package from the checked-out sources.
42
43 Options:
44 --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
45 sources reside. Use this if you already
46 have gnulib sources on your machine, and
47 do not want to waste your bandwidth downloading
48 them again.
49 --copy Copy files instead of creating symbolic links.
50 --force Attempt to bootstrap even if the sources seem
51 not to have been checked out.
52 --skip-po Do not download po files.
53
54 If the file $0.conf exists in the same directory as this script, its
55 contents are read as shell variables to configure the bootstrap.
56
57 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
58 are honored.
59
60 Running without arguments will suffice in most cases.
61 EOF
62 }
63
64 # Configuration.
65
66 # Name of the Makefile.am
67 gnulib_mk=gnulib.mk
68
69 # List of gnulib modules needed.
70 gnulib_modules=
71
72 # Any gnulib files needed that are not in modules.
73 gnulib_files=
74
75 # A function to be called after everything else in this script.
76 # Override it via your own definition in bootstrap.conf.
77 bootstrap_epilogue() { :; }
78
79 # The command to download all .po files for a specified domain into
80 # a specified directory. Fill in the first %s is the domain name, and
81 # the second with the destination directory. Use rsync's -L and -r
82 # options because the latest/%s directory and the .po files within are
83 # all symlinks.
84 po_download_command_format=\
85 "rsync -Lrtvz 'translationproject.org::tp/latest/%s/' '%s'"
86
87 extract_package_name='
88 /^AC_INIT(/{
89 /.*,.*,.*, */{
90 s///
91 s/[][]//g
92 s/)$//
93 p
94 q
95 }
96 s/AC_INIT(\[*//
97 s/]*,.*//
98 s/^GNU //
99 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
100 s/[^A-Za-z0-9_]/-/g
101 p
102 }
103 '
104 package=`sed -n "$extract_package_name" configure.ac` || exit
105 gnulib_name=lib$package
106
107 build_aux=build-aux
108 source_base=lib
109 m4_base=m4
110 doc_base=doc
111 tests_base=tests
112
113 # Extra files from gnulib, which override files from other sources.
114 gnulib_extra_files="
115 $build_aux/install-sh
116 $build_aux/missing
117 $build_aux/mdate-sh
118 $build_aux/texinfo.tex
119 $build_aux/depcomp
120 $build_aux/config.guess
121 $build_aux/config.sub
122 doc/INSTALL
123 "
124
125 # Additional gnulib-tool options to use. Use "\newline" to break lines.
126 gnulib_tool_option_extras=
127
128 # Other locale categories that need message catalogs.
129 EXTRA_LOCALE_CATEGORIES=
130
131 # Additional xgettext options to use. Use "\\\newline" to break lines.
132 XGETTEXT_OPTIONS='\\\
133 --flag=_:1:pass-c-format\\\
134 --flag=N_:1:pass-c-format\\\
135 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
136 '
137
138 # Package bug report address for gettext files
139 MSGID_BUGS_ADDRESS=bug-$package@gnu.org
140
141 # Files we don't want to import.
142 excluded_files=
143
144 # File that should exist in the top directory of a checked out hierarchy,
145 # but not in a distribution tarball.
146 checkout_only_file=HACKING
147
148 # Whether to use copies instead of symlinks.
149 copy=false
150
151 # Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
152 # those files to be generated in directories like lib/, m4/, and po/.
153 # Or set it to 'auto' to make this script select which to use based
154 # on which version control system (if any) is used in the source directory.
155 vc_ignore=auto
156
157 # find_tool ENVVAR NAMES...
158 # -------------------------
159 # Search for a required program. Use the value of ENVVAR, if set,
160 # otherwise find the first of the NAMES that can be run (i.e.,
161 # supports --version). If found, set ENVVAR to the program name,
162 # die otherwise.
163 find_tool ()
164 {
165 # Find sha1sum, named gsha1sum on MacPorts.
166 find_tool_envvar=$1
167 shift
168 find_tool_names=$@
169 eval "find_tool_res=\$$find_tool_envvar"
170 if test x"$find_tool_res" = x; then
171 for i
172 do
173 if ($i --version </dev/null) >/dev/null 2>&1; then
174 find_tool_res=$i
175 break
176 fi
177 done
178 else
179 find_tool_error_prefix="\$$find_tool_envvar: "
180 fi
181 if test x"$find_tool_res" = x; then
182 echo >&2 "$0: one of these is required: $find_tool_names"
183 exit 1
184 fi
185 ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
186 echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version"
187 exit 1
188 }
189 eval "$find_tool_envvar=\$find_tool_res"
190 eval "export $find_tool_envvar"
191 }
192
193 # Find sha1sum, named gsha1sum on MacPorts.
194 find_tool SHA1SUM sha1sum gsha1sum
195
196 # Override the default configuration, if necessary.
197 # Make sure that bootstrap.conf is sourced from the current directory
198 # if we were invoked as "sh bootstrap".
199 case "$0" in
200 */*) test -r "$0.conf" && . "$0.conf" ;;
201 *) test -r "$0.conf" && . ./"$0.conf" ;;
202 esac
203
204
205 if test "$vc_ignore" = auto; then
206 vc_ignore=
207 test -d .git && vc_ignore=.gitignore
208 test -d CVS && vc_ignore="$vc_ignore .cvsignore"
209 fi
210
211 # Translate configuration into internal form.
212
213 # Parse options.
214
215 for option
216 do
217 case $option in
218 --help)
219 usage
220 exit;;
221 --gnulib-srcdir=*)
222 GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;;
223 --skip-po)
224 SKIP_PO=t;;
225 --force)
226 checkout_only_file=;;
227 --copy)
228 copy=true;;
229 *)
230 echo >&2 "$0: $option: unknown option"
231 exit 1;;
232 esac
233 done
234
235 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
236 echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
237 exit 1
238 fi
239
240 # If $STR is not already on a line by itself in $FILE, insert it,
241 # sorting the new contents of the file and replacing $FILE with the result.
242 insert_sorted_if_absent() {
243 file=$1
244 str=$2
245 test -f $file || touch $file
246 echo "$str" | sort -u - $file | cmp - $file > /dev/null \
247 || echo "$str" | sort -u - $file -o $file \
248 || exit 1
249 }
250
251 # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
252 # insert_sorted_if_absent.
253 insert_vc_ignore() {
254 vc_ignore_file="$1"
255 case $vc_ignore_file in
256 *.gitignore)
257 # A .gitignore entry that does not start with `/' applies recursively to
258 # subdirectories, so prepend `/' to every .gitignore entry.
259 pattern=`echo "$2" | sed s,^,/,`;;
260 *)
261 pattern="$2";;
262 esac
263 insert_sorted_if_absent "$vc_ignore_file" "$pattern"
264 }
265
266 # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
267 found_aux_dir=no
268 grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
269 >/dev/null && found_aux_dir=yes
270 grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
271 >/dev/null && found_aux_dir=yes
272 if test $found_aux_dir = no; then
273 echo "$0: expected line not found in configure.ac. Add the following:" >&2
274 echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
275 exit 1
276 fi
277
278 # If $build_aux doesn't exist, create it now, otherwise some bits
279 # below will malfunction. If creating it, also mark it as ignored.
280 if test ! -d $build_aux; then
281 mkdir $build_aux
282 for dot_ig in x $vc_ignore; do
283 test $dot_ig = x && continue
284 insert_vc_ignore $dot_ig $build_aux
285 done
286 fi
287
288 # Note this deviates from the version comparison in automake
289 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
290 # but this should suffice as we won't be specifying old
291 # version formats or redundant trailing .0 in bootstrap.conf.
292 # If we did want full compatibility then we should probably
293 # use m4_version_compare from autoconf.
294 sort_ver() { # sort -V is not generally available
295 ver1="$1"
296 ver2="$2"
297
298 # split on '.' and compare each component
299 i=1
300 while : ; do
301 p1=$(echo "$ver1" | cut -d. -f$i)
302 p2=$(echo "$ver2" | cut -d. -f$i)
303 if [ ! "$p1" ]; then
304 echo "$1 $2"
305 break
306 elif [ ! "$p2" ]; then
307 echo "$2 $1"
308 break
309 elif [ ! "$p1" = "$p2" ]; then
310 if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
311 echo "$2 $1"
312 elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
313 echo "$1 $2"
314 else # numeric, then lexicographic comparison
315 lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
316 if [ "$lp" = "$p2" ]; then
317 echo "$1 $2"
318 else
319 echo "$2 $1"
320 fi
321 fi
322 break
323 fi
324 i=$(($i+1))
325 done
326 }
327
328 get_version() {
329 app=$1
330
331 $app --version >/dev/null 2>&1 || return 1
332
333 $app --version 2>&1 |
334 sed -n '# extract version within line
335 s/.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
336 t done
337
338 # extract version at start of line
339 s/^\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
340 t done
341
342 d
343
344 :done
345 #the following essentially does s/5.005/5.5/
346 s/\.0*\([1-9]\)/.\1/g
347 p
348 q'
349 }
350
351 check_versions() {
352 ret=0
353
354 while read app req_ver; do
355 # Honor $APP variables ($TAR, $AUTOCONF, etc.)
356 appvar=`echo $app | tr '[a-z]' '[A-Z]'`
357 test "$appvar" = TAR && appvar=AMTAR
358 eval "app=\${$appvar-$app}"
359 inst_ver=$(get_version $app)
360 if [ ! "$inst_ver" ]; then
361 echo "Error: '$app' not found" >&2
362 ret=1
363 elif [ ! "$req_ver" = "-" ]; then
364 latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
365 if [ ! "$latest_ver" = "$inst_ver" ]; then
366 echo "Error: '$app' version == $inst_ver is too old" >&2
367 echo " '$app' version >= $req_ver is required" >&2
368 ret=1
369 fi
370 fi
371 done
372
373 return $ret
374 }
375
376 print_versions() {
377 echo "Program Min_version"
378 echo "----------------------"
379 printf "$buildreq"
380 echo "----------------------"
381 # can't depend on column -t
382 }
383
384 if ! printf "$buildreq" | check_versions; then
385 test -f README-prereq &&
386 echo "See README-prereq for notes on obtaining these prerequisite programs:" >&2
387 echo
388 print_versions
389 exit 1
390 fi
391
392 echo "$0: Bootstrapping from checked-out $package sources..."
393
394 # See if we can use gnulib's git-merge-changelog merge driver.
395 if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
396 if git config merge.merge-changelog.driver >/dev/null ; then
397 :
398 elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
399 echo "initializing git-merge-changelog driver"
400 git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
401 git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
402 else
403 echo "consider installing git-merge-changelog from gnulib"
404 fi
405 fi
406
407
408 cleanup_gnulib() {
409 status=$?
410 rm -fr gnulib
411 exit $status
412 }
413
414 git_modules_config () {
415 test -f .gitmodules && git config --file .gitmodules "$@"
416 }
417
418 # Get gnulib files.
419
420 case ${GNULIB_SRCDIR--} in
421 -)
422 if git_modules_config submodule.gnulib.url >/dev/null; then
423 echo "$0: getting gnulib files..."
424 git submodule init || exit $?
425 git submodule update || exit $?
426
427 elif [ ! -d gnulib ]; then
428 echo "$0: getting gnulib files..."
429
430 trap cleanup_gnulib 1 2 13 15
431
432 git clone --help|grep depth > /dev/null && shallow='--depth 2' || shallow=
433 git clone $shallow git://git.sv.gnu.org/gnulib ||
434 cleanup_gnulib
435
436 trap - 1 2 13 15
437 fi
438 GNULIB_SRCDIR=gnulib
439 ;;
440 *)
441 # Redirect the gnulib submodule to the directory on the command line
442 # if possible.
443 if test -d "$GNULIB_SRCDIR"/.git && \
444 git_modules_config submodule.gnulib.url >/dev/null; then
445 git submodule init
446 GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
447 git_modules_config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
448 echo "$0: getting gnulib files..."
449 git submodule update || exit $?
450 GNULIB_SRCDIR=gnulib
451 fi
452 ;;
453 esac
454
455 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
456 <$gnulib_tool || exit
457
458 # Get translations.
459
460 download_po_files() {
461 subdir=$1
462 domain=$2
463 echo "$0: getting translations into $subdir for $domain..."
464 cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
465 eval "$cmd"
466 }
467
468 # Download .po files to $po_dir/.reference and copy only the new
469 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
470 update_po_files() {
471 # Directory containing primary .po files.
472 # Overwrite them only when we're sure a .po file is new.
473 po_dir=$1
474 domain=$2
475
476 # Download *.po files into this dir.
477 # Usually contains *.s1 checksum files.
478 ref_po_dir="$po_dir/.reference"
479
480 test -d $ref_po_dir || mkdir $ref_po_dir || return
481 download_po_files $ref_po_dir $domain \
482 && ls "$ref_po_dir"/*.po 2>/dev/null |
483 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
484
485 langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
486 test "$langs" = '*' && langs=x
487 for po in $langs; do
488 case $po in x) continue;; esac
489 new_po="$ref_po_dir/$po.po"
490 cksum_file="$ref_po_dir/$po.s1"
491 if ! test -f "$cksum_file" ||
492 ! test -f "$po_dir/$po.po" ||
493 ! $SHA1SUM -c --status "$cksum_file" \
494 < "$new_po" > /dev/null; then
495 echo "updated $po_dir/$po.po..."
496 cp "$new_po" "$po_dir/$po.po" \
497 && $SHA1SUM < "$new_po" > "$cksum_file"
498 fi
499 done
500 }
501
502 case $SKIP_PO in
503 '')
504 if test -d po; then
505 update_po_files po $package || exit
506 fi
507
508 if test -d runtime-po; then
509 update_po_files runtime-po $package-runtime || exit
510 fi;;
511 esac
512
513 check_dst_dir()
514 {
515 dst=$1
516 # If the destination directory doesn't exist, create it.
517 # This is required at least for "lib/uniwidth/cjk.h".
518 dst_dir=`dirname "$dst"`
519 if ! test -d "$dst_dir"; then
520 mkdir -p "$dst_dir"
521
522 # If we've just created a directory like lib/uniwidth,
523 # tell version control system(s) it's ignorable.
524 # FIXME: for now, this does only one level
525 parent=`dirname "$dst_dir"`
526 for dot_ig in x $vc_ignore; do
527 test $dot_ig = x && continue
528 ig=$parent/$dot_ig
529 insert_vc_ignore $ig `echo "$dst_dir"|sed 's,.*/,,'`
530 done
531 fi
532 }
533
534 symlink_to_dir()
535 {
536 src=$1/$2
537 dst=${3-$2}
538
539 test -f "$src" && {
540
541 check_dst_dir "$dst"
542
543 if $copy; then
544 {
545 test ! -h "$dst" || {
546 echo "$0: rm -f $dst" &&
547 rm -f "$dst"
548 }
549 } &&
550 test -f "$dst" &&
551 cmp -s "$src" "$dst" || {
552 echo "$0: cp -fp $src $dst" &&
553 cp -fp "$src" "$dst"
554 }
555 else
556 test -h "$dst" &&
557 src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
558 dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
559 test "$src_i" = "$dst_i" || {
560 dot_dots=
561 case $src in
562 /*) ;;
563 *)
564 case /$dst/ in
565 *//* | */../* | */./* | /*/*/*/*/*/)
566 echo >&2 "$0: invalid symlink calculation: $src -> $dst"
567 exit 1;;
568 /*/*/*/*/) dot_dots=../../../;;
569 /*/*/*/) dot_dots=../../;;
570 /*/*/) dot_dots=../;;
571 esac;;
572 esac
573
574 echo "$0: ln -fs $dot_dots$src $dst" &&
575 ln -fs "$dot_dots$src" "$dst"
576 }
577 fi
578 }
579 }
580
581 cp_mark_as_generated()
582 {
583 cp_src=$1
584 cp_dst=$2
585
586 if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
587 symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
588 elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
589 symlink_to_dir $local_gl_dir "$cp_dst"
590 else
591 case $cp_dst in
592 *.[ch]) c1='/* '; c2=' */';;
593 *.texi) c1='@c '; c2= ;;
594 *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
595 *) c1= ; c2= ;;
596 esac
597
598 if test -z "$c1"; then
599 cmp -s "$cp_src" "$cp_dst" || {
600 # Copy the file first to get proper permissions if it
601 # doesn't already exist. Then overwrite the copy.
602 echo "$0: cp -f $cp_src $cp_dst" &&
603 rm -f "$cp_dst" &&
604 cp "$cp_src" "$cp_dst-t" &&
605 sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
606 mv -f "$cp_dst-t" "$cp_dst"
607 }
608 else
609 check_dst_dir "$cp_dst"
610 # Copy the file first to get proper permissions if it
611 # doesn't already exist. Then overwrite the copy.
612 cp "$cp_src" "$cp_dst-t" &&
613 (
614 echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
615 echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
616 sed "s!$bt_regex/!!g" "$cp_src"
617 ) > $cp_dst-t &&
618 if cmp -s "$cp_dst-t" "$cp_dst"; then
619 rm -f "$cp_dst-t"
620 else
621 echo "$0: cp $cp_src $cp_dst # with edits" &&
622 mv -f "$cp_dst-t" "$cp_dst"
623 fi
624 fi
625 fi
626 }
627
628 version_controlled_file() {
629 dir=$1
630 file=$2
631 found=no
632 if test -d CVS; then
633 grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
634 grep '^/[^/]*/[0-9]' > /dev/null && found=yes
635 elif test -d .git; then
636 git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
637 elif test -d .svn; then
638 svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
639 else
640 echo "$0: no version control for $dir/$file?" >&2
641 fi
642 test $found = yes
643 }
644
645 slurp() {
646 for dir in . `(cd $1 && find * -type d -print)`; do
647 copied=
648 sep=
649 for file in `ls -a $1/$dir`; do
650 case $file in
651 .|..) continue;;
652 .*) continue;; # FIXME: should all file names starting with "." be ignored?
653 esac
654 test -d $1/$dir/$file && continue
655 for excluded_file in $excluded_files; do
656 test "$dir/$file" = "$excluded_file" && continue 2
657 done
658 if test $file = Makefile.am; then
659 copied=$copied${sep}$gnulib_mk; sep=$nl
660 remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
661 sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || {
662 echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
663 rm -f $dir/$gnulib_mk &&
664 sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
665 }
666 elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
667 version_controlled_file $dir $file; then
668 echo "$0: $dir/$file overrides $1/$dir/$file"
669 else
670 copied=$copied$sep$file; sep=$nl
671 if test $file = gettext.m4; then
672 echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
673 rm -f $dir/$file
674 sed '
675 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
676 AC_DEFUN([AM_INTL_SUBDIR], [
677 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
678 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
679 $a\
680 AC_DEFUN([gl_LOCK_EARLY], [])
681 ' $1/$dir/$file >$dir/$file
682 else
683 cp_mark_as_generated $1/$dir/$file $dir/$file
684 fi
685 fi || exit
686 done
687
688 for dot_ig in x $vc_ignore; do
689 test $dot_ig = x && continue
690 ig=$dir/$dot_ig
691 if test -n "$copied"; then
692 insert_vc_ignore $ig "$copied"
693 # If an ignored file name ends with .in.h, then also add
694 # the name with just ".h". Many gnulib headers are generated,
695 # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
696 # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
697 f=`echo "$copied"|sed 's/\.in\.h$/.h/;s/\.sin$/.sed/;s/\.y$/.c/;s/\.gperf$/.h/'`
698 insert_vc_ignore $ig "$f"
699
700 # For files like sys_stat.in.h and sys_time.in.h, record as
701 # ignorable the directory we might eventually create: sys/.
702 f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
703 insert_vc_ignore $ig "$f"
704 fi
705 done
706 done
707 }
708
709
710 # Create boot temporary directories to import from gnulib and gettext.
711 rm -fr $bt $bt2 &&
712 mkdir $bt $bt2 || exit
713
714 # Import from gnulib.
715
716 gnulib_tool_options="\
717 --import\
718 --no-changelog\
719 --aux-dir $bt/$build_aux\
720 --doc-base $bt/$doc_base\
721 --lib $gnulib_name\
722 --m4-base $bt/$m4_base/\
723 --source-base $bt/$source_base/\
724 --tests-base $bt/$tests_base\
725 --local-dir $local_gl_dir\
726 $gnulib_tool_option_extras\
727 "
728 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
729 $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
730 slurp $bt || exit
731
732 for file in $gnulib_files; do
733 symlink_to_dir "$GNULIB_SRCDIR" $file || exit
734 done
735
736
737 # Import from gettext.
738 with_gettext=yes
739 grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
740 with_gettext=no
741
742 if test $with_gettext = yes; then
743 echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..."
744 cp configure.ac $bt2 &&
745 (cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) &&
746 slurp $bt2 $bt || exit
747 fi
748 rm -fr $bt $bt2 || exit
749
750 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
751 # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
752 # The following requires GNU find 4.2.3 or newer. Considering the usual
753 # portability constraints of this script, that may seem a very demanding
754 # requirement, but it should be ok. Ignore any failure, which is fine,
755 # since this is only a convenience to help developers avoid the relatively
756 # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
757 # between successive runs of this script.
758 find "$m4_base" "$source_base" \
759 -depth \( -name '*.m4' -o -name '*.[ch]' \) \
760 -type l -xtype l -delete > /dev/null 2>&1
761
762 # Reconfigure, getting other files.
763
764 # Skip autoheader if it's not needed.
765 grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null ||
766 AUTOHEADER=true
767
768 for command in \
769 libtool \
770 "${ACLOCAL-aclocal} --force -I m4" \
771 "${AUTOCONF-autoconf} --force" \
772 "${AUTOHEADER-autoheader} --force" \
773 "${AUTOMAKE-automake} --add-missing --copy --force-missing"
774 do
775 if test "$command" = libtool; then
776 use_libtool=0
777 # We'd like to use grep -E, to see if any of LT_INIT,
778 # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
779 # but that's not portable enough (e.g., for Solaris).
780 grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
781 && use_libtool=1
782 grep '^[ ]*LT_INIT' configure.ac >/dev/null \
783 && use_libtool=1
784 test $use_libtool = 0 \
785 && continue
786 command="${LIBTOOLIZE-libtoolize} -c -f"
787 fi
788 echo "$0: $command ..."
789 $command || exit
790 done
791
792
793 # Get some extra files from gnulib, overriding existing files.
794 for file in $gnulib_extra_files; do
795 case $file in
796 */INSTALL) dst=INSTALL;;
797 build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
798 *) dst=$file;;
799 esac
800 symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
801 done
802
803 if test $with_gettext = yes; then
804 # Create gettext configuration.
805 echo "$0: Creating po/Makevars from po/Makevars.template ..."
806 rm -f po/Makevars
807 sed '
808 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
809 /^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
810 /^XGETTEXT_OPTIONS *=/{
811 s/$/ \\/
812 a\
813 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
814 }
815 ' po/Makevars.template >po/Makevars
816
817 if test -d runtime-po; then
818 # Similarly for runtime-po/Makevars, but not quite the same.
819 rm -f runtime-po/Makevars
820 sed '
821 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
822 /^subdir *=.*/s/=.*/= runtime-po/
823 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
824 /^XGETTEXT_OPTIONS *=/{
825 s/$/ \\/
826 a\
827 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
828 }
829 ' <po/Makevars.template >runtime-po/Makevars
830
831 # Copy identical files from po to runtime-po.
832 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
833 fi
834 fi
835
836 bootstrap_epilogue
837
838 echo "$0: done. Now you can run './configure'."
839
840 # Local Variables:
841 # indent-tabs-mode: nil
842 # End: