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