]> git.ipfire.org Git - thirdparty/tar.git/blame - bootstrap
Update
[thirdparty/tar.git] / bootstrap
CommitLineData
88ffc135
PE
1#! /bin/sh
2
94de7c4c 3# Bootstrap this package from CVS.
88ffc135 4
c17a9f91 5# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
88ffc135
PE
6
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2, or (at your option)
10# any later version.
11
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
120e96c4
PE
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20# 02110-1301, USA.
88ffc135 21
7347b4f5 22# Written by Paul Eggert and Sergey Poznyakoff.
88ffc135 23
c930802f
PE
24nl='
25'
94de7c4c
PE
26
27# Ensure file names are sorted consistently across platforms.
28# Also, ensure diagnostics are in English, e.g., "wget --help" below.
e24d4efe
PE
29LC_ALL=C
30export LC_ALL
31
9771467d 32usage() {
c930802f
PE
33 echo >&2 "\
34Usage: $0 [OPTION]...
35Bootstrap this package from the checked-out sources.
36
37Options:
38 --paxutils-srcdir=DIRNAME Specify the local directory where paxutils
39 sources reside. Use this if you already
40 have paxutils sources on your machine, and
41 do not want to waste your bandwidth dowloading
42 them again.
43 --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
44 sources reside. Use this if you already
45 have gnulib sources on your machine, and
46 do not want to waste your bandwidth dowloading
47 them again.
48 --copy Copy files instead of creating symbolic links.
49 --force Attempt to bootstrap even if the sources seem
50 not to have been checked out.
51 --skip-po Do not download po files.
27094c4f 52 --update-po[=LANG] Update po file(s) and exit.
c930802f
PE
53 --cvs-user=USERNAME Set the CVS username to be used when accessing
54 the gnulib repository.
55
27094c4f 56If the file bootstrap.conf exists in the current working directory, its
c930802f
PE
57contents are read as shell variables to configure the bootstrap.
58
27094c4f
SP
59Local defaults can be provided by placing the file \`.bootstrap' in the
60current working directory. The file is read after bootstrap.conf, comments
61and empty lines are removed, shell variables expanded and the result is
62prepended to the command line options.
63
c930802f
PE
64Running without arguments will suffice in most cases.
65"
9771467d 66}
88ffc135 67
c930802f
PE
68checkout() {
69 if [ ! -d $1 ]; then
70 echo "$0: getting $1 files..."
71
72 case ${CVS_AUTH-pserver} in
73 pserver)
74 CVS_PREFIX=':pserver:anonymous@';;
75 ssh)
76 CVS_PREFIX="$CVS_USER${CVS_USER+@}";;
77 *)
78 echo "$0: $CVS_AUTH: Unknown CVS access method" >&2
79 exit 1;;
80 esac
81
82 case $CVS_RSH in
83 '') CVS_RSH=ssh; export CVS_RSH;;
84 esac
85
86 trap "cleanup $1" 1 2 13 15
87
88 cvs -z3 -q -d ${CVS_PREFIX}cvs.savannah.gnu.org:/cvsroot/"$1" co $1 ||
89 cleanup $1
90
91 trap - 1 2 13 15
92 fi
93}
94
95cleanup() {
96 status=$?
97 rm -fr $1
98 exit $status
99}
100
101# Configuration.
102
103# List of gnulib modules needed.
104gnulib_modules=
105
106# Any gnulib files needed that are not in modules.
107gnulib_files=
108
109# Translation Project URL, for the registry of all projects
110# and for the translation-team master directory.
111TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain='
112TP_PO_URL='http://www.iro.umontreal.ca/translation/teams/PO/'
113
114extract_package_name='
115 /^AC_INIT(/{
116 /.*,.*,.*,/{
117 s///
118 s/[][]//g
119 p
120 q
121 }
122 s/AC_INIT(\[*//
123 s/]*,.*//
124 s/^GNU //
125 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
126 s/[^A-Za-z0-9_]/-/g
127 p
128 }
129'
130package=`sed -n "$extract_package_name" configure.ac` || exit
131
132# Extra files from gnulib, which override files from other sources.
133gnulib_extra_files='
134 build-aux/announce-gen
135 build-aux/install-sh
136 build-aux/missing
137 build-aux/mdate-sh
138 build-aux/texinfo.tex
139 build-aux/depcomp
140 build-aux/config.guess
141 build-aux/config.sub
142 doc/INSTALL
143'
144
145# Other locale categories that need message catalogs.
146EXTRA_LOCALE_CATEGORIES=
147
148# Additional xgettext options to use. Use "\\\newline" to break lines.
149XGETTEXT_OPTIONS='\\\
150 --flag=_:1:pass-c-format\\\
151 --flag=N_:1:pass-c-format\\\
152 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
153'
154
155# Files we don't want to import.
156excluded_files=
157
158# File that should exist in the top directory of a checked out hierarchy,
159# but not in a distribution tarball.
160CVS_only_file=README-cvs
161
162# Whether to use copies instead of symlinks.
163copy=false
164
165# Override the default configuration, if necessary.
166test -r bootstrap.conf && . ./bootstrap.conf
167
27094c4f
SP
168# Read local configuration file
169if [ -r .bootstrap ]; then
170 echo "$0: Reading configuration file .bootstrap"
171 eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
172fi
173
c930802f 174# Translate configuration into internal form.
64aea5de 175
88ffc135
PE
176# Parse options.
177
54e32211
PE
178for option
179do
88ffc135
PE
180 case $option in
181 --help)
9771467d 182 usage
88ffc135 183 exit;;
7347b4f5
SP
184 --paxutils-srcdir=*)
185 PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
c930802f
PE
186 --gnulib-srcdir=*)
187 GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
a0c65636 188 --cvs-user=*)
0ad27d19 189 CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
c930802f 190 --skip-po | --no-po) # --no-po is for compatibility with 'tar' tradition.
27094c4f
SP
191 DOWNLOAD_PO=skip;;
192 --update-po=*)
193 DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
194 --update-po)
195 DOWNLOAD_PO=only;;
c930802f
PE
196 --force)
197 CVS_only_file=;;
198 --copy)
199 copy=true;;
88ffc135
PE
200 *)
201 echo >&2 "$0: $option: unknown option"
202 exit 1;;
203 esac
204done
205
c930802f
PE
206if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then
207 echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
208 exit 1
209fi
94de7c4c
PE
210
211echo "$0: Bootstrapping CVS $package..."
659f70a3 212
27094c4f
SP
213# Get translations.
214
215get_translations() {
216 subdir=$1
217 domain=$2
218 po_file=$3
219
220 case $WGET_COMMAND in
221 '')
222 echo "$0: wget not available; skipping translations";;
223 ?*)
224 echo "$0: getting ${po_file:-translations} into $subdir for $domain..." &&
225 case $po_file in
226 '') (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`);;
227 esac &&
228
229 $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
230
231 sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" |
232 sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
233 awk -F. '
234 { if (lang && $1 != lang) print lang, ver }
235 { lang = $1; ver = substr($0, index($0, ".") + 1) }
236 END { if (lang) print lang, ver }
237 ' | awk -v domain="$domain" -v po_file="$po_file" -v subdir="$subdir" '
238 {
239 lang = $1
240 if (po_file && po_file != (lang ".po")) next
241
242 ver = $2
243 urlfmt = ""
244 printf "{ $WGET_COMMAND -O %s/%s.po '\'"$TP_PO_URL"'/%s/%s-%s.%s.po'\'' &&\n", subdir, lang, lang, domain, ver, lang
245 printf " msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang
246 printf " echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang
247 printf " rm -f %s/%s.po; }; } &&\n", subdir, lang
248 }
249 END { print ":" }
250 ' | WGET_COMMAND="$WGET_COMMAND" sh;;
251 esac &&
252 ls "$subdir"/*.po 2>/dev/null |
253 sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
254 rm -f "$subdir/$domain.html"
255}
256
257case `wget --help` in
258*'--no-cache'*)
259 WGET_COMMAND='wget -nv --no-cache';;
260*'--cache=on/off'*)
261 WGET_COMMAND='wget -nv --cache=off';;
262*'--non-verbose'*)
263 WGET_COMMAND='wget -nv';;
264*)
265 WGET_COMMAND='';;
266esac
267
268case $DOWNLOAD_PO in
269'skip')
270 ;;
271'')
272 get_translations po $package || exit
273 ;;
274'only')
275 get_translations po $package
276 exit
277 ;;
278*.po)
279 get_translations po $package "$DOWNLOAD_PO"
280 exit
281 ;;
282*)
283 get_translations po $package "${DOWNLOAD_PO}.po"
284 exit
285esac
286
c930802f 287# Get paxutils files.
4d8ddc72 288
4d8ddc72
SP
289case ${PAXUTILS_SRCDIR--} in
290-) checkout paxutils
291 PAXUTILS_SRCDIR=paxutils
292esac
293
294if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
c930802f
PE
295 gnulib_modules=`
296 (echo "$gnulib_modules"; grep '^[^#]' $PAXUTILS_SRCDIR/gnulib.modules) |
297 sort -u
298 `
4d8ddc72
SP
299fi
300
301# copy_files srcdir dstdir
302copy_files() {
303 for file in `cat $1/DISTFILES`
304 do
305 case $file in
306 "#*") continue;;
307 esac
8f1f0955
SP
308 dst=`echo $file | sed 's^.*/^^'`
309 if [ $# -eq 3 ]; then
c17a9f91 310 case $dst in
8f1f0955
SP
311 ${3}*) ;;
312 *) dst=${3}$dst;;
313 esac
c17a9f91 314 fi
8f1f0955
SP
315 echo "$0: Copying file $1/$file to $2/$dst"
316 cp -p $1/$file $2/$dst
4d8ddc72
SP
317 done
318}
319
320copy_files ${PAXUTILS_SRCDIR}/m4 m4
321echo "$0: Creating m4/paxutils.m4"
322(echo "# This file is generated automatically. Please, do not edit."
323 echo "#"
82b2829e 324 echo "AC_DEFUN([${package}_PAXUTILS],["
4d8ddc72
SP
325 cat ${PAXUTILS_SRCDIR}/m4/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
326 echo "])") > ./m4/paxutils.m4
327
328if [ -d rmt ]; then
329 :
330else
331 mkdir rmt
332fi
333
cfe4eef5
SP
334for dir in doc rmt lib tests
335do
336 copy_files ${PAXUTILS_SRCDIR}/$dir $dir
337done
4d8ddc72 338
8f1f0955
SP
339copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
340
7347b4f5
SP
341# Get gnulib files.
342
343case ${GNULIB_SRCDIR--} in
c930802f
PE
344-)
345 checkout gnulib
346 GNULIB_SRCDIR=gnulib
88ffc135
PE
347esac
348
94de7c4c
PE
349gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
350<$gnulib_tool || exit
88ffc135 351
c930802f
PE
352symlink_to_gnulib()
353{
354 src=$GNULIB_SRCDIR/$1
355 dst=${2-$1}
356
357 test -f "$src" && {
358 if $copy; then
359 {
360 test ! -h "$dst" || {
361 echo "$0: rm -f $dst" &&
362 rm -f "$dst"
363 }
364 } &&
365 test -f "$dst" &&
366 cmp -s "$src" "$dst" || {
367 echo "$0: cp -fp $src $dst" &&
368 cp -fp "$src" "$dst"
369 }
370 else
371 test -h "$dst" &&
372 src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
373 dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
374 test "$src_i" = "$dst_i" || {
375 dot_dots=
376 case $src in
377 /*) ;;
378 *)
379 case /$dst/ in
380 *//* | */../* | */./* | /*/*/*/*/*/)
381 echo >&2 "$0: invalid symlink calculation: $src -> $dst"
382 exit 1;;
383 /*/*/*/*/) dot_dots=../../../;;
384 /*/*/*/) dot_dots=../../;;
385 /*/*/) dot_dots=../;;
386 esac;;
387 esac
388
389 echo "$0: ln -fs $dot_dots$src $dst" &&
390 ln -fs "$dot_dots$src" "$dst"
391 }
392 fi
393 }
394}
88ffc135 395
c930802f
PE
396cp_mark_as_generated()
397{
398 cp_src=$1
399 cp_dst=$2
88ffc135 400
c930802f
PE
401 if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
402 symlink_to_gnulib "$cp_dst"
403 else
404 case $cp_dst in
405 *.[ch]) c1='/* '; c2=' */';;
406 *.texi) c1='@c '; c2= ;;
407 *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
408 *) c1= ; c2= ;;
409 esac
88ffc135 410
c930802f
PE
411 if test -z "$c1"; then
412 cmp -s "$cp_src" "$cp_dst" || {
413 echo "$0: cp -f $cp_src $cp_dst" &&
414 cp -f "$cp_src" "$cp_dst"
415 }
416 else
417 # Copy the file first to get proper permissions if it
418 # doesn't already exist. Then overwrite the copy.
419 cp "$cp_src" "$cp_dst-t" &&
420 (
421 echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
422 echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
423 cat "$cp_src"
424 ) > $cp_dst-t &&
425 if cmp -s "$cp_dst-t" "$cp_dst"; then
426 rm -f "$cp_dst-t"
427 else
428 echo "$0: cp $cp_src $cp_dst # with edits" &&
429 mv -f "$cp_dst-t" "$cp_dst"
430 fi
431 fi
432 fi
433}
94de7c4c 434
c930802f
PE
435version_controlled_file() {
436 dir=$1
437 file=$2
438 found=no
439 if test -d CVS; then
440 grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
441 grep '^/[^/]*/[0-9]' > /dev/null && found=yes
442 elif test -d .git; then
443 git-rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
444 else
445 echo "$0: no version control for $dir/$file?" >&2
446 fi
447 test $found = yes
448}
94de7c4c 449
c930802f
PE
450slurp() {
451 for dir in . `(cd $1 && find * -type d -print)`; do
452 copied=
453 sep=
454 for file in `ls $1/$dir`; do
455 test -d $1/$dir/$file && continue
456 for excluded_file in $excluded_files; do
457 test "$dir/$file" = "$excluded_file" && continue 2
458 done
459 if test $file = Makefile.am; then
460 copied=$copied${sep}gnulib.mk; sep=$nl
461 remove_intl='/^[^#].*\/intl/s/^/#/'
462 sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/gnulib.mk || {
463 echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
464 rm -f $dir/gnulib.mk &&
465 sed "$remove_intl" $1/$dir/$file >$dir/gnulib.mk
466 }
467 elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
468 version_controlled_file $dir $file; then
469 echo "$0: $dir/$file overrides $1/$dir/$file"
470 else
471 copied=$copied$sep$file; sep=$nl
472 if test $file = gettext.m4; then
473 echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
474 rm -f $dir/$file
475 sed '
476 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
477 AC_DEFUN([AM_INTL_SUBDIR], [
478 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
479 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
480 $a\
481 AC_DEFUN([gl_LOCK_EARLY], [])
482 ' $1/$dir/$file >$dir/$file
483 else
484 cp_mark_as_generated $1/$dir/$file $dir/$file
485 fi
486 fi || exit
487 done
488
b09417ca
SP
489 if test -n "$copied"; then
490 copied="Makefile
491Makefile.in
492$copied"
493 if test -d CVS; then
494 dot_ig=.cvsignore
495 else
496 dor_ig=.gitignore
c930802f 497 fi
b09417ca
SP
498
499 ig=$dir/$dot_ig
500 if test -f $ig; then
501 echo "$copied" | sort -u - $ig | cmp -s - $ig ||
502 echo "$copied" | sort -u - $ig -o $ig
503 else
504 copied="$dot_ig
505$copied"
506 if [ "$dir" = "po" ]; then
507 copied="LINGUAS
508Makevars
509POTFILES
510*.mo
511*.gmo
512*.po
513remove-potcdate.sed
514stamp-po
515$package.pot
516$copied"
517 fi
518 echo "$copied" | sort -u -o $ig
519 fi || exit
520 fi
c930802f
PE
521 done
522}
c8c35168 523
c930802f
PE
524
525# Create boot temporary directories to import from gnulib and gettext.
526
527bt='.#bootmp'
528bt2=${bt}2
529rm -fr $bt $bt2 &&
530mkdir $bt $bt2 || exit
531
532# Import from gnulib.
533
534test -d build-aux || {
535 echo "$0: mkdir build-aux ..." &&
536 mkdir build-aux
537} || exit
538gnulib_tool_options="\
539 --import\
540 --no-changelog\
541 --aux-dir $bt/build-aux\
542 --doc-base $bt/doc\
543 --lib lib$package\
544 --m4-base $bt/m4/\
545 --source-base $bt/lib/\
546 --tests-base $bt/tests\
547 --local-dir gl\
548"
549echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
550$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
551slurp $bt || exit
552
553for file in $gnulib_files; do
554 symlink_to_gnulib $file || exit
94de7c4c
PE
555done
556
c930802f
PE
557
558# Import from gettext.
559
560echo "$0: (cd $bt2; autopoint) ..."
561cp configure.ac $bt2 &&
562(cd $bt2 && autopoint && rm configure.ac) &&
563slurp $bt2 $bt || exit
564
565rm -fr $bt $bt2 || exit
566
567
568# Reconfigure, getting other files.
94de7c4c
PE
569
570for command in \
571 'aclocal --force -I m4' \
572 'autoconf --force' \
573 'autoheader --force' \
574 'automake --add-missing --copy --force-missing';
575do
576 echo "$0: $command ..."
577 $command || exit
578done
579
580
c930802f
PE
581# Get some extra files from gnulib, overriding existing files.
582
583for file in $gnulib_extra_files; do
584 case $file in
585 */INSTALL) dst=INSTALL;;
586 *) dst=$file;;
587 esac
588 symlink_to_gnulib $file $dst || exit
589done
590
591
01b6fb98
PE
592# Create gettext configuration.
593echo "$0: Creating po/Makevars from po/Makevars.template ..."
c930802f 594rm -f po/Makevars
01b6fb98 595sed '
c930802f 596 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
01b6fb98
PE
597 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
598 /^XGETTEXT_OPTIONS *=/{
599 s/$/ \\/
600 a\
c930802f 601 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
01b6fb98
PE
602 }
603' po/Makevars.template >po/Makevars
88ffc135 604
c930802f
PE
605if test -d runtime-po; then
606 # Similarly for runtime-po/Makevars, but not quite the same.
607 rm -f runtime-po/Makevars
608 sed '
609 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
610 /^subdir *=.*/s/=.*/= runtime-po/
611 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
612 /^XGETTEXT_OPTIONS *=/{
613 s/$/ \\/
614 a\
615 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
616 }
617 ' <po/Makevars.template >runtime-po/Makevars
618
619 # Copy identical files from po to runtime-po.
620 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
621fi
88ffc135
PE
622
623echo "$0: done. Now you can run './configure'."