3 # Bootstrap this package from CVS.
5 # Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
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 3, or (at your option)
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.
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
22 # Written by Paul Eggert and Sergey Poznyakoff.
27 # Ensure file names are sorted consistently across platforms.
28 # Also, ensure diagnostics are in English, e.g., "wget --help" below.
35 Bootstrap this package from the checked-out sources.
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
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
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 --update-po Update po files and exit.
53 --cvs-user=USERNAME Set the CVS username to be used when accessing
54 the paxutils repository.
56 If the file bootstrap.conf exists in the current working directory, its
57 contents are read as shell variables to configure the bootstrap.
59 Local defaults can be provided by placing the file \`.bootstrap' in the
60 current working directory. The file is read after bootstrap.conf, comments
61 and empty lines are removed, shell variables expanded and the result is
62 prepended to the command line options.
64 Running without arguments will suffice in most cases.
70 echo "$0: getting $1 files..."
74 case ${CVS_AUTH-pserver} in
76 CVS_PREFIX
=':pserver:anonymous@';;
78 CVS_PREFIX
="$CVS_USER${CVS_USER+@}";;
80 echo "$0: $CVS_AUTH: Unknown CVS access method" >&2
85 '') CVS_RSH
=ssh; export CVS_RSH
;;
88 CVSURL
=${CVS_PREFIX}cvs.savannah.gnu.org
:/cvsroot
/"$1"
92 CVSURL
=:pserver
:anonymous@pserver.git.sv.gnu.org
:/gnulib.git
97 trap "cleanup $1" 1 2 13 15
99 cvs
-z3 -q -d $CVSURL co
$1 || cleanup
$1
113 # List of gnulib modules needed.
116 # Any gnulib files needed that are not in modules.
119 # The command to download all .po files for a specified domain into
120 # a specified directory. Fill in the first %s is the domain name, and
121 # the second with the destination directory. Use rsync's -L and -r
122 # options because the latest/%s directory and the .po files within are
124 po_download_command_format
=\
125 "rsync -Lrtvz 'translationproject.org::tp/latest/%s/' '%s'"
127 extract_package_name
='
138 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
143 package
=`sed -n "$extract_package_name" configure.ac` || exit
145 # Extra files from gnulib, which override files from other sources.
147 build-aux/announce-gen
151 build-aux/texinfo.tex
153 build-aux/config.guess
158 # Other locale categories that need message catalogs.
159 EXTRA_LOCALE_CATEGORIES
=
161 # Additional xgettext options to use. Use "\\\newline" to break lines.
162 XGETTEXT_OPTIONS
='\\\
163 --flag=_:1:pass-c-format\\\
164 --flag=N_:1:pass-c-format\\\
165 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
168 # Files we don't want to import.
171 # File that should exist in the top directory of a checked out hierarchy,
172 # but not in a distribution tarball.
173 CVS_only_file
=README
-cvs
175 # Whether to use copies instead of symlinks.
178 # Override the default configuration, if necessary.
179 test -r bootstrap.conf
&& . .
/bootstrap.conf
181 # Read local configuration file
182 if [ -r .bootstrap
]; then
183 echo "$0: Reading configuration file .bootstrap"
184 eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
187 # Translate configuration into internal form.
198 PAXUTILS_SRCDIR
=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
200 GNULIB_SRCDIR
=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
202 CVS_USER
=`expr "$option" : '--cvs-user=\(.*\)'`;;
203 --skip-po | --no-po) # --no-po is for compatibility with 'tar' tradition.
206 DOWNLOAD_PO
=`expr "$option" : '--update-po=\(.*\)'`;;
214 echo >&2 "$0: $option: unknown option"
219 if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then
220 echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
224 echo "$0: Bootstrapping CVS $package..."
228 download_po_files
() {
231 echo "$0: getting translations into $subdir for $domain..."
232 cmd
=`printf "$po_download_command_format" "$domain" "$subdir"`
236 # Download .po files to $po_dir/.reference and copy only the new
237 # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
239 # Directory containing primary .po files.
240 # Overwrite them only when we're sure a .po file is new.
244 # Download *.po files into this dir.
245 # Usually contains *.s1 checksum files.
246 ref_po_dir
="$po_dir/.reference"
248 test -d $ref_po_dir || mkdir $ref_po_dir || return
249 download_po_files
$ref_po_dir $domain \
250 && ls "$ref_po_dir"/*.po
2>/dev
/null
|
251 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
253 langs
=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
254 test "$langs" = '*' && langs
=x
255 for po
in `cd $ref_po_dir && echo *.po|sed 's/\.po//g'`; do
256 case $po in x
) continue;; esac
257 new_po
="$ref_po_dir/$po.po"
258 cksum_file
="$ref_po_dir/$po.s1"
259 if ! test -f "$cksum_file" ||
260 ! test -f "$po_dir/$po.po" ||
261 ! sha1sum -c --status "$cksum_file" < "$new_po" > /dev
/null
; then
262 echo "updated $po_dir/$po.po..."
263 cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file"
273 update_po_files po
$package || exit
278 update_po_files po
$package || exit
284 # Get paxutils files.
286 case ${PAXUTILS_SRCDIR--} in
288 PAXUTILS_SRCDIR
=paxutils
291 if [ -r $PAXUTILS_SRCDIR/gnulib.modules
]; then
293 (echo "$gnulib_modules"; grep '^[^#]' $PAXUTILS_SRCDIR/gnulib.modules) |
300 test -n "$ignore_file_list" && rm -f $ignore_file_list
303 trap 'cleanup_ifl' 1 2 3 15
305 # ignorefile DIR FILE
306 # add FILE to the temporary ignorelist in the directory DIR
310 if `echo $ignore_list | grep -qv $file`; then
311 ignore_file_list
="$ignore_file_list
316 # copy_files srcdir dstdir
318 for file in `cat $1/DISTFILES`
323 dst
=`echo $file | sed 's^.*/^^'`
324 if [ $# -eq 3 ]; then
330 echo "$0: Copying file $1/$file to $2/$dst"
331 cp -p $1/$file $2/$dst
338 case ${GNULIB_SRCDIR--} in
344 gnulib_tool
=$GNULIB_SRCDIR/gnulib
-tool
345 <$gnulib_tool || exit
350 test -d "$d" || mkdir -p -- "$d"
355 src
=$GNULIB_SRCDIR/$1
361 test ! -h "$dst" || {
362 echo "$0: rm -f $dst" &&
367 cmp -s "$src" "$dst" || {
368 echo "$0: cp -fp $src $dst" &&
369 ensure_dir_exists
$dst &&
374 src_ls
=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i
=$1 &&
375 dst_ls
=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i
=$1 &&
376 test "$src_i" = "$dst_i" || {
382 *//* | */..
/* | */.
/* | /*/*/*/*/*/)
383 echo >&2 "$0: invalid symlink calculation: $src -> $dst"
385 /*/*/*/*/) dot_dots
=..
/..
/..
/;;
386 /*/*/*/) dot_dots
=..
/..
/;;
387 /*/*/) dot_dots
=..
/;;
391 echo "$0: ln -fs $dot_dots$src $dst" &&
392 ensure_dir_exists
$dst &&
393 ln -fs "$dot_dots$src" "$dst"
399 cp_mark_as_generated
()
404 if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
405 symlink_to_gnulib
"$cp_dst"
408 *.
[ch
]) c1
='/* '; c2
=' */';;
409 *.texi
) c1
='@c '; c2
= ;;
410 *.
m4|*/Make
*|Make
*) c1
='# ' ; c2
= ;;
414 if test -z "$c1"; then
415 cmp -s "$cp_src" "$cp_dst" || {
416 echo "$0: cp -f $cp_src $cp_dst" &&
417 cp -f "$cp_src" "$cp_dst"
420 # Copy the file first to get proper permissions if it
421 # doesn't already exist. Then overwrite the copy.
422 cp "$cp_src" "$cp_dst-t" &&
424 echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
425 echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
428 if cmp -s "$cp_dst-t" "$cp_dst"; then
431 echo "$0: cp $cp_src $cp_dst # with edits" &&
432 mv -f "$cp_dst-t" "$cp_dst"
438 version_controlled_file
() {
443 grep -F "/$file/" $dir/CVS
/Entries
2>/dev
/null
|
444 grep '^/[^/]*/[0-9]' > /dev
/null
&& found
=yes
445 elif test -d .git
; then
446 git
-rm -n "$dir/$file" > /dev
/null
2>&1 && found
=yes
448 echo "$0: no version control for $dir/$file?" >&2
454 for dir
in .
`(cd $1 && find * -type d -print)`; do
457 for file in `ls $1/$dir`; do
458 test -d $1/$dir/$file && continue
459 for excluded_file
in $excluded_files; do
460 test "$dir/$file" = "$excluded_file" && continue 2
462 if test $file = Makefile.am
; then
463 copied
=$copied${sep}gnulib.mk
; sep
=$nl
464 remove_intl
='/^[^#].*\/intl/s/^/#/;'"s,/$bt,,g"
465 sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/gnulib.mk
|| {
466 echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
467 rm -f $dir/gnulib.mk
&&
468 sed "$remove_intl" $1/$dir/$file >$dir/gnulib.mk
470 elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
471 version_controlled_file
$dir $file; then
472 echo "$0: $dir/$file overrides $1/$dir/$file"
474 copied
=$copied$sep$file; sep
=$nl
475 if test $file = gettext.
m4; then
476 echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
479 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
480 AC_DEFUN([AM_INTL_SUBDIR], [
481 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
482 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
484 AC_DEFUN([gl_LOCK_EARLY], [])
485 ' $1/$dir/$file >$dir/$file
487 cp_mark_as_generated
$1/$dir/$file $dir/$file
492 if test -n "$copied"; then
503 if [ -f $dir/.ignore.$$
]; then
504 tfile
=$dir/.ignore.$$
509 echo "$copied" | sort -u - $ig | cmp -s - $ig ||
510 echo "$copied" | sort -u - $ig $tfile -o $ig
514 if [ "$dir" = "po" ]; then
526 echo "$copied" | sort -u - $tfile -o $ig
533 # Create boot temporary directories to import from gnulib and gettext.
538 mkdir $bt $bt2 || exit
540 # Import from gnulib.
542 test -d build
-aux || {
543 echo "$0: mkdir build-aux ..." &&
546 gnulib_tool_options
="\
549 --aux-dir $bt/build-aux\
553 --source-base $bt/lib/\
554 --tests-base $bt/tests\
557 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
558 $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
561 for file in $gnulib_files; do
562 symlink_to_gnulib
$file || exit
566 # Import from gettext.
568 echo "$0: (cd $bt2; autopoint) ..."
569 cp configure.ac
$bt2 &&
570 (cd $bt2 && autopoint
&& rm configure.ac
) &&
571 slurp
$bt2 $bt || exit
573 rm -fr $bt $bt2 || exit
575 # Import from paxutils
576 copy_files
${PAXUTILS_SRCDIR}/m4 m4
577 echo "$0: Creating m4/paxutils.m4"
578 (echo "# This file is generated automatically. Please, do not edit."
580 echo "AC_DEFUN([${package}_PAXUTILS],["
581 cat ${PAXUTILS_SRCDIR}/m
4/DISTFILES
| sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a
-z A
-Z
582 echo "])") > .
/m
4/paxutils.
m4
583 ignorefile
m4 paxutils.
m4
591 for dir
in doc rmt lib tests
593 copy_files
${PAXUTILS_SRCDIR}/$dir $dir
596 copy_files
${PAXUTILS_SRCDIR}/paxlib lib pax
598 # Reconfigure, getting other files.
601 'aclocal --force -I m4' \
603 'autoheader --force' \
604 'automake --add-missing --copy --force-missing';
606 echo "$0: $command ..."
611 # Get some extra files from gnulib, overriding existing files.
613 for file in $gnulib_extra_files; do
615 */INSTALL
) dst
=INSTALL
;;
618 symlink_to_gnulib
$file $dst || exit
622 # Create gettext configuration.
623 echo "$0: Creating po/Makevars from po/Makevars.template ..."
626 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
627 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
628 /^XGETTEXT_OPTIONS *=/{
631 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
633 ' po
/Makevars.template
>po
/Makevars
635 if test -d runtime
-po; then
636 # Similarly for runtime-po/Makevars, but not quite the same.
637 rm -f runtime
-po/Makevars
639 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
640 /^subdir *=.*/s/=.*/= runtime-po/
641 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
642 /^XGETTEXT_OPTIONS *=/{
645 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
647 ' <po
/Makevars.template
>runtime
-po/Makevars
649 # Copy identical files from po to runtime-po.
650 (cd po
&& cp -p Makefile.
in.
in *-quot *.header
*.
sed *.sin ..
/runtime
-po)
653 echo "$0: done. Now you can run './configure'."