3 # bootstrap (GNU M4) version 2007-07-04
4 # Written by Gary V. Vaughan <gary@gnu.org>
6 # Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
7 # This is free software; see the source for copying conditions. There is NO
8 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 # This program 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 # This program is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # 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, a copy can be downloaded from
22 # http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
23 # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 # Usage: $progname [options]
28 # -f --force bootstrap even when sources are not from CVS
29 # -v --version print version information
30 # -h,-? --help print short or long help message
32 # You can also set the following variables to help $progname
33 # locate the right tools:
34 # AUTORECONF, GNULIB_TOOL, RM, SED
36 # This script bootstraps a CVS checkout of GNU M4 by correctly
37 # calling out to parts of the GNU Build Platform. Currently this
38 # requires GNU Autoconf 2.60, GNU Automake 1.9.6, and bleeding edge
39 # CVS snapshots of GNU Gnulib.
41 # Report bugs to <bug-m4@gnu.org>
43 : ${AUTORECONF=autoreconf}
44 : ${GNULIB_TOOL=gnulib-tool}
51 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
52 # is ksh but when the shell is invoked as "sh" and the current value of
53 # the _XPG environment variable is not equal to 1 (one), the special
54 # positional parameter $0, within a function call, is the name of the
58 # The name of this program:
59 progname
=`echo "$progpath" | $SED "$basename"`
62 # Detect whether this is a CVS checkout or a tarball
66 # Echo program name prefixed message.
69 echo $progname: ${1+"$@"}
74 # Echo program name prefixed message to standard error.
77 echo $progname: ${1+"$@"} >&2
80 # func_fatal_error arg...
81 # Echo program name prefixed message to standard error, and exit.
89 # Echo program name prefixed message in verbose mode only.
92 $opt_verbose && func_error
${1+"$@"}
95 # func_missing_arg argname
96 # Echo program name prefixed message to standard error and set global
100 func_error
"missing argument for $1"
104 # func_fatal_help arg...
105 # Echo program name prefixed message to standard error, followed by
106 # a help hint, and exit.
110 func_fatal_error
"Try \`$progname --help' for more information."
113 # func_missing_arg argname
114 # Echo program name prefixed message to standard error and set global
118 func_error
"missing argument for $1"
123 # Echo short help message to standard output and exit.
126 $SED '/^# Usage:/,/# -h/ {
128 s/\$progname/'$progname'/;
132 echo "run \`$progname --help | more' for full usage"
137 # Echo long help message to standard output and exit.
140 $SED '/^# Usage:/,/# Report bugs to/ {
142 s/\$progname/'$progname'/;
149 # Echo version message to standard output and exit.
152 $SED '/^# '$PROGRAM' (GNU /,/# warranty; / {
154 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
161 # Copy $1 to $2 if it is newer.
164 if test -f "$2" && cmp -s "$1" "$2" ; then
165 func_verbose
"$2 is up-to-date"
167 func_echo
"copying $1 -> $2"
172 # Parse options once, thoroughly. This comes as soon as possible in
173 # the script to make things like `bootstrap --version' happen quickly.
176 my_sed_single_opt
='1s/^\(..\).*$/\1/;q'
177 my_sed_single_rest
='1s/^..\(.*\)$/\1/;q'
178 my_sed_long_opt
='1s/^\(--[^=]*\)=.*/\1/;q'
179 my_sed_long_arg
='1s/^--[^=]*=//'
181 # this just eases exit handling
182 while test $# -gt 0; do
186 # Separate optargs to short options:
187 -f|
--force) CVS_only_file
= ;;
188 -\?|
-h) func_usage
;;
190 --version) func_version
;;
192 -*) func_fatal_help
"unrecognized option \`$opt'" ;;
193 *) set -- "$opt" ${1+"$@"}; break ;;
197 # Bail if the options were screwed
198 $exit_cmd $EXIT_FAILURE
200 if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then
201 func_fatal_error
"Bootstrapping from a non-CVS distribution is risky."
205 ## ---------------------------- ##
206 ## Find the gnulib module tree. ##
207 ## ---------------------------- ##
210 /* ) gnulibdir
=$GNULIB_TOOL ;; # absolute
211 */* ) gnulibdir
=`pwd`/$GNULIB_TOOL ;; # relative
212 * ) gnulibdir
=`which "$GNULIB_TOOL"` ;; # PATH search
216 while test -h "$gnulibdir"; do
218 # Resolve symbolic link.
219 sedexpr1
='s, -> ,#%%#,'
220 sedexpr2
='s,^.*#%%#\(.*\)$,\1,p'
221 linkval
=`LC_ALL=C ls -l "$gnulibdir" | $SED "$sedexpr1" | $SED -n "$sedexpr2"`
222 test -n "$linkval" ||
break
225 /* ) gnulibdir
="$linkval" ;;
226 * ) gnulibdir
=`echo "$gnulibdir" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
231 gnulibdir
=`echo "$gnulibdir" | $SED "$dirname"`
233 ## ---------------------- ##
234 ## Import Gnulib modules. ##
235 ## ---------------------- ##
237 func_echo
"running: $GNULIB_TOOL --update"
238 $GNULIB_TOOL --update || func_fatal_error
"gnulib-tool failed"
244 func_echo
"running: $AUTORECONF --force --verbose --install"
245 $AUTORECONF --force --verbose --install || func_fatal_error
"autoreconf failed"
247 ## ---------------------------------------- ##
248 ## Gnulib is more up-to-date than automake. ##
249 ## ---------------------------------------- ##
251 func_update
"$gnulibdir"/build-aux
/config.guess config.guess
252 func_update
"$gnulibdir"/build-aux
/config.sub config.sub
253 func_update
"$gnulibdir"/build-aux
/depcomp depcomp
254 func_update
"$gnulibdir"/build-aux
/install-sh install-sh
255 func_update
"$gnulibdir"/build-aux
/mdate-sh
doc
/mdate-sh
256 func_update
"$gnulibdir"/build-aux
/missing missing
257 func_update
"$gnulibdir"/build-aux
/texinfo.tex
doc
/texinfo.tex
258 func_update
"$gnulibdir"/doc
/COPYINGv3 COPYING
259 func_update
"$gnulibdir"/doc
/INSTALL INSTALL
264 # eval: (add-hook 'write-file-hooks 'time-stamp)
265 # time-stamp-start: "# bootstrap (GNU M4) version "
266 # time-stamp-format: "%:y-%02m-%02d"
267 # time-stamp-end: "$"