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 2, 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.
27 # Ensure file names are sorted consistently across platforms.
28 # Also, ensure diagnostics are in English, e.g., "wget --help" below.
32 # Temporary directory names.
34 bt_regex
=`echo "$bt"| sed 's/\./[.]/g'`
40 Bootstrap this package from the checked-out sources.
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 downloading
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.
55 If the file .bootstrap.conf exists in the current working directory, its
56 contents are read as shell variables to configure the bootstrap.
58 Running without arguments will suffice in most cases.
64 # List of gnulib modules needed.
67 # Any gnulib files needed that are not in modules.
70 # Translation Project URL, for the registry of all projects
71 # and for the translation-team master directory.
72 TP_URL
='http://www.iro.umontreal.ca/translation/registry.cgi?domain='
73 TP_PO_URL
='http://www.iro.umontreal.ca/translation/teams/PO/'
75 extract_package_name
='
86 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
91 package
=`sed -n "$extract_package_name" configure.ac` ||
exit
93 # Extra files from gnulib, which override files from other sources.
100 build-aux/config.guess
105 # Other locale categories that need message catalogs.
106 EXTRA_LOCALE_CATEGORIES
=
108 # Additional xgettext options to use. Use "\\\newline" to break lines.
109 XGETTEXT_OPTIONS
='\\\
110 --flag=_:1:pass-c-format\\\
111 --flag=N_:1:pass-c-format\\\
112 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
115 # Files we don't want to import.
118 # File that should exist in the top directory of a checked out hierarchy,
119 # but not in a distribution tarball.
120 CVS_only_file
=README-hacking
122 # Whether to use copies instead of symlinks.
125 # Override the default configuration, if necessary.
126 test -r bootstrap.conf
&& . .
/bootstrap.conf
128 # Translate configuration into internal form.
139 GNULIB_SRCDIR
=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
141 CVS_USER
=`expr "$option" : '--cvs-user=\(.*\)'`;;
149 echo >&2 "$0: $option: unknown option"
154 if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then
155 echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
159 echo "$0: Bootstrapping CVS $package..."
169 case ${GNULIB_SRCDIR--} in
171 if [ ! -d gnulib
]; then
172 echo "$0: getting gnulib files..."
174 case ${CVS_AUTH-pserver} in
176 CVS_PREFIX
=':pserver:anonymous@';;
178 CVS_PREFIX
="$CVS_USER${CVS_USER+@}";;
180 echo "$0: $CVS_AUTH: Unknown CVS access method" >&2
185 '') CVS_RSH
=ssh; export CVS_RSH
;;
188 trap cleanup_gnulib
1 2 13 15
190 cvs
-z3 -q -d ${CVS_PREFIX}cvs.savannah.gnu.org
:/cvsroot
/gnulib co gnulib ||
198 gnulib_tool
=$GNULIB_SRCDIR/gnulib-tool
199 <$gnulib_tool ||
exit
207 case $WGET_COMMAND in
209 echo "$0: wget not available; skipping translations";;
211 echo "$0: getting translations into $subdir for $domain..." &&
213 (cd $subdir && rm -f dummy
`ls | sed -n '/\.gmo$/p; /\.po/p'`) &&
214 $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
216 sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" |
217 sort -k 1,1 -k 2,2n
-k2,2 -k3,3n
-k3,3 -k4,4n
-k4,4 -k5,5n
-k5.5 |
219 { if (lang && $1 != lang) print lang, ver }
220 { lang = $1; ver = substr($0, index($0, ".") + 1) }
221 END { if (lang) print lang, ver }
222 ' |
awk -v domain
="$domain" -v subdir
="$subdir" '
227 printf "{ $WGET_COMMAND -O %s/%s.po '\'"$TP_PO_URL"'/%s/%s-%s.%s.po'\'' &&\n", subdir, lang, lang, domain, ver, lang
228 printf " msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang
229 printf " echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang
230 printf " rm -f %s/%s.po; }; } &&\n", subdir, lang
233 ' | WGET_COMMAND
="$WGET_COMMAND" sh
;;
235 ls "$subdir"/*.po
2>/dev
/null |
236 sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
237 rm -f "$subdir/$domain.html"
242 case `wget --help` in
244 WGET_COMMAND
='wget -nv --no-cache';;
246 WGET_COMMAND
='wget -nv --cache=off';;
248 WGET_COMMAND
='wget -nv';;
254 get_translations po
$package ||
exit
257 if test -d runtime-po
; then
258 get_translations runtime-po
$package-runtime ||
exit
264 src
=$GNULIB_SRCDIR/$1
270 test ! -h "$dst" ||
{
271 echo "$0: rm -f $dst" &&
276 cmp -s "$src" "$dst" ||
{
277 echo "$0: cp -fp $src $dst" &&
282 src_ls
=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i
=$1 &&
283 dst_ls
=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i
=$1 &&
284 test "$src_i" = "$dst_i" ||
{
290 *//* |
*/..
/* |
*/.
/* |
/*/*/*/*/*/)
291 echo >&2 "$0: invalid symlink calculation: $src -> $dst"
293 /*/*/*/*/) dot_dots
=..
/..
/..
/;;
294 /*/*/*/) dot_dots
=..
/..
/;;
295 /*/*/) dot_dots
=..
/;;
299 echo "$0: ln -fs $dot_dots$src $dst" &&
300 ln -fs "$dot_dots$src" "$dst"
306 cp_mark_as_generated
()
311 if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
312 symlink_to_gnulib
"$cp_dst"
315 *.
[ch
]) c1
='/* '; c2
=' */';;
316 *.texi
) c1
='@c '; c2
= ;;
317 *.
m4|
*/Make
*|Make
*) c1
='# ' ; c2
= ;;
321 if test -z "$c1"; then
322 cmp -s "$cp_src" "$cp_dst" ||
{
323 echo "$0: cp -f $cp_src $cp_dst" &&
325 sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst"
328 # Copy the file first to get proper permissions if it
329 # doesn't already exist. Then overwrite the copy.
330 cp "$cp_src" "$cp_dst-t" &&
332 echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
333 echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
334 sed "s!$bt_regex/!!g" "$cp_src"
336 if cmp -s "$cp_dst-t" "$cp_dst"; then
339 echo "$0: cp $cp_src $cp_dst # with edits" &&
340 mv -f "$cp_dst-t" "$cp_dst"
346 version_controlled_file
() {
351 grep -F "/$file/" $dir/CVS
/Entries
2>/dev
/null |
352 grep '^/[^/]*/[0-9]' > /dev
/null
&& found
=yes
353 elif test -d .git
; then
354 git-rm
-n "$dir/$file" > /dev
/null
2>&1 && found
=yes
356 echo "$0: no version control for $dir/$file?" >&2
361 # If $STR is not already on a line by itself in $FILE, insert it,
362 # sorting the new contents of the file and replacing $FILE with the result.
363 insert_sorted_if_absent
() {
366 echo "$str" |
sort -u - $file |
cmp -s - $file \
367 ||
echo "$str" |
sort -u - $file -o $file \
372 for dir
in .
`(cd $1 && find * -type d -print)`; do
375 for file in `ls $1/$dir`; do
376 test -d $1/$dir/$file && continue
377 for excluded_file
in $excluded_files; do
378 test "$dir/$file" = "$excluded_file" && continue 2
380 if test $file = Makefile.am
; then
381 copied
=$copied${sep}gnulib.mk
; sep
=$nl
382 remove_intl
='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
383 sed "$remove_intl" $1/$dir/$file |
cmp -s - $dir/gnulib.mk ||
{
384 echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
385 rm -f $dir/gnulib.mk
&&
386 sed "$remove_intl" $1/$dir/$file >$dir/gnulib.mk
388 elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
389 version_controlled_file
$dir $file; then
390 echo "$0: $dir/$file overrides $1/$dir/$file"
392 copied
=$copied$sep$file; sep
=$nl
393 if test $file = gettext.
m4; then
394 echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
397 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
398 AC_DEFUN([AM_INTL_SUBDIR], [
399 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
400 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
402 AC_DEFUN([gl_LOCK_EARLY], [])
403 ' $1/$dir/$file >$dir/$file
405 cp_mark_as_generated
$1/$dir/$file $dir/$file
410 for dot_ig
in .cvsignore .gitignore
; do
412 if test -n "$copied" && test -f $ig; then
413 insert_sorted_if_absent
$ig "$copied"
414 # If an ignored file name ends with _.h, then also add
415 # the name with just ".h". Many gnulib headers are generated,
416 # e.g., stdint_.h -> stdint.h, dirent_.h ->..., etc.
417 f
=`echo "$copied"|sed 's/_\.h$/.h/'`
418 insert_sorted_if_absent
$ig "$f"
425 # Create boot temporary directories to import from gnulib and gettext.
427 mkdir
$bt $bt2 ||
exit
429 # Import from gnulib.
431 gnulib_tool_options
="\
434 --aux-dir $bt/build-aux\
438 --source-base $bt/lib/\
439 --tests-base $bt/tests\
442 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
443 $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
446 for file in $gnulib_files; do
447 symlink_to_gnulib
$file ||
exit
451 # Import from gettext.
453 echo "$0: (cd $bt2; autopoint) ..."
454 cp configure.ac
$bt2 &&
455 (cd $bt2 && autopoint
&& rm configure.ac
) &&
456 slurp
$bt2 $bt ||
exit
458 rm -fr $bt $bt2 ||
exit
461 # Reconfigure, getting other files.
464 'aclocal --force -I m4' \
466 'autoheader --force' \
467 'automake --add-missing --copy --force-missing';
469 echo "$0: $command ..."
474 # Get some extra files from gnulib, overriding existing files.
476 for file in $gnulib_extra_files; do
478 */INSTALL
) dst
=INSTALL
;;
481 symlink_to_gnulib
$file $dst ||
exit
485 # Create gettext configuration.
486 echo "$0: Creating po/Makevars from po/Makevars.template ..."
489 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
490 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
491 /^XGETTEXT_OPTIONS *=/{
494 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
496 ' po
/Makevars.template
>po
/Makevars
498 if test -d runtime-po
; then
499 # Similarly for runtime-po/Makevars, but not quite the same.
500 rm -f runtime-po
/Makevars
502 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
503 /^subdir *=.*/s/=.*/= runtime-po/
504 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
505 /^XGETTEXT_OPTIONS *=/{
508 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
510 ' <po
/Makevars.template
>runtime-po
/Makevars
512 # Copy identical files from po to runtime-po.
513 (cd po
&& cp -p Makefile.
in.
in *-quot *.header
*.
sed *.sin ..
/runtime-po
)
516 echo "$0: done. Now you can run './configure'."