Support for POSIX ACLs
[tar.git] / bootstrap
blob15997287d3f2862c7569b0f0dd7132cff703bcaa
1 #! /bin/sh
2 # Print a version string.
3 scriptversion=2010-10-24.18; # UTC
5 # Bootstrap this package from checked-out sources.
7 # Copyright (C) 2003-2010 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 local_gl_dir=gl
41 # Temporary directory names.
42 bt='._bootmp'
43 bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
44 bt2=${bt}2
46 usage() {
47 cat <<EOF
48 Usage: $0 [OPTION]...
49 Bootstrap this package from the checked-out sources.
51 Options:
52 --paxutils-srcdir=DIRNAME Specify the local directory where paxutils
53 sources reside. Use this if you already
54 have paxutils sources on your machine, and
55 do not want to waste your bandwidth dowloading
56 them again.
57 --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
58 sources reside. Use this if you already
59 have gnulib sources on your machine, and
60 do not want to waste your bandwidth downloading
61 them again. Defaults to \$GNULIB_SRCDIR.
62 --copy Copy files instead of creating symbolic links.
63 --force Attempt to bootstrap even if the sources seem
64 not to have been checked out.
65 --skip-po Do not download po files.
67 If the file $0.conf exists in the same directory as this script, its
68 contents are read as shell variables to configure the bootstrap.
70 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
71 are honored.
73 Running without arguments will suffice in most cases.
74 EOF
77 # Configuration.
79 # Name of the Makefile.am
80 gnulib_mk=gnulib.mk
82 # List of gnulib modules needed.
83 gnulib_modules=
85 # Any gnulib files needed that are not in modules.
86 gnulib_files=
88 # A function to be called to edit gnulib.mk right after it's created.
89 # Override it via your own definition in bootstrap.conf.
90 gnulib_mk_hook() { :; }
92 # A function to be called after everything else in this script.
93 # Override it via your own definition in bootstrap.conf.
94 bootstrap_epilogue() { :; }
96 # The command to download all .po files for a specified domain into
97 # a specified directory. Fill in the first %s is the domain name, and
98 # the second with the destination directory. Use rsync's -L and -r
99 # options because the latest/%s directory and the .po files within are
100 # all symlinks.
101 po_download_command_format=\
102 "rsync --delete --exclude '*.s1' -Lrtvz \
103 'translationproject.org::tp/latest/%s/' '%s'"
105 extract_package_name='
106 /^AC_INIT(/{
107 /.*,.*,.*, */{
108 s///
109 s/[][]//g
110 s/)$//
114 s/AC_INIT(\[*//
115 s/]*,.*//
116 s/^GNU //
117 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
118 s/[^A-Za-z0-9_]/-/g
122 package=`sed -n "$extract_package_name" configure.ac` || exit
123 gnulib_name=lib$package
125 build_aux=build-aux
126 source_base=lib
127 m4_base=m4
128 doc_base=doc
129 tests_base=tests
131 # Extra files from gnulib, which override files from other sources.
132 gnulib_extra_files="
133 $build_aux/install-sh
134 $build_aux/missing
135 $build_aux/mdate-sh
136 $build_aux/texinfo.tex
137 $build_aux/depcomp
138 $build_aux/config.guess
139 $build_aux/config.sub
140 doc/INSTALL
143 # Additional gnulib-tool options to use. Use "\newline" to break lines.
144 gnulib_tool_option_extras=
146 # Other locale categories that need message catalogs.
147 EXTRA_LOCALE_CATEGORIES=
149 # Additional xgettext options to use. Use "\\\newline" to break lines.
150 XGETTEXT_OPTIONS='\\\
151 --flag=_:1:pass-c-format\\\
152 --flag=N_:1:pass-c-format\\\
153 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
156 # Package bug report address and copyright holder for gettext files
157 COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
158 MSGID_BUGS_ADDRESS=bug-$package@gnu.org
160 # Files we don't want to import.
161 excluded_files=
163 # File that should exist in the top directory of a checked out hierarchy,
164 # but not in a distribution tarball.
165 checkout_only_file=README-hacking
167 # Whether to use copies instead of symlinks.
168 copy=false
170 # Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
171 # those files to be generated in directories like lib/, m4/, and po/.
172 # Or set it to 'auto' to make this script select which to use based
173 # on which version control system (if any) is used in the source directory.
174 vc_ignore=auto
176 # find_tool ENVVAR NAMES...
177 # -------------------------
178 # Search for a required program. Use the value of ENVVAR, if set,
179 # otherwise find the first of the NAMES that can be run (i.e.,
180 # supports --version). If found, set ENVVAR to the program name,
181 # die otherwise.
182 find_tool ()
184 find_tool_envvar=$1
185 shift
186 find_tool_names=$@
187 eval "find_tool_res=\$$find_tool_envvar"
188 if test x"$find_tool_res" = x; then
189 for i
191 if ($i --version </dev/null) >/dev/null 2>&1; then
192 find_tool_res=$i
193 break
195 done
196 else
197 find_tool_error_prefix="\$$find_tool_envvar: "
199 if test x"$find_tool_res" = x; then
200 echo >&2 "$0: one of these is required: $find_tool_names"
201 exit 1
203 ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
204 echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version"
205 exit 1
207 eval "$find_tool_envvar=\$find_tool_res"
208 eval "export $find_tool_envvar"
211 # Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
212 find_tool SHA1SUM sha1sum gsha1sum shasum
214 # Override the default configuration, if necessary.
215 # Make sure that bootstrap.conf is sourced from the current directory
216 # if we were invoked as "sh bootstrap".
217 case "$0" in
218 */*) test -r "$0.conf" && . "$0.conf" ;;
219 *) test -r "$0.conf" && . ./"$0.conf" ;;
220 esac
223 if test "$vc_ignore" = auto; then
224 vc_ignore=
225 test -d .git && vc_ignore=.gitignore
226 test -d CVS && vc_ignore="$vc_ignore .cvsignore"
229 # Translate configuration into internal form.
231 # Parse options.
233 for option
235 case $option in
236 --help)
237 usage
238 exit;;
239 --gnulib-srcdir=*)
240 GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;;
241 --paxutils-srcdir=*)
242 PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
243 --skip-po)
244 SKIP_PO=t;;
245 --force)
246 checkout_only_file=;;
247 --copy)
248 copy=true;;
250 echo >&2 "$0: $option: unknown option"
251 exit 1;;
252 esac
253 done
255 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
256 echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
257 exit 1
260 # If $STR is not already on a line by itself in $FILE, insert it,
261 # sorting the new contents of the file and replacing $FILE with the result.
262 insert_sorted_if_absent() {
263 file=$1
264 str=$2
265 test -f $file || touch $file
266 echo "$str" | sort -u - $file | cmp - $file > /dev/null \
267 || echo "$str" | sort -u - $file -o $file \
268 || exit 1
271 # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
272 found_aux_dir=no
273 grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
274 >/dev/null && found_aux_dir=yes
275 grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
276 >/dev/null && found_aux_dir=yes
277 if test $found_aux_dir = no; then
278 echo "$0: expected line not found in configure.ac. Add the following:" >&2
279 echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
280 exit 1
283 # If $build_aux doesn't exist, create it now, otherwise some bits
284 # below will malfunction. If creating it, also mark it as ignored.
285 if test ! -d $build_aux; then
286 mkdir $build_aux
287 for dot_ig in x $vc_ignore; do
288 test $dot_ig = x && continue
289 insert_sorted_if_absent $dot_ig $build_aux
290 done
293 # Note this deviates from the version comparison in automake
294 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
295 # but this should suffice as we won't be specifying old
296 # version formats or redundant trailing .0 in bootstrap.conf.
297 # If we did want full compatibility then we should probably
298 # use m4_version_compare from autoconf.
299 sort_ver() { # sort -V is not generally available
300 ver1="$1"
301 ver2="$2"
303 # split on '.' and compare each component
305 while : ; do
306 p1=$(echo "$ver1" | cut -d. -f$i)
307 p2=$(echo "$ver2" | cut -d. -f$i)
308 if [ ! "$p1" ]; then
309 echo "$1 $2"
310 break
311 elif [ ! "$p2" ]; then
312 echo "$2 $1"
313 break
314 elif [ ! "$p1" = "$p2" ]; then
315 if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
316 echo "$2 $1"
317 elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
318 echo "$1 $2"
319 else # numeric, then lexicographic comparison
320 lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
321 if [ "$lp" = "$p2" ]; then
322 echo "$1 $2"
323 else
324 echo "$2 $1"
327 break
329 i=$(($i+1))
330 done
333 get_version() {
334 app=$1
336 $app --version >/dev/null 2>&1 || return 1
338 $app --version 2>&1 |
339 sed -n '# extract version within line
340 s/.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
341 t done
343 # extract version at start of line
344 s/^\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
345 t done
349 :done
350 #the following essentially does s/5.005/5.5/
351 s/\.0*\([1-9]\)/.\1/g
356 check_versions() {
357 ret=0
359 while read app req_ver; do
360 # We only need libtoolize from the libtool package.
361 if test "$app" = libtool; then
362 app=libtoolize
364 # Honor $APP variables ($TAR, $AUTOCONF, etc.)
365 appvar=`echo $app | tr '[a-z]-' '[A-Z]_'`
366 test "$appvar" = TAR && appvar=AMTAR
367 eval "app=\${$appvar-$app}"
368 inst_ver=$(get_version $app)
369 if [ ! "$inst_ver" ]; then
370 echo "Error: '$app' not found" >&2
371 ret=1
372 elif [ ! "$req_ver" = "-" ]; then
373 latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
374 if [ ! "$latest_ver" = "$inst_ver" ]; then
375 echo "Error: '$app' version == $inst_ver is too old" >&2
376 echo " '$app' version >= $req_ver is required" >&2
377 ret=1
380 done
382 return $ret
385 print_versions() {
386 echo "Program Min_version"
387 echo "----------------------"
388 printf %s "$buildreq"
389 echo "----------------------"
390 # can't depend on column -t
393 use_libtool=0
394 # We'd like to use grep -E, to see if any of LT_INIT,
395 # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
396 # but that's not portable enough (e.g., for Solaris).
397 grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
398 && use_libtool=1
399 grep '^[ ]*LT_INIT' configure.ac >/dev/null \
400 && use_libtool=1
401 if test $use_libtool = 1; then
402 find_tool LIBTOOLIZE glibtoolize libtoolize
405 if ! printf "$buildreq" | check_versions; then
406 echo >&2
407 if test -f README-prereq; then
408 echo "See README-prereq for how to get the prerequisite programs" >&2
409 else
410 echo "Please install the prerequisite programs" >&2
412 exit 1
415 echo "$0: Bootstrapping from checked-out $package sources..."
417 # See if we can use gnulib's git-merge-changelog merge driver.
418 if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
419 if git config merge.merge-changelog.driver >/dev/null ; then
421 elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
422 echo "initializing git-merge-changelog driver"
423 git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
424 git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
425 else
426 echo "consider installing git-merge-changelog from gnulib"
430 cleanup() {
431 status=$?
432 rm -fr $1
433 exit $status
436 cleanup_gnulib() {
437 cleanup "$gnulib_path"
440 # Get paxutils files.
441 case ${PAXUTILS_SRCDIR--} in
442 -) if [ ! -d paxutils ]; then
443 echo "$0: getting paxutils files..."
445 trap "cleanup paxutils" 1 2 13 15
447 git clone --depth 1 git://git.sv.gnu.org/paxutils || cleanup paxutils
449 trap - 1 2 13 15
451 PAXUTILS_SRCDIR=paxutils
453 esac
455 if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
456 gnulib_modules=`
457 (echo "$gnulib_modules"; grep '^[^#]' $PAXUTILS_SRCDIR/gnulib.modules) |
458 sort -u
462 git_modules_config () {
463 test -f .gitmodules && git config --file .gitmodules "$@"
466 gnulib_path=`git_modules_config submodule.gnulib.path`
467 : ${gnulib_path:=gnulib}
468 # Get gnulib files.
470 case ${GNULIB_SRCDIR--} in
472 if git_modules_config submodule.gnulib.url >/dev/null; then
473 echo "$0: getting gnulib files..."
474 git submodule init || exit $?
475 git submodule update || exit $?
477 elif [ ! -d "$gnulib_path" ]; then
478 echo "$0: getting gnulib files..."
480 trap cleanup_gnulib 1 2 13 15
482 shallow=
483 git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
484 git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
485 cleanup_gnulib
487 trap - 1 2 13 15
489 GNULIB_SRCDIR=$gnulib_path
492 # Use GNULIB_SRCDIR as a reference.
493 if test -d "$GNULIB_SRCDIR"/.git && \
494 git_modules_config submodule.gnulib.url >/dev/null; then
495 echo "$0: getting gnulib files..."
496 if git submodule -h|grep -- --reference > /dev/null; then
497 # Prefer the one-liner available in git 1.6.4 or newer.
498 git submodule update --init --reference "$GNULIB_SRCDIR" \
499 "$gnulib_path" || exit $?
500 else
501 # This fallback allows at least git 1.5.5.
502 if test -f "$gnulib_path"/gnulib-tool; then
503 # Since file already exists, assume submodule init already complete.
504 git submodule update || exit $?
505 else
506 # Older git can't clone into an empty directory.
507 rmdir "$gnulib_path" 2>/dev/null
508 git clone --reference "$GNULIB_SRCDIR" \
509 "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
510 && git submodule init && git submodule update \
511 || exit $?
514 GNULIB_SRCDIR=$gnulib_path
517 esac
519 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
520 <$gnulib_tool || exit
522 # Get translations.
524 download_po_files() {
525 subdir=$1
526 domain=$2
527 echo "$0: getting translations into $subdir for $domain..."
528 cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
529 eval "$cmd"
532 # Mirror .po files to $po_dir/.reference and copy only the new
533 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
534 # Note po files that exist locally only are left in $po_dir but will
535 # not be included in LINGUAS and hence will not be distributed.
536 update_po_files() {
537 # Directory containing primary .po files.
538 # Overwrite them only when we're sure a .po file is new.
539 po_dir=$1
540 domain=$2
542 # Mirror *.po files into this dir.
543 # Usually contains *.s1 checksum files.
544 ref_po_dir="$po_dir/.reference"
546 test -d $ref_po_dir || mkdir $ref_po_dir || return
547 download_po_files $ref_po_dir $domain \
548 && ls "$ref_po_dir"/*.po 2>/dev/null |
549 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
551 langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
552 test "$langs" = '*' && langs=x
553 for po in $langs; do
554 case $po in x) continue;; esac
555 new_po="$ref_po_dir/$po.po"
556 cksum_file="$ref_po_dir/$po.s1"
557 if ! test -f "$cksum_file" ||
558 ! test -f "$po_dir/$po.po" ||
559 ! $SHA1SUM -c --status "$cksum_file" \
560 < "$new_po" > /dev/null; then
561 echo "updated $po_dir/$po.po..."
562 cp "$new_po" "$po_dir/$po.po" \
563 && $SHA1SUM < "$new_po" > "$cksum_file"
565 done
568 case $SKIP_PO in
570 if test -d po; then
571 update_po_files po $package || exit
574 if test -d runtime-po; then
575 update_po_files runtime-po $package-runtime || exit
576 fi;;
577 esac
579 symlink_to_dir()
581 src=$1/$2
582 dst=${3-$2}
584 test -f "$src" && {
586 # If the destination directory doesn't exist, create it.
587 # This is required at least for "lib/uniwidth/cjk.h".
588 dst_dir=`dirname "$dst"`
589 if ! test -d "$dst_dir"; then
590 mkdir -p "$dst_dir"
592 # If we've just created a directory like lib/uniwidth,
593 # tell version control system(s) it's ignorable.
594 # FIXME: for now, this does only one level
595 parent=`dirname "$dst_dir"`
596 for dot_ig in x $vc_ignore; do
597 test $dot_ig = x && continue
598 ig=$parent/$dot_ig
599 insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
600 done
603 if $copy; then
605 test ! -h "$dst" || {
606 echo "$0: rm -f $dst" &&
607 rm -f "$dst"
609 } &&
610 test -f "$dst" &&
611 cmp -s "$src" "$dst" || {
612 echo "$0: cp -fp $src $dst" &&
613 cp -fp "$src" "$dst"
615 else
616 test -h "$dst" &&
617 src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
618 dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
619 test "$src_i" = "$dst_i" || {
620 dot_dots=
621 case $src in
622 /*) ;;
624 case /$dst/ in
625 /./*) ;;
626 *//* | */../* | */./* | /*/*/*/*/*/)
627 echo >&2 "$0: invalid symlink calculation: $src -> $dst"
628 exit 1;;
629 /*/*/*/*/) dot_dots=../../../;;
630 /*/*/*/) dot_dots=../../;;
631 /*/*/) dot_dots=../;;
632 esac;;
633 esac
635 echo "$0: ln -fs $dot_dots$src $dst" &&
636 ln -fs "$dot_dots$src" "$dst"
642 cp_mark_as_generated()
644 cp_src=$1
645 cp_dst=$2
647 if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
648 symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
649 elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
650 symlink_to_dir $local_gl_dir "$cp_dst"
651 else
652 case $cp_dst in
653 *.[ch]) c1='/* '; c2=' */';;
654 *.texi) c1='@c '; c2= ;;
655 *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
656 *) c1= ; c2= ;;
657 esac
659 # If the destination directory doesn't exist, create it.
660 # This is required at least for "lib/uniwidth/cjk.h".
661 dst_dir=`dirname "$cp_dst"`
662 test -d "$dst_dir" || mkdir -p "$dst_dir"
664 if test -z "$c1"; then
665 cmp -s "$cp_src" "$cp_dst" || {
666 # Copy the file first to get proper permissions if it
667 # doesn't already exist. Then overwrite the copy.
668 echo "$0: cp -f $cp_src $cp_dst" &&
669 rm -f "$cp_dst" &&
670 cp "$cp_src" "$cp_dst-t" &&
671 sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
672 mv -f "$cp_dst-t" "$cp_dst"
674 else
675 # Copy the file first to get proper permissions if it
676 # doesn't already exist. Then overwrite the copy.
677 cp "$cp_src" "$cp_dst-t" &&
679 echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
680 echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
681 sed "s!$bt_regex/!!g" "$cp_src"
682 ) > $cp_dst-t &&
683 if cmp -s "$cp_dst-t" "$cp_dst"; then
684 rm -f "$cp_dst-t"
685 else
686 echo "$0: cp $cp_src $cp_dst # with edits" &&
687 mv -f "$cp_dst-t" "$cp_dst"
693 version_controlled_file() {
694 dir=$1
695 file=$2
696 found=no
697 if test -d CVS; then
698 grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
699 grep '^/[^/]*/[0-9]' > /dev/null && found=yes
700 elif test -d .git; then
701 git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
702 elif test -d .svn; then
703 svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
704 else
705 echo "$0: no version control for $dir/$file?" >&2
707 test $found = yes
710 slurp() {
711 for dir in . `(cd $1 && find * -type d -print)`; do
712 copied=
713 sep=
714 for file in `ls -a $1/$dir`; do
715 case $file in
716 .|..) continue;;
717 # FIXME: should all file names starting with "." be ignored?
718 .*) continue;;
719 esac
720 test -d $1/$dir/$file && continue
721 for excluded_file in $excluded_files; do
722 test "$dir/$file" = "$excluded_file" && continue 2
723 done
724 if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
725 copied=$copied${sep}$gnulib_mk; sep=$nl
726 remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
727 sed "$remove_intl" $1/$dir/$file |
728 cmp - $dir/$gnulib_mk > /dev/null || {
729 echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
730 rm -f $dir/$gnulib_mk &&
731 sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk &&
732 gnulib_mk_hook $dir/$gnulib_mk
734 elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
735 version_controlled_file $dir $file; then
736 echo "$0: $dir/$file overrides $1/$dir/$file"
737 else
738 copied=$copied$sep$file; sep=$nl
739 if test $file = gettext.m4; then
740 echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
741 rm -f $dir/$file
742 sed '
743 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
744 AC_DEFUN([AM_INTL_SUBDIR], [])
745 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
746 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
748 AC_DEFUN([gl_LOCK_EARLY], [])
749 ' $1/$dir/$file >$dir/$file
750 else
751 cp_mark_as_generated $1/$dir/$file $dir/$file
753 fi || exit
754 done
756 for dot_ig in x $vc_ignore; do
757 test $dot_ig = x && continue
758 ig=$dir/$dot_ig
759 if test -n "$copied"; then
760 insert_sorted_if_absent $ig "$copied"
761 # If an ignored file name ends with .in.h, then also add
762 # the name with just ".h". Many gnulib headers are generated,
763 # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
764 # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
765 f=`echo "$copied" |
766 sed '
767 s/\.in\.h$/.h/
768 s/\.sin$/.sed/
769 s/\.y$/.c/
770 s/\.gperf$/.h/
773 insert_sorted_if_absent $ig "$f"
775 # For files like sys_stat.in.h and sys_time.in.h, record as
776 # ignorable the directory we might eventually create: sys/.
777 f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
778 insert_sorted_if_absent $ig "$f"
780 done
781 done
785 # Create boot temporary directories to import from gnulib and gettext.
786 rm -fr $bt $bt2 &&
787 mkdir $bt $bt2 || exit
789 # Import from gnulib.
791 gnulib_tool_options="\
792 --import\
793 --no-changelog\
794 --aux-dir $bt/$build_aux\
795 --doc-base $bt/$doc_base\
796 --lib $gnulib_name\
797 --m4-base $bt/$m4_base/\
798 --source-base $bt/$source_base/\
799 --tests-base $bt/$tests_base\
800 --local-dir $local_gl_dir\
801 $gnulib_tool_option_extras\
803 if test $use_libtool = 1; then
804 case "$gnulib_tool_options " in
805 *' --libtool '*) ;;
806 *) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
807 esac
809 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
810 $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
811 slurp $bt || exit
813 for file in $gnulib_files; do
814 symlink_to_dir "$GNULIB_SRCDIR" $file || exit
815 done
818 # Import from gettext.
819 with_gettext=yes
820 grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
821 with_gettext=no
823 if test $with_gettext = yes; then
824 echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..."
825 cp configure.ac $bt2 &&
826 (cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) &&
827 slurp $bt2 $bt || exit
829 rm -fr $bt $bt2 || exit
831 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
832 # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
833 # The following requires GNU find 4.2.3 or newer. Considering the usual
834 # portability constraints of this script, that may seem a very demanding
835 # requirement, but it should be ok. Ignore any failure, which is fine,
836 # since this is only a convenience to help developers avoid the relatively
837 # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
838 # between successive runs of this script.
839 find "$m4_base" "$source_base" \
840 -depth \( -name '*.m4' -o -name '*.[ch]' \) \
841 -type l -xtype l -delete > /dev/null 2>&1
843 # Reconfigure, getting other files.
845 # copy_files srcdir dstdir
846 copy_files() {
847 for file in `cat $1/DISTFILES`
849 case $file in
850 "#*") continue;;
851 esac
852 dst=`echo $file | sed 's^.*/^^'`
853 if [ $# -eq 3 ]; then
854 case $dst in
855 ${3}*) ;;
856 *) dst=${3}$dst;;
857 esac
859 symlink_to_dir "$1" "$file" "$2/$dst" || exit
860 # FIXME ignorefile $2 $dst
861 done
864 # Import from paxutils
865 copy_files ${PAXUTILS_SRCDIR} .
866 copy_files ${PAXUTILS_SRCDIR}/am m4
867 echo "$0: Creating m4/paxutils.m4"
868 (echo "# This file is generated automatically. Please, do not edit."
869 echo "#"
870 echo "AC_DEFUN([${package}_PAXUTILS],["
871 cat ${PAXUTILS_SRCDIR}/am/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
872 echo "])") > ./m4/paxutils.m4
873 #FIXME ignorefile m4 paxutils.m4
875 if [ -d rmt ]; then
877 else
878 mkdir rmt
881 for dir in doc rmt lib tests
883 copy_files ${PAXUTILS_SRCDIR}/$dir $dir
884 done
886 copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
890 # Skip autoheader if it's not needed.
891 grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null ||
892 AUTOHEADER=true
894 for command in \
895 libtool \
896 "${ACLOCAL-aclocal} --force -I m4 $ACLOCAL_FLAGS" \
897 "${AUTOCONF-autoconf} --force" \
898 "${AUTOHEADER-autoheader} --force" \
899 "${AUTOMAKE-automake} --add-missing --copy --force-missing"
901 if test "$command" = libtool; then
902 test $use_libtool = 0 \
903 && continue
904 command="${LIBTOOLIZE-libtoolize} -c -f"
906 echo "$0: $command ..."
907 $command || exit
908 done
911 # Get some extra files from gnulib, overriding existing files.
912 for file in $gnulib_extra_files; do
913 case $file in
914 */INSTALL) dst=INSTALL;;
915 build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
916 *) dst=$file;;
917 esac
918 symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
919 done
921 if test $with_gettext = yes; then
922 # Create gettext configuration.
923 echo "$0: Creating po/Makevars from po/Makevars.template ..."
924 rm -f po/Makevars
925 sed '
926 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
927 /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
928 /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
929 /^XGETTEXT_OPTIONS *=/{
930 s/$/ \\/
932 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
934 ' po/Makevars.template >po/Makevars || exit 1
936 if test -d runtime-po; then
937 # Similarly for runtime-po/Makevars, but not quite the same.
938 rm -f runtime-po/Makevars
939 sed '
940 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
941 /^subdir *=.*/s/=.*/= runtime-po/
942 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
943 /^XGETTEXT_OPTIONS *=/{
944 s/$/ \\/
946 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
948 ' po/Makevars.template >runtime-po/Makevars || exit 1
950 # Copy identical files from po to runtime-po.
951 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
955 bootstrap_epilogue
957 echo "$0: done. Now you can run './configure'."
959 # Local variables:
960 # eval: (add-hook 'write-file-hooks 'time-stamp)
961 # time-stamp-start: "scriptversion="
962 # time-stamp-format: "%:y-%02m-%02d.%02H"
963 # time-stamp-time-zone: "UTC"
964 # time-stamp-end: "; # UTC"
965 # End: