3 # bootstrap (GNU M4) version 2010-03-02
4 # Written by Gary V. Vaughan <gary@gnu.org>
6 # Copyright (C) 2004-2011 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 # --gnulib-srcdir=DIRNAME
27 # Specify the local directory where gnulib
28 # sources reside. Use this if you already
29 # have gnulib sources on your machine, and
30 # do not want to waste your bandwidth downloading
31 # them again. Defaults to $GNULIB_SRCDIR.
32 # -v --version print version information
33 # -h,-? --help print short or long help message
35 # You can also set the following variables to help $progname
36 # locate the right tools:
37 # AUTORECONF, CONFIG_SHELL, GNULIB_SRCDIR, M4, RM, SED
39 # This script bootstraps a git checkout of GNU M4 by correctly calling
40 # out to parts of the GNU Build Platform. See HACKING for a list of
41 # prerequisite tools and versions required. If you are re-running
42 # bootstrap on a release tarball rather than using a git checkout,
43 # then see the release announcement for the prerequisite tools used.
45 # Report bugs to <bug-m4@gnu.org>
47 : ${AUTORECONF=autoreconf}
48 : ${CONFIG_SHELL=/bin/sh}
52 # Ensure file names are sorted consistently across platforms.
61 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
62 # is ksh but when the shell is invoked as "sh" and the current value of
63 # the _XPG environment variable is not equal to 1 (one), the special
64 # positional parameter $0, within a function call, is the name of the
68 # The name of this program:
69 progname=`echo "$progpath" | $SED "$basename"`
72 # Detect whether this is a version control system checkout or a tarball
76 # Echo program name prefixed message.
79 echo $progname: ${1+"$@"}
84 # Echo program name prefixed message to standard error.
87 echo $progname: ${1+"$@"} >&2
90 # func_fatal_error arg...
91 # Echo program name prefixed message to standard error, and exit.
99 # Echo program name prefixed message in verbose mode only.
102 $opt_verbose && func_error ${1+"$@"}
105 # func_missing_arg argname
106 # Echo program name prefixed message to standard error and set global
110 func_error "missing argument for $1"
114 # func_fatal_help arg...
115 # Echo program name prefixed message to standard error, followed by
116 # a help hint, and exit.
120 func_fatal_error "Try \`$progname --help' for more information."
123 # func_missing_arg argname
124 # Echo program name prefixed message to standard error and set global
128 func_error "missing argument for $1"
133 # Echo short help message to standard output and exit.
136 $SED '/^# Usage:/,/# -h/ {
138 s/\$progname/'$progname'/;
142 echo "run \`$progname --help | more' for full usage"
147 # Echo long help message to standard output and exit.
150 $SED '/^# Usage:/,/# Report bugs to/ {
152 s/\$progname/'$progname'/;
159 # Echo version message to standard output and exit.
162 $SED '/^# '$PROGRAM' (GNU /,/# warranty; / {
164 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
171 # Copy $1 to $2 if it is newer.
174 if test -f "$2" && cmp -s "$1" "$2" ; then
175 func_verbose "$2 is up-to-date"
177 func_echo "copying $1 -> $2"
182 # Parse options once, thoroughly. This comes as soon as possible in
183 # the script to make things like `bootstrap --version' happen quickly.
186 my_sed_single_opt='1s/^\(..\).*$/\1/;q'
187 my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
188 my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
189 my_sed_long_arg='1s/^--[^=]*=//'
191 # this just eases exit handling
192 while test $# -gt 0; do
196 # Separate optargs to short options:
197 -f|--force) vcs_only_file= ;;
199 GNULIB_SRCDIR=`expr "X$opt" : 'X--gnulib-srcdir=\(.*\)'` ;;
200 -\?|-h) func_usage ;;
202 --version) func_version ;;
204 -*) func_fatal_help "unrecognized option \`$opt'" ;;
205 *) set -- "$opt" ${1+"$@"}; break ;;
209 # Bail if the options were screwed
210 $exit_cmd $EXIT_FAILURE
212 if test -n "$vcs_only_file" && test ! -r "$vcs_only_file"; then
214 "Bootstrapping from a non-version-control distribution is risky."
218 ## ---------------- ##
219 ## Version control. ##
220 ## ---------------- ##
222 # gnulib-tool updates m4/.{git,cvs}ignore and lib/.{git,cvs}ignore, and
223 # keeping generated files under version control does not make sense.
224 # Since lib is entirely ignored, we only need to prepopulate the m4 ignore
225 # files with generated files not tracked by gnulib-tool.
226 if test -f $config_macro_dir/.gitignore ; then
229 func_echo "creating initial $config_macro_dir/.cvsignore"
230 cat > $config_macro_dir/.cvsignore <<\EOF
231 # files created by gnulib, but that gnulib doesn't track
236 # gnulib-tool edits below here
238 func_echo "creating initial $config_macro_dir/.gitignore"
239 cp $config_macro_dir/.cvsignore $config_macro_dir/.gitignore
242 # See if we can use gnulib's git-merge-changelog merge driver.
243 if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
244 if git config merge.merge-changelog.driver >/dev/null ; then
246 elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
247 func_echo "initializing git-merge-changelog driver"
248 git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
249 git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
251 func_echo "consider installing git-merge-changelog from gnulib"
253 if git config diff.texinfo.funcname >/dev/null ; then
256 func_echo "initializing git texinfo diff driver"
257 git config diff.texinfo.funcname '^@node[ \t][ \t]*\\([^,][^,]*\\)'
261 ## ------------------------------ ##
262 ## Update the gnulib module tree. ##
263 ## ------------------------------ ##
265 if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
266 if test -f gnulib/gnulib-tool ; then
267 func_echo "updating gnulib submodule"
268 git submodule update \
269 || func_fatal_error "Unable to update gnulib"
271 # A fresh checkout creates an empty subdirectory gnulib. However,
272 # older git didn't know how to clone into an empty subdir. If the
273 # user provided GNULIB_SRCDIR, then make the initial clone refer
274 # to the existing checkout, to save network traffic.
275 func_echo "importing gnulib submodule"
276 if test -d "$GNULIB_SRCDIR" ; then
277 rmdir gnulib 2>/dev/null
278 git clone --reference "$GNULIB_SRCDIR" git://git.sv.gnu.org/gnulib.git \
279 && git submodule init && git submodule update \
280 || func_fatal_error "Unable to update gnulib"
282 git submodule update --init \
283 || func_fatal_error "Unable to update gnulib"
287 func_echo "git not detected. If needed, update gnulib subdirectory manually"
290 ## ---------------------- ##
291 ## Import Gnulib modules. ##
292 ## ---------------------- ##
294 func_echo "running: $CONFIG_SHELL gnulib/gnulib-tool --update"
295 $CONFIG_SHELL gnulib/gnulib-tool --update \
296 || func_fatal_error "gnulib-tool failed"
302 func_echo "running: $AUTORECONF --verbose --install"
303 $AUTORECONF --verbose --install || func_fatal_error "autoreconf failed"
308 # eval: (add-hook 'write-file-hooks 'time-stamp)
309 # time-stamp-start: "# bootstrap (GNU M4) version "
310 # time-stamp-format: "%:y-%02m-%02d"
311 # time-stamp-end: "$"