Mention release of version 1.4.14.
[m4.git] / bootstrap
blobad123046e6cbcad1b3f6010fbc987f2dd01dfd1c
1 #! /bin/sh
3 # bootstrap (GNU M4) version 2010-01-05
4 # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
5 # Foundation, Inc.
6 # License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
7 # This is free software: you are free to change and redistribute it.
8 # There is NO WARRANTY, to the extent permitted by law.
10 # Written by Gary V. Vaughan <gary@gnu.org>
12 # This file is part of GNU M4.
14 # GNU M4 is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation, either version 3 of the License, or
17 # (at your option) any later version.
19 # GNU M4 is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 # Usage: $progname [options]
29 # -f --force bootstrap even when sources are not from git
30 # --skip-po skip downloading pofiles
31 # -v --version print version information
32 # -h,-? --help print short or long help message
34 # You can also set the following variables to help $progname
35 # locate the right tools:
36 # AUTOPOINT, AUTORECONF, AWK, CONFIG_SHELL, GNULIB_SRCDIR, LIBTOOLIZE,
37 # M4, RM, SED
39 # This script bootstraps a git or CVS checkout of GNU M4 by correctly calling
40 # out to parts of the GNU Build Platform. Currently this requires GNU
41 # Gettext 0.16 or better, the latest git Autoconf 2.63b-41 or better,
42 # GNU M4 1.4.5 or better, Automake 1.10b or better, Libtool 2.2 or better,
43 # and the latest git or CVS checkout of Gnulib.
44 # Libtool must be installed; either with the same --prefix as
45 # automake, or made accessible to aclocal's search path via
46 # $AUTOMAKE_prefix/share/aclocal/dirlist.
48 # Report bugs to <bug-m4@gnu.org>
50 : ${AUTOPOINT=autopoint}
51 : ${AUTORECONF=autoreconf}
52 : ${AWK=awk}
53 : ${CONFIG_SHELL=/bin/sh}
54 : ${LIBTOOLIZE=libtoolize}
55 : ${M4=m4}
56 : ${RM='rm -f'}
57 : ${SED=sed}
59 # Ensure file names are sorted consistently across platforms.
60 # Also, ensure diagnostics are in English.
61 LC_ALL=C
62 export LC_ALL
64 package=m4
65 ltdldir=ltdl
66 config_aux_dir=build-aux
67 config_macro_dir=$ltdldir/m4
68 bailout_cb=:
70 # List dependencies here too; we don't extract them, otherwise dependent
71 # modules could end up being imported to src/ *and* gnu/!
72 src_modules='
73 getopt-gnu
74 getopt-posix
75 version-etc-fsf
76 version-etc
77 xstrtol
80 dirname="s,/[^/]*$,,"
81 basename="s,^.*/,,g"
83 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
84 # is ksh but when the shell is invoked as "sh" and the current value of
85 # the _XPG environment variable is not equal to 1 (one), the special
86 # positional parameter $0, within a function call, is the name of the
87 # function.
88 progpath="$0"
90 # The name of this program:
91 progname=`echo "$progpath" | $SED "$basename"`
92 PROGRAM=bootstrap
94 # Detect whether this is a version control system checkout or a tarball
95 vcs_only_file=HACKING
97 # func_echo arg...
98 # Echo program name prefixed message.
99 func_echo ()
101 echo $progname: ${1+"$@"}
104 # func_error arg...
105 # Echo program name prefixed message to standard error.
106 func_error ()
108 echo $progname: ${1+"$@"} >&2
111 # func_fatal_error arg...
112 # Echo program name prefixed message to standard error, and exit.
113 func_fatal_error ()
115 func_error ${1+"$@"}
116 exit $EXIT_FAILURE
119 # func_verbose arg...
120 # Echo program name prefixed message in verbose mode only.
121 func_verbose ()
123 $opt_verbose && func_error ${1+"$@"}
126 # func_missing_arg argname
127 # Echo program name prefixed message to standard error and set global
128 # exit_cmd.
129 func_missing_arg ()
131 func_error "missing argument for $1"
132 exit_cmd=exit
135 # func_fatal_help arg...
136 # Echo program name prefixed message to standard error, followed by
137 # a help hint, and exit.
138 func_fatal_help ()
140 func_error ${1+"$@"}
141 func_fatal_error "Try \`$progname --help' for more information."
144 # func_missing_arg argname
145 # Echo program name prefixed message to standard error and set global
146 # exit_cmd.
147 func_missing_arg ()
149 func_error "missing argument for $1"
150 exit_cmd=exit
153 # func_usage
154 # Echo short help message to standard output and exit.
155 func_usage ()
157 $SED '/^# Usage:/,/# -h/ {
158 s/^# //; s/^# *$//;
159 s/\$progname/'$progname'/;
161 }; d' < "$progpath"
162 echo
163 echo "run \`$progname --help | more' for full usage"
164 exit $EXIT_SUCCESS
167 # func_help
168 # Echo long help message to standard output and exit.
169 func_help ()
171 $SED '/^# Usage:/,/# Report bugs to/ {
172 s/^# //; s/^# *$//;
173 s/\$progname/'$progname'/;
175 }; d' < "$progpath"
176 exit $EXIT_SUCCESS
179 # func_version
180 # Echo version message to standard output and exit.
181 func_version ()
183 $SED '/^# '$PROGRAM' (GNU /,/# Written by / {
184 s/^# //;
185 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
187 }; d' < "$progpath"
188 exit $EXIT_SUCCESS
191 # func_update
192 # Copy $1 to $2 if it is newer.
193 func_update ()
195 if test -f "$2" && cmp -s "$1" "$2" ; then
196 func_verbose "$2 is up-to-date"
197 else
198 func_echo "copying $1 -> $2"
199 cp "$1" "$2"
203 # Parse options once, thoroughly. This comes as soon as possible in
204 # the script to make things like `bootstrap --version' happen quickly.
206 # sed scripts:
207 my_sed_single_opt='1s/^\(..\).*$/\1/;q'
208 my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
209 my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
210 my_sed_long_arg='1s/^--[^=]*=//'
212 # this just eases exit handling
213 while test $# -gt 0; do
214 opt="$1"
215 shift
216 case $opt in
217 -f|--force) vcs_only_file= ;;
218 --skip-po) SKIP_PO=t ;;
219 -\?|-h) func_usage ;;
220 --help) func_help ;;
221 --version) func_version ;;
222 --) break ;;
223 -*) func_fatal_help "unrecognized option \`$opt'" ;;
224 *) set -- "$opt" ${1+"$@"}; break ;;
225 esac
226 done
228 # Bail if the options were screwed
229 $exit_cmd $EXIT_FAILURE
231 if test -n "$vcs_only_file" && test ! -r "$vcs_only_file"; then
232 func_fatal_error \
233 "Bootstrapping from a non-version-control distribution is risky."
237 ## --------------------------------------- ##
238 ## Fetch translations. ##
239 ## (taken from gnulib build-aux/bootstrap) ##
240 ## --------------------------------------- ##
242 # The command to download all .po files for a specified domain into
243 # a specified directory. Fill in the first %s with the domain name,
244 # the second with the destination directory. Use rsync's -L and -r
245 # options because the latest/%s directory and the .po files within
246 # are all symlinks.
247 po_download_command_format=\
248 "rsync -Lrtvz 'translationproject.org::tp/latest/%s/' '%s'"
250 func_get_translations()
252 subdir=$1
253 domain=$2
255 func_echo "getting translations into $subdir for $domain..."
256 cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
257 eval "$cmd"
260 ## --------------------------------------- ##
261 ## Update translations. ##
262 ## (taken from gnulib build-aux/bootstrap) ##
263 ## --------------------------------------- ##
265 func_update_po ()
267 # Directory containing primary .po files.
268 # Overwrite them only when we're sure a .po file is new.
269 po_dir=po
270 domain=$package
272 # Download *.po files into this dir.
273 # Usually contains *.s1 checksum files.
274 ref_po_dir="$po_dir/.reference"
276 test -d $ref_po_dir || mkdir $ref_po_dir || return
278 func_get_translations $ref_po_dir $domain \
279 && ls "$ref_po_dir"/*.po 2>/dev/null \
280 | sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
281 langs=`cd $ref_po_dir && echo *.po | sed 's/\.po//g'`
283 test "$langs" = '*' && langs=x
284 for po in $langs; do
285 case $po in x) continue;; esac
286 new_po="$ref_po_dir/$po.po"
287 cksum_file="$ref_po_dir/$po.s1"
288 if ! test -f "$cksum_file" ||
289 ! test -f "$po_dir/$po.po" ||
290 ! sha1sum -c --status "$cksum_file" < "$new_po" > /dev/null; then
291 echo "updated $po_dir/$po.po..."
292 cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file"
294 done
297 case $SKIP_PO in
298 '') func_update_po ;;
299 esac
301 ## ---------------- ##
302 ## Version control. ##
303 ## ---------------- ##
305 # See if we can use gnulib's git-merge-changelog merge driver.
306 if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
307 if git config merge.merge-changelog.driver >/dev/null ; then
309 elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
310 func_echo "initializing git-merge-changelog driver"
311 git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
312 git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
313 else
314 func_echo "consider installing git-merge-changelog from gnulib"
316 if git config diff.texinfo.funcname >/dev/null ; then
318 else
319 func_echo "initializing git texinfo diff driver"
320 git config diff.texinfo.funcname '^@node[ ][ ]*\\([^,][^,]*\\)'
324 ## ------------------------------ ##
325 ## Update the gnulib module tree. ##
326 ## ------------------------------ ##
328 if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
329 if test -f gnulib/gnulib-tool ; then
330 func_echo "updating gnulib submodule"
331 git submodule update \
332 || func_fatal_error "Unable to update gnulib"
333 else
334 # A fresh checkout creates an empty subdirectory gnulib. However,
335 # older git didn't know how to clone into an empty subdir. If the
336 # user provided GNULIB_SRCDIR, then make the initial clone refer
337 # to the existing checkout, to save network traffic.
338 func_echo "importing gnulib submodule"
339 if test -d "$GNULIB_SRCDIR" ; then
340 rmdir gnulib 2>/dev/null
341 git clone --reference "$GNULIB_SRCDIR" git://git.sv.gnu.org/gnulib.git \
342 && git submodule init && git submodule update \
343 || func_fatal_error "Unable to update gnulib"
344 else
345 git submodule update --init \
346 || func_fatal_error "Unable to update gnulib"
349 else
350 func_echo "git not detected. If needed, update gnulib subdirectory manually"
353 ## ---------- ##
354 ## Autopoint. ##
355 ## ---------- ##
357 # Released autopoint has the tendency to install macros that have been
358 # obsoleted in current gnulib, so run this before gnulib-tool.
359 func_echo "running: $AUTOPOINT --force"
360 $AUTOPOINT --force
362 ## ----------- ##
363 ## Libtoolize. ##
364 ## ----------- ##
366 # Autoreconf runs aclocal before libtoolize, which causes spurious
367 # warnings if the initial aclocal is confused by the libtoolized
368 # (or worse out-of-date) macro directory.
369 func_echo "running: $LIBTOOLIZE --copy --install"
370 ${LIBTOOLIZE} --copy --install
371 # Note that if libtoolize has newer auxiliary files than the current
372 # gnulib submodule, then this will result in a typechange. See
373 # HACKING for details.
375 ## ---------------------- ##
376 ## Import Gnulib modules. ##
377 ## ---------------------- ##
379 func_echo "running: $CONFIG_SHELL gnulib/gnulib-tool --update"
380 $CONFIG_SHELL gnulib/gnulib-tool --update \
381 || func_fatal_error "gnulib-tool failed"
383 ## --------------------------------- ##
384 ## Copy additional src only modules. ##
385 ## --------------------------------- ##
387 func_echo "fetching modules for src directory"
389 for file in `$CONFIG_SHELL gnulib/gnulib-tool --extract-filelist $src_modules \
390 | sort -u`
393 dest=`echo $file | $SED "$basename"`
394 case $file in
395 lib/*) dest=src/$dest ;;
396 m4/*) dest=$config_macro_dir/$dest ;;
397 *) func_echo "Unknown file: $file"
398 exit 1
400 esac
402 # Be sure to show all copying errors before bailing out
403 if test -f gnulib/$file; then
404 func_echo "copying file \`$dest'"
405 cp gnulib/$file $dest
406 else
407 func_error "gnulib/$file does not exist"
408 bailout_cb="exit 1"
410 done
411 $bailout_cb
414 ## ----------- ##
415 ## Autoreconf. ##
416 ## ----------- ##
418 # Disable autopoint and libtoolize, since they were already done above.
419 func_echo "running: AUTOPOINT=true LIBTOOLIZE=true " \
420 "$AUTORECONF --verbose --install --no-recursive"
421 AUTOPOINT=true LIBTOOLIZE=true \
422 $AUTORECONF --verbose --install --no-recursive \
423 || func_fatal_error "autoreconf failed"
425 ## ------- ##
426 ## Wrapup. ##
427 ## ------- ##
429 if test x"$SKIP_PO" = x; then
430 func_echo "If your pofiles are up-to-date, you can rerun bootstrap"
431 func_echo "as \`$progname --skip-po' to avoid redownloading."
434 exit 0
436 # Local variables:
437 # eval: (add-hook 'write-file-hooks 'time-stamp)
438 # time-stamp-start: "# bootstrap (GNU M4) version "
439 # time-stamp-format: "%:y-%02m-%02d"
440 # time-stamp-end: "$"
441 # End: