3 # bootstrap (GNU M4) version 2008-09-16
4 # Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 # License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
6 # This is free software: you are free to change and redistribute it.
7 # There is NO WARRANTY, to the extent permitted by law.
9 # Written by Gary V. Vaughan <gary@gnu.org>
11 # This file is part of GNU M4.
13 # GNU M4 is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
18 # GNU M4 is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 # Usage: $progname [options]
28 # -f --force bootstrap even when sources are not from git
29 # --skip-po skip downloading pofiles
30 # -v --version print version information
31 # -h,-? --help print short or long help message
33 # You can also set the following variables to help $progname
34 # locate the right tools:
35 # AUTOPOINT, AUTORECONF, AWK, GNULIB_TOOL, LIBTOOLIZE, M4, RM, SED
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.62 or better, GNU M4 1.4.5 or better,
40 # the latest git Automake 1.10a or better, Libtool 2.2 or better,
41 # 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}
52 : ${LIBTOOLIZE=libtoolize}
57 # Ensure file names are sorted consistently across platforms.
58 # Also, ensure diagnostics are in English.
64 config_aux_dir
=build-aux
65 config_macro_dir
=$ltdldir/m4
68 # List dependencies here too; we don't extract them, otherwise dependent
69 # modules could end up being imported to src/ *and* gnu/!
70 src_modules
='getopt version-etc-fsf version-etc xstrtol'
75 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
76 # is ksh but when the shell is invoked as "sh" and the current value of
77 # the _XPG environment variable is not equal to 1 (one), the special
78 # positional parameter $0, within a function call, is the name of the
82 # The name of this program:
83 progname
=`echo "$progpath" | $SED "$basename"`
86 # Detect whether this is a version control system checkout or a tarball
90 # Echo program name prefixed message.
93 echo $progname: ${1+"$@"}
97 # Echo program name prefixed message to standard error.
100 echo $progname: ${1+"$@"} >&2
103 # func_fatal_error arg...
104 # Echo program name prefixed message to standard error, and exit.
111 # func_verbose arg...
112 # Echo program name prefixed message in verbose mode only.
115 $opt_verbose && func_error
${1+"$@"}
118 # func_missing_arg argname
119 # Echo program name prefixed message to standard error and set global
123 func_error
"missing argument for $1"
127 # func_fatal_help arg...
128 # Echo program name prefixed message to standard error, followed by
129 # a help hint, and exit.
133 func_fatal_error
"Try \`$progname --help' for more information."
136 # func_missing_arg argname
137 # Echo program name prefixed message to standard error and set global
141 func_error
"missing argument for $1"
146 # Echo short help message to standard output and exit.
149 $SED '/^# Usage:/,/# -h/ {
151 s/\$progname/'$progname'/;
155 echo "run \`$progname --help | more' for full usage"
160 # Echo long help message to standard output and exit.
163 $SED '/^# Usage:/,/# Report bugs to/ {
165 s/\$progname/'$progname'/;
172 # Echo version message to standard output and exit.
175 $SED '/^# '$PROGRAM' (GNU /,/# Written by / {
177 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
184 # Copy $1 to $2 if it is newer.
187 if test -f "$2" && cmp -s "$1" "$2" ; then
188 func_verbose
"$2 is up-to-date"
190 func_echo
"copying $1 -> $2"
195 # Parse options once, thoroughly. This comes as soon as possible in
196 # the script to make things like `bootstrap --version' happen quickly.
199 my_sed_single_opt
='1s/^\(..\).*$/\1/;q'
200 my_sed_single_rest
='1s/^..\(.*\)$/\1/;q'
201 my_sed_long_opt
='1s/^\(--[^=]*\)=.*/\1/;q'
202 my_sed_long_arg
='1s/^--[^=]*=//'
204 # this just eases exit handling
205 while test $# -gt 0; do
209 -f|
--force) vcs_only_file
= ;;
210 --skip-po) SKIP_PO
=t
;;
211 -\?|
-h) func_usage
;;
213 --version) func_version
;;
215 -*) func_fatal_help
"unrecognized option \`$opt'" ;;
216 *) set -- "$opt" ${1+"$@"}; break ;;
220 # Bail if the options were screwed
221 $exit_cmd $EXIT_FAILURE
223 if test -n "$vcs_only_file" && test ! -r "$vcs_only_file"; then
225 "Bootstrapping from a non-version-control distribution is risky."
229 ## --------------------------------------- ##
230 ## Fetch translations. ##
231 ## (taken from gnulib build-aux/bootstrap) ##
232 ## --------------------------------------- ##
234 # The command to download all .po files for a specified domain into
235 # a specified directory. Fill in the first %s with the domain name,
236 # the second with the destination directory. Use rsync's -L and -r
237 # options because the latest/%s directory and the .po files within
239 po_download_command_format
=\
240 "rsync -Lrtvz 'translationproject.org::tp/latest/%s/' '%s'"
242 func_get_translations
()
247 func_echo
"getting translations into $subdir for $domain..."
248 cmd
=`printf "$po_download_command_format" "$domain" "$subdir"`
252 ## --------------------------------------- ##
253 ## Update translations. ##
254 ## (taken from gnulib build-aux/bootstrap) ##
255 ## --------------------------------------- ##
259 # Directory containing primary .po files.
260 # Overwrite them only when we're sure a .po file is new.
264 # Download *.po files into this dir.
265 # Usually contains *.s1 checksum files.
266 ref_po_dir
="$po_dir/.reference"
268 test -d $ref_po_dir || mkdir
$ref_po_dir ||
return
270 func_get_translations
$ref_po_dir $domain \
271 && ls "$ref_po_dir"/*.po
2>/dev
/null \
272 |
sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
273 langs
=`cd $ref_po_dir && echo *.po | sed 's/\.po//g'`
275 test "$langs" = '*' && langs
=x
277 case $po in x
) continue;; esac
278 new_po
="$ref_po_dir/$po.po"
279 cksum_file
="$ref_po_dir/$po.s1"
280 if ! test -f "$cksum_file" ||
281 ! test -f "$po_dir/$po.po" ||
282 ! sha1sum -c --status "$cksum_file" < "$new_po" > /dev
/null
; then
283 echo "updated $po_dir/$po.po..."
284 cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file"
290 '') func_update_po
;;
293 ## ---------------- ##
294 ## Version control. ##
295 ## ---------------- ##
297 # gnulib-tool updates ltdl/m4/.{git,cvs}ignore and gnu/.{git,cvs}ignore, and
298 # keeping generated files under version control does not make sense. Since
299 # gnu is entirely ignored, we only need to prepopulate the ltdl/m4 ignore
300 # files with generated files not tracked by gnulib-tool.
301 if test -f $config_macro_dir/.gitignore
; then
304 func_echo
"creating initial $config_macro_dir/.cvsignore"
305 cat > $config_macro_dir/.cvsignore
<<\EOF
306 # files created by gnulib, but that gnulib doesn't track
311 # files manually imported, rather than using gnulib-tool
314 # files created by autopoint
345 # files created by libtoolize
353 # gnulib-tool edits below here
355 func_echo
"creating initial $config_macro_dir/.gitignore"
356 cp $config_macro_dir/.cvsignore
$config_macro_dir/.gitignore
359 # See if we can use gnulib's git-merge-changelog merge driver.
360 if test -d .git
&& (git
--version) >/dev
/null
2>/dev
/null
; then
361 if git config merge.merge-changelog.driver
>/dev
/null
; then
363 elif (git-merge-changelog
--version) >/dev
/null
2>/dev
/null
; then
364 func_echo
"initializing git-merge-changelog driver"
365 git config merge.merge-changelog.name
'GNU-style ChangeLog merge driver'
366 git config merge.merge-changelog.driver
'git-merge-changelog %O %A %B'
368 func_echo
"consider installing git-merge-changelog from gnulib"
370 if git config
diff.texinfo.funcname
>/dev
/null
; then
373 func_echo
"initializing git texinfo diff driver"
374 git config
diff.texinfo.funcname
'^@node[ ][ ]*\\([^,][^,]*\\)'
382 # Released autopoint has the tendency to install macros that have been
383 # obsoleted in current gnulib, so run this before gnulib-tool.
384 func_echo
"running: $AUTOPOINT --force"
391 # Autoreconf runs aclocal before libtoolize, which causes spurious
392 # warnings if the initial aclocal is confused by the libtoolized
393 # (or worse out-of-date) macro directory.
394 func_echo
"running: $LIBTOOLIZE --force --copy --install"
395 ${LIBTOOLIZE} --force --copy --install
397 ## ---------------------------- ##
398 ## Find the gnulib module tree. ##
399 ## ---------------------------- ##
402 /* ) gnulibdir
=$GNULIB_TOOL ;; # absolute
403 */* ) gnulibdir
=`pwd`/$GNULIB_TOOL ;; # relative
404 * ) gnulibdir
=`which "$GNULIB_TOOL"` ;; # PATH search
408 while test -h "$gnulibdir"; do
410 # Resolve symbolic link.
411 sedexpr1
='s, -> ,#%%#,'
412 sedexpr2
='s,^.*#%%#\(.*\)$,\1,p'
413 linkval
=`ls -l "$gnulibdir" | $SED "$sedexpr1" | $SED -n "$sedexpr2"`
414 test -n "$linkval" ||
break
417 /* ) gnulibdir
="$linkval" ;;
418 * ) gnulibdir
=`echo "$gnulibdir" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
423 gnulibdir
=`echo "$gnulibdir" | $SED "$dirname"`
426 ## ---------------------- ##
427 ## Import Gnulib modules. ##
428 ## ---------------------- ##
430 func_echo
"running: ${GNULIB_TOOL} --update"
431 ${GNULIB_TOOL} --update
434 ## --------------------------------- ##
435 ## Copy additional src only modules. ##
436 ## --------------------------------- ##
438 func_echo
"fetching modules for src directory"
440 for file in `${GNULIB_TOOL} --extract-filelist $src_modules`; do
442 dest
=`echo $file | $SED "$basename"`
444 lib
/*) dest
=src
/$dest ;;
445 m
4/*) dest
=$config_macro_dir/$dest ;;
446 *) func_echo
"Unknown file: $file"
451 # Be sure to show all copying errors before bailing out
452 if test -f $gnulibdir/$file; then
453 func_echo
"copying file \`$dest'"
454 cp $gnulibdir/$file $dest
456 func_error
"$gnulibdir/$file does not exist"
467 # Disable autopoint and libtoolize, since they were already done above.
468 func_echo
"running: AUTOPOINT=true LIBTOOLIZE=true " \
469 "$AUTORECONF --force --verbose --install --no-recursive"
470 AUTOPOINT
=true LIBTOOLIZE
=true \
471 $AUTORECONF --force --verbose --install --no-recursive
474 ## ---------------------------------------- ##
475 ## Gnulib is more up-to-date than automake. ##
476 ## ---------------------------------------- ##
478 func_update
"$gnulibdir"/build-aux
/config.guess
$config_aux_dir/config.guess
479 func_update
"$gnulibdir"/build-aux
/config.sub
$config_aux_dir/config.sub
480 func_update
"$gnulibdir"/build-aux
/depcomp
$config_aux_dir/depcomp
481 func_update
"$gnulibdir"/build-aux
/install-sh
$config_aux_dir/install-sh
482 func_update
"$gnulibdir"/build-aux
/mdate-sh
$config_aux_dir/mdate-sh
483 func_update
"$gnulibdir"/build-aux
/missing
$config_aux_dir/missing
484 func_update
"$gnulibdir"/build-aux
/texinfo.tex
$config_aux_dir/texinfo.tex
485 func_update
"$gnulibdir"/build-aux
/po
/Makefile.
in.
in po
/Makefile.
in.
in
486 func_update
"$gnulibdir"/build-aux
/po
/remove-potcdate.sin po
/remove-potcdate.sin
487 func_update
"$gnulibdir"/doc
/COPYINGv3 COPYING
488 func_update
"$gnulibdir"/doc
/INSTALL INSTALL
495 if test x
"$SKIP_PO" = x
; then
496 func_echo
"If your pofiles are up-to-date, you can rerun bootstrap"
497 func_echo
"as \`$progname --skip-po' to avoid redownloading."
503 # eval: (add-hook 'write-file-hooks 'time-stamp)
504 # time-stamp-start: "# bootstrap (GNU M4) version "
505 # time-stamp-format: "%:y-%02m-%02d"
506 # time-stamp-end: "$"