3 # bootstrap (GNU M4) version 2007-11-05
4 # Written by Gary V. Vaughan <gary@gnu.org>
6 # Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
8 # This file is part of GNU M4.
10 # GNU M4 is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # GNU M4 is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 # Usage: $progname [options]
25 # -f --force bootstrap even when sources are not from git
26 # -p ARG --download-po=ARG whether to download pofiles [yes]
27 # -v --version print version information
28 # -h,-? --help print short or long help message
30 # For --download-po, ARG can also be `no' to skip pofile downloads,
31 # `only' to just update pofiles, or a set of locales to add or update.
33 # You can also set the following variables to help $progname
34 # locate the right tools:
35 # AUTOPOINT, AUTORECONF, AWK, GNULIB_TOOL, M4, RM, SED, WGET
37 # This script bootstraps a git or CVS checkout of GNU M4 by correctly calling
38 # out to parts of the GNU Build Platform. Currently this requires GNU
39 # Gettext 0.16 or better, Autoconf 2.60 or better, GNU M4 1.4.x or
40 # better, a git snapshot of Automake 1.10a or better, a CVS snapshot
41 # of Libtool 2.1a or better, and the latest git or CVS checkout of Gnulib.
42 # Libtool must be installed; either with the same --prefix as
43 # automake, or made accessible to aclocal's search path via
44 # $AUTOMAKE_prefix/share/aclocal/dirlist.
46 # Report bugs to <bug-m4@gnu.org>
48 : ${AUTOPOINT=autopoint}
49 : ${AUTORECONF=autoreconf}
51 : ${GNULIB_TOOL=gnulib-tool}
60 # Ensure file names are sorted consistently across platforms.
61 # Also, ensure diagnostics are in English, e.g., "wget --help" below.
67 config_aux_dir
=build-aux
68 config_macro_dir
=$ltdldir/m4
71 # List dependencies here too; we don't extract them, otherwise dependent
72 # modules could end up being imported to src/ *and* gnu/!
73 src_modules
='getopt version-etc-fsf version-etc xstrtol'
78 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
79 # is ksh but when the shell is invoked as "sh" and the current value of
80 # the _XPG environment variable is not equal to 1 (one), the special
81 # positional parameter $0, within a function call, is the name of the
85 # The name of this program:
86 progname
=`echo "$progpath" | $SED "$basename"`
89 # Detect whether this is a version control system checkout or a tarball
93 # Echo program name prefixed message.
96 echo $progname: ${1+"$@"}
100 # Echo program name prefixed message to standard error.
103 echo $progname: ${1+"$@"} >&2
106 # func_fatal_error arg...
107 # Echo program name prefixed message to standard error, and exit.
114 # func_verbose arg...
115 # Echo program name prefixed message in verbose mode only.
118 $opt_verbose && func_error
${1+"$@"}
121 # func_missing_arg argname
122 # Echo program name prefixed message to standard error and set global
126 func_error
"missing argument for $1"
130 # func_fatal_help arg...
131 # Echo program name prefixed message to standard error, followed by
132 # a help hint, and exit.
136 func_fatal_error
"Try \`$progname --help' for more information."
139 # func_missing_arg argname
140 # Echo program name prefixed message to standard error and set global
144 func_error
"missing argument for $1"
149 # Echo short help message to standard output and exit.
152 $SED '/^# Usage:/,/# -h/ {
154 s/\$progname/'$progname'/;
158 echo "run \`$progname --help | more' for full usage"
163 # Echo long help message to standard output and exit.
166 $SED '/^# Usage:/,/# Report bugs to/ {
168 s/\$progname/'$progname'/;
175 # Echo version message to standard output and exit.
178 $SED '/^# '$PROGRAM' (GNU /,/# warranty; / {
180 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
187 # Copy $1 to $2 if it is newer.
190 if test -f "$2" && cmp -s "$1" "$2" ; then
191 func_verbose
"$2 is up-to-date"
193 func_echo
"copying $1 -> $2"
198 # Parse options once, thoroughly. This comes as soon as possible in
199 # the script to make things like `bootstrap --version' happen quickly.
202 my_sed_single_opt
='1s/^\(..\).*$/\1/;q'
203 my_sed_single_rest
='1s/^..\(.*\)$/\1/;q'
204 my_sed_long_opt
='1s/^\(--[^=]*\)=.*/\1/;q'
205 my_sed_long_arg
='1s/^--[^=]*=//'
207 # this just eases exit handling
208 while test $# -gt 0; do
213 test $# = 0 && func_missing_arg
$opt && break
215 0|
[Nn
]*|
[Ff
]*) DOWNLOAD_PO
=no
;;
216 [Oo
]*) DOWNLOAD_PO
=only
;;
220 # Separate optargs to long options:
222 arg
=`echo "$opt" | $SED "$my_sed_long_arg"`
223 opt
=`echo "$opt" | $SED "$my_sed_long_opt"`
224 set -- "$opt" "$arg" ${1+"$@"}
227 # Separate optargs to short options:
229 arg
=`echo "$opt" |$SED "$my_sed_single_rest"`
230 opt
=`echo "$opt" |$SED "$my_sed_single_opt"`
231 set -- "$opt" "$arg" ${1+"$@"}
234 -f|
--force) vcs_only_file
= ;;
235 -\?|
-h) func_usage
;;
237 --version) func_version
;;
239 -*) func_fatal_help
"unrecognized option \`$opt'" ;;
240 *) set -- "$opt" ${1+"$@"}; break ;;
244 # Bail if the options were screwed
245 $exit_cmd $EXIT_FAILURE
247 if test -n "$vcs_only_file" && test ! -r "$vcs_only_file"; then
249 "Bootstrapping from a non-version-control distribution is risky."
253 ## ------------------------------ ##
254 ## Fetch translations. ##
255 ## (taken from GNU tar bootstrap) ##
256 ## ------------------------------ ##
258 func_get_translations
()
264 url
=http
://translationproject.org
/domain
/$2.html
265 baseurl
=`expr "$url" : '\(.*\)/.*'`
267 func_echo
"getting translations into $subdir for $domain..."
270 '') (cd $subdir && rm -f dummy
`ls | sed -n '/\.gmo$/p; /\.po/p'`);;
273 $WGET -nv --cache=off
-O "$subdir/$domain.html" "$url" &&
275 sed -n 's|.*href="\(.*\)/\([^/][^/]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\2:\3:\1|p' <"$subdir/$domain.html" |
276 sort -t: -k 1,1 -k 2,2n
-k2,2 -k3,3n
-k3,3 -k4,4n
-k4,4 -k5,5n
-k5.5 |
278 { if (lang && $1 != lang) print lang, ver, subdir }
279 { lang = $1; ver = $2; subdir = $3 }
280 END { if (lang) print lang, ver, subdir }
281 ' |
$AWK -v domain
="$domain" -v po_file
="$po_file" -v baseurl
="$baseurl" -v subdir
="$subdir" '
284 if (po_file == (lang ".po")) next
288 printf "$WGET -nv --cache=off -O %s/%s.po %s/%s/%s/%s-%s.%s.po &&\n", subdir, lang, baseurl, $3, lang, domain, ver, lang
293 ls "$subdir"/*.po |
sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
294 rm "$subdir/$domain.html"
297 ## ------------------------------ ##
298 ## Update translations. ##
299 ## (taken from GNU tar bootstrap) ##
300 ## ------------------------------ ##
309 func_get_translations .
/po
$package "$POFILE" &&
310 LANG
=`expr $POFILE : '\(.*\)\.po'` &&
311 { grep -q $LANG po
/LINGUAS ||
312 (echo $LANG; cat po
/LINGUAS
) |
sort -o po
/LINGUAS
; }
314 func_get_translations .
/po
$package
320 only
) func_update_po
; exit 0 ;;
321 yes) func_update_po
;;
322 *) func_update_po
$DOWNLOAD_PO ;;
325 ## ---------------- ##
326 ## Version control. ##
327 ## ---------------- ##
329 # gnulib-tool updates ltdl/m4/.{git,cvs}ignore and gnu/.{git,cvs}ignore, and
330 # keeping generated files under version control does not make sense. Since
331 # gnu is entirely ignored, we only need to prepopulate the ltdl/m4 ignore
332 # files with generated files not tracked by gnulib-tool.
333 if test -f $config_macro_dir/.gitignore
; then
336 func_echo
"creating initial $config_macro_dir/.cvsignore"
337 cat > $config_macro_dir/.cvsignore
<<\EOF
338 # files created by gnulib, but that gnulib doesn't track
343 # files manually imported, rather than using gnulib-tool
346 # files created by autopoint
377 # files created by libtoolize
385 # gnulib-tool edits below here
387 func_echo
"creating initial $config_macro_dir/.gitignore"
388 cp $config_macro_dir/.cvsignore
$config_macro_dir/.gitignore
395 # Released autopoint has the tendency to install macros that have been
396 # obsoleted in current gnulib, so run this before gnulib-tool.
397 func_echo
"running: $AUTOPOINT --force"
400 ## ---------------------------- ##
401 ## Find the gnulib module tree. ##
402 ## ---------------------------- ##
405 /* ) gnulibdir
=$GNULIB_TOOL ;; # absolute
406 */* ) gnulibdir
=`pwd`/$GNULIB_TOOL ;; # relative
407 * ) gnulibdir
=`which "$GNULIB_TOOL"` ;; # PATH search
411 while test -h "$gnulibdir"; do
413 # Resolve symbolic link.
414 sedexpr1
='s, -> ,#%%#,'
415 sedexpr2
='s,^.*#%%#\(.*\)$,\1,p'
416 linkval
=`ls -l "$gnulibdir" | $SED "$sedexpr1" | $SED -n "$sedexpr2"`
417 test -n "$linkval" ||
break
420 /* ) gnulibdir
="$linkval" ;;
421 * ) gnulibdir
=`echo "$gnulibdir" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
426 gnulibdir
=`echo "$gnulibdir" | $SED "$dirname"`
429 ## ---------------------- ##
430 ## Import Gnulib modules. ##
431 ## ---------------------- ##
433 func_echo
"running: ${GNULIB_TOOL} --update"
434 ${GNULIB_TOOL} --update
437 ## --------------------------------- ##
438 ## Copy additional src only modules. ##
439 ## --------------------------------- ##
441 func_echo
"fetching modules for src directory"
443 for file in `${GNULIB_TOOL} --extract-filelist $src_modules`; do
445 dest
=`echo $file | $SED "$basename"`
447 lib
/*) dest
=src
/$dest ;;
448 m
4/*) dest
=$config_macro_dir/$dest ;;
449 *) func_echo
"Unknown file: $file"
454 # Be sure to show all copying errors before bailing out
455 if test -f $gnulibdir/$file; then
456 func_echo
"copying file \`$dest'"
457 cp $gnulibdir/$file $dest
459 func_error
"$gnulibdir/$file does not exist"
470 # Disable autopoint, since it was already done above.
471 func_echo
"running: AUTOPOINT=true" \
472 "$AUTORECONF --force --verbose --install --no-recursive"
473 AUTOPOINT
=true
$AUTORECONF --force --verbose --install --no-recursive
476 ## ---------------------------------------- ##
477 ## Gnulib is more up-to-date than automake. ##
478 ## ---------------------------------------- ##
480 func_update
"$gnulibdir"/build-aux
/config.guess
$config_aux_dir/config.guess
481 func_update
"$gnulibdir"/build-aux
/config.sub
$config_aux_dir/config.sub
482 func_update
"$gnulibdir"/build-aux
/depcomp
$config_aux_dir/depcomp
483 func_update
"$gnulibdir"/build-aux
/install-sh
$config_aux_dir/install-sh
484 func_update
"$gnulibdir"/build-aux
/mdate-sh
$config_aux_dir/mdate-sh
485 func_update
"$gnulibdir"/build-aux
/missing
$config_aux_dir/missing
486 func_update
"$gnulibdir"/build-aux
/texinfo.tex
$config_aux_dir/texinfo.tex
487 func_update
"$gnulibdir"/build-aux
/po
/Makefile.
in.
in po
/Makefile.
in.
in
488 func_update
"$gnulibdir"/build-aux
/po
/remove-potcdate.sin po
/remove-potcdate.sin
489 func_update
"$gnulibdir"/doc
/COPYINGv3 COPYING
490 func_update
"$gnulibdir"/doc
/INSTALL INSTALL
497 if test x
"$DOWNLOAD_PO" != xno
; then
498 func_echo
"If your pofiles are up-to-date, you can rerun bootstrap"
499 func_echo
"as \`DOWNLOAD_PO=no $progname' to avoid redownloading."
505 # eval: (add-hook 'write-file-hooks 'time-stamp)
506 # time-stamp-start: "# bootstrap (GNU M4) version "
507 # time-stamp-format: "%:y-%02m-%02d"
508 # time-stamp-end: "$"