]> Dogcows Code - chaz/tar/blob - bootstrap
Version 1.24
[chaz/tar] / bootstrap
1 #! /bin/sh
2 # Print a version string.
3 scriptversion=2010-10-24.18; # UTC
4
5 # Bootstrap this package from checked-out sources.
6
7 # Copyright (C) 2003-2010 Free Software Foundation, Inc.
8
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.
13
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.
18
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/>.
21
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.
31
32 nl='
33 '
34
35 # Ensure file names are sorted consistently across platforms.
36 LC_ALL=C
37 export LC_ALL
38
39 local_gl_dir=gl
40
41 # Temporary directory names.
42 bt='._bootmp'
43 bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
44 bt2=${bt}2
45
46 usage() {
47 cat <<EOF
48 Usage: $0 [OPTION]...
49 Bootstrap this package from the checked-out sources.
50
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.
66
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.
69
70 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
71 are honored.
72
73 Running without arguments will suffice in most cases.
74 EOF
75 }
76
77 # Configuration.
78
79 # Name of the Makefile.am
80 gnulib_mk=gnulib.mk
81
82 # List of gnulib modules needed.
83 gnulib_modules=
84
85 # Any gnulib files needed that are not in modules.
86 gnulib_files=
87
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() { :; }
91
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() { :; }
95
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'"
104
105 extract_package_name='
106 /^AC_INIT(/{
107 /.*,.*,.*, */{
108 s///
109 s/[][]//g
110 s/)$//
111 p
112 q
113 }
114 s/AC_INIT(\[*//
115 s/]*,.*//
116 s/^GNU //
117 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
118 s/[^A-Za-z0-9_]/-/g
119 p
120 }
121 '
122 package=`sed -n "$extract_package_name" configure.ac` || exit
123 gnulib_name=lib$package
124
125 build_aux=build-aux
126 source_base=lib
127 m4_base=m4
128 doc_base=doc
129 tests_base=tests
130
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
141 "
142
143 # Additional gnulib-tool options to use. Use "\newline" to break lines.
144 gnulib_tool_option_extras=
145
146 # Other locale categories that need message catalogs.
147 EXTRA_LOCALE_CATEGORIES=
148
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\\\
154 '
155
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
159
160 # Files we don't want to import.
161 excluded_files=
162
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
166
167 # Whether to use copies instead of symlinks.
168 copy=false
169
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
175
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 ()
183 {
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
190 do
191 if ($i --version </dev/null) >/dev/null 2>&1; then
192 find_tool_res=$i
193 break
194 fi
195 done
196 else
197 find_tool_error_prefix="\$$find_tool_envvar: "
198 fi
199 if test x"$find_tool_res" = x; then
200 echo >&2 "$0: one of these is required: $find_tool_names"
201 exit 1
202 fi
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
206 }
207 eval "$find_tool_envvar=\$find_tool_res"
208 eval "export $find_tool_envvar"
209 }
210
211 # Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
212 find_tool SHA1SUM sha1sum gsha1sum shasum
213
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
221
222
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"
227 fi
228
229 # Translate configuration into internal form.
230
231 # Parse options.
232
233 for option
234 do
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;;
249 *)
250 echo >&2 "$0: $option: unknown option"
251 exit 1;;
252 esac
253 done
254
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
258 fi
259
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
269 }
270
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
281 fi
282
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
291 fi
292
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"
302
303 # split on '.' and compare each component
304 i=1
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"
325 fi
326 fi
327 break
328 fi
329 i=$(($i+1))
330 done
331 }
332
333 get_version() {
334 app=$1
335
336 $app --version >/dev/null 2>&1 || return 1
337
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
342
343 # extract version at start of line
344 s/^\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
345 t done
346
347 d
348
349 :done
350 #the following essentially does s/5.005/5.5/
351 s/\.0*\([1-9]\)/.\1/g
352 p
353 q'
354 }
355
356 check_versions() {
357 ret=0
358
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
363 fi
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
378 fi
379 fi
380 done
381
382 return $ret
383 }
384
385 print_versions() {
386 echo "Program Min_version"
387 echo "----------------------"
388 printf %s "$buildreq"
389 echo "----------------------"
390 # can't depend on column -t
391 }
392
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
403 fi
404
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
411 fi
412 exit 1
413 fi
414
415 echo "$0: Bootstrapping from checked-out $package sources..."
416
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
420 :
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"
427 fi
428 fi
429
430 cleanup() {
431 status=$?
432 rm -fr $1
433 exit $status
434 }
435
436 cleanup_gnulib() {
437 cleanup "$gnulib_path"
438 }
439
440 # Get paxutils files.
441 case ${PAXUTILS_SRCDIR--} in
442 -) if [ ! -d paxutils ]; then
443 echo "$0: getting paxutils files..."
444
445 trap "cleanup paxutils" 1 2 13 15
446
447 git clone --depth 1 git://git.sv.gnu.org/paxutils || cleanup paxutils
448
449 trap - 1 2 13 15
450 fi
451 PAXUTILS_SRCDIR=paxutils
452 ;;
453 esac
454
455 if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
456 gnulib_modules=`
457 (echo "$gnulib_modules"; grep '^[^#]' $PAXUTILS_SRCDIR/gnulib.modules) |
458 sort -u
459 `
460 fi
461
462 git_modules_config () {
463 test -f .gitmodules && git config --file .gitmodules "$@"
464 }
465
466 gnulib_path=`git_modules_config submodule.gnulib.path`
467 : ${gnulib_path=gnulib}
468
469 # Get gnulib files.
470
471 case ${GNULIB_SRCDIR--} in
472 -)
473 if git_modules_config submodule.gnulib.url >/dev/null; then
474 echo "$0: getting gnulib files..."
475 git submodule init || exit $?
476 git submodule update || exit $?
477
478 elif [ ! -d "$gnulib_path" ]; then
479 echo "$0: getting gnulib files..."
480
481 trap cleanup_gnulib 1 2 13 15
482
483 shallow=
484 git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
485 git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
486 cleanup_gnulib
487
488 trap - 1 2 13 15
489 fi
490 GNULIB_SRCDIR=$gnulib_path
491 ;;
492 *)
493 # Use GNULIB_SRCDIR as a reference.
494 if test -d "$GNULIB_SRCDIR"/.git && \
495 git_modules_config submodule.gnulib.url >/dev/null; then
496 echo "$0: getting gnulib files..."
497 if git submodule -h|grep -- --reference > /dev/null; then
498 # Prefer the one-liner available in git 1.6.4 or newer.
499 git submodule update --init --reference "$GNULIB_SRCDIR" \
500 "$gnulib_path" || exit $?
501 else
502 # This fallback allows at least git 1.5.5.
503 if test -f "$gnulib_path"/gnulib-tool; then
504 # Since file already exists, assume submodule init already complete.
505 git submodule update || exit $?
506 else
507 # Older git can't clone into an empty directory.
508 rmdir "$gnulib_path" 2>/dev/null
509 git clone --reference "$GNULIB_SRCDIR" \
510 "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
511 && git submodule init && git submodule update \
512 || exit $?
513 fi
514 fi
515 GNULIB_SRCDIR=$gnulib_path
516 fi
517 ;;
518 esac
519
520 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
521 <$gnulib_tool || exit
522
523 # Get translations.
524
525 download_po_files() {
526 subdir=$1
527 domain=$2
528 echo "$0: getting translations into $subdir for $domain..."
529 cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
530 eval "$cmd"
531 }
532
533 # Mirror .po files to $po_dir/.reference and copy only the new
534 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
535 # Note po files that exist locally only are left in $po_dir but will
536 # not be included in LINGUAS and hence will not be distributed.
537 update_po_files() {
538 # Directory containing primary .po files.
539 # Overwrite them only when we're sure a .po file is new.
540 po_dir=$1
541 domain=$2
542
543 # Mirror *.po files into this dir.
544 # Usually contains *.s1 checksum files.
545 ref_po_dir="$po_dir/.reference"
546
547 test -d $ref_po_dir || mkdir $ref_po_dir || return
548 download_po_files $ref_po_dir $domain \
549 && ls "$ref_po_dir"/*.po 2>/dev/null |
550 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
551
552 langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
553 test "$langs" = '*' && langs=x
554 for po in $langs; do
555 case $po in x) continue;; esac
556 new_po="$ref_po_dir/$po.po"
557 cksum_file="$ref_po_dir/$po.s1"
558 if ! test -f "$cksum_file" ||
559 ! test -f "$po_dir/$po.po" ||
560 ! $SHA1SUM -c --status "$cksum_file" \
561 < "$new_po" > /dev/null; then
562 echo "updated $po_dir/$po.po..."
563 cp "$new_po" "$po_dir/$po.po" \
564 && $SHA1SUM < "$new_po" > "$cksum_file"
565 fi
566 done
567 }
568
569 case $SKIP_PO in
570 '')
571 if test -d po; then
572 update_po_files po $package || exit
573 fi
574
575 if test -d runtime-po; then
576 update_po_files runtime-po $package-runtime || exit
577 fi;;
578 esac
579
580 symlink_to_dir()
581 {
582 src=$1/$2
583 dst=${3-$2}
584
585 test -f "$src" && {
586
587 # If the destination directory doesn't exist, create it.
588 # This is required at least for "lib/uniwidth/cjk.h".
589 dst_dir=`dirname "$dst"`
590 if ! test -d "$dst_dir"; then
591 mkdir -p "$dst_dir"
592
593 # If we've just created a directory like lib/uniwidth,
594 # tell version control system(s) it's ignorable.
595 # FIXME: for now, this does only one level
596 parent=`dirname "$dst_dir"`
597 for dot_ig in x $vc_ignore; do
598 test $dot_ig = x && continue
599 ig=$parent/$dot_ig
600 insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
601 done
602 fi
603
604 if $copy; then
605 {
606 test ! -h "$dst" || {
607 echo "$0: rm -f $dst" &&
608 rm -f "$dst"
609 }
610 } &&
611 test -f "$dst" &&
612 cmp -s "$src" "$dst" || {
613 echo "$0: cp -fp $src $dst" &&
614 cp -fp "$src" "$dst"
615 }
616 else
617 test -h "$dst" &&
618 src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
619 dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
620 test "$src_i" = "$dst_i" || {
621 dot_dots=
622 case $src in
623 /*) ;;
624 *)
625 case /$dst/ in
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
634
635 echo "$0: ln -fs $dot_dots$src $dst" &&
636 ln -fs "$dot_dots$src" "$dst"
637 }
638 fi
639 }
640 }
641
642 cp_mark_as_generated()
643 {
644 cp_src=$1
645 cp_dst=$2
646
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
658
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"
663
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"
673 }
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" &&
678 (
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"
688 fi
689 fi
690 fi
691 }
692
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
706 fi
707 test $found = yes
708 }
709
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
733 }
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], [])
747 $a\
748 AC_DEFUN([gl_LOCK_EARLY], [])
749 ' $1/$dir/$file >$dir/$file
750 else
751 cp_mark_as_generated $1/$dir/$file $dir/$file
752 fi
753 fi || exit
754 done
755
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/
771 '
772 `
773 insert_sorted_if_absent $ig "$f"
774
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"
779 fi
780 done
781 done
782 }
783
784
785 # Create boot temporary directories to import from gnulib and gettext.
786 rm -fr $bt $bt2 &&
787 mkdir $bt $bt2 || exit
788
789 # Import from gnulib.
790
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\
802 "
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
808 fi
809 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
810 $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
811 slurp $bt || exit
812
813 for file in $gnulib_files; do
814 symlink_to_dir "$GNULIB_SRCDIR" $file || exit
815 done
816
817
818 # Import from gettext.
819 with_gettext=yes
820 grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
821 with_gettext=no
822
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
828 fi
829 rm -fr $bt $bt2 || exit
830
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
842
843 # Reconfigure, getting other files.
844
845 # copy_files srcdir dstdir
846 copy_files() {
847 for file in `cat $1/DISTFILES`
848 do
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
858 fi
859 symlink_to_dir "$1" "$file" "$2/$dst" || exit
860 # FIXME ignorefile $2 $dst
861 done
862 }
863
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
874
875 if [ -d rmt ]; then
876 :
877 else
878 mkdir rmt
879 fi
880
881 for dir in doc rmt lib tests
882 do
883 copy_files ${PAXUTILS_SRCDIR}/$dir $dir
884 done
885
886 copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
887
888
889
890 # Skip autoheader if it's not needed.
891 grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null ||
892 AUTOHEADER=true
893
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"
900 do
901 if test "$command" = libtool; then
902 test $use_libtool = 0 \
903 && continue
904 command="${LIBTOOLIZE-libtoolize} -c -f"
905 fi
906 echo "$0: $command ..."
907 $command || exit
908 done
909
910
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
920
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/$/ \\/
931 a\
932 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
933 }
934 ' po/Makevars.template >po/Makevars || exit 1
935
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/$/ \\/
945 a\
946 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
947 }
948 ' po/Makevars.template >runtime-po/Makevars || exit 1
949
950 # Copy identical files from po to runtime-po.
951 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
952 fi
953 fi
954
955 bootstrap_epilogue
956
957 echo "$0: done. Now you can run './configure'."
958
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:
This page took 0.074156 seconds and 5 git commands to generate.