3 # bootstrap (GNU M4) version 2006-07-15
4 # Written by Gary V. Vaughan <gary@gnu.org>
6 # Copyright (C) 2004, 2005, 2006 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 2 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 # -v --version print version information
29 # -h,-? --help print short or long help message
31 # You can also set the following variables to help $progname
32 # locate the right tools:
33 # AUTORECONF, GNULIB_TOOL, RM, SED
35 # This script bootstraps a CVS checkout of GNU M4 by correctly
36 # calling out to parts of the GNU Build Platform. Currently this
37 # requires GNU Autoconf 2.60, GNU Automake 1.9.6, and bleeding edge
38 # CVS snapshots of GNU Gnulib.
40 # Report bugs to <bug-m4@gnu.org>
42 : ${AUTORECONF=autoreconf}
43 : ${GNULIB_TOOL=gnulib-tool}
50 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
51 # is ksh but when the shell is invoked as "sh" and the current value of
52 # the _XPG environment variable is not equal to 1 (one), the special
53 # positional parameter $0, within a function call, is the name of the
57 # The name of this program:
58 progname
=`echo "$progpath" | $SED "$basename"`
62 # Echo program name prefixed message.
65 echo $progname: ${1+"$@"}
70 # Echo program name prefixed message to standard error.
73 echo $progname: ${1+"$@"} >&2
76 # func_fatal_error arg...
77 # Echo program name prefixed message to standard error, and exit.
85 # Echo program name prefixed message in verbose mode only.
88 $opt_verbose && func_error
${1+"$@"}
91 # func_missing_arg argname
92 # Echo program name prefixed message to standard error and set global
96 func_error
"missing argument for $1"
100 # func_fatal_help arg...
101 # Echo program name prefixed message to standard error, followed by
102 # a help hint, and exit.
106 func_fatal_error
"Try \`$progname --help' for more information."
109 # func_missing_arg argname
110 # Echo program name prefixed message to standard error and set global
114 func_error
"missing argument for $1"
119 # Echo short help message to standard output and exit.
122 $SED '/^# Usage:/,/# -h/ {
124 s/\$progname/'$progname'/;
128 echo "run \`$progname --help | more' for full usage"
133 # Echo long help message to standard output and exit.
136 $SED '/^# Usage:/,/# Report bugs to/ {
138 s/\$progname/'$progname'/;
145 # Echo version message to standard output and exit.
148 $SED '/^# '$PROGRAM' (GNU /,/# warranty; / {
150 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
157 # Copy $1 to $2 if it is newer.
160 if test -f "$2" && cmp -s "$1" "$2" ; then
161 func_verbose
"$2 is up-to-date"
163 func_echo
"copying $1 -> $2"
168 # Parse options once, thoroughly. This comes as soon as possible in
169 # the script to make things like `bootstrap --version' happen quickly.
172 my_sed_single_opt
='1s/^\(..\).*$/\1/;q'
173 my_sed_single_rest
='1s/^..\(.*\)$/\1/;q'
174 my_sed_long_opt
='1s/^\(--[^=]*\)=.*/\1/;q'
175 my_sed_long_arg
='1s/^--[^=]*=//'
177 # this just eases exit handling
178 while test $# -gt 0; do
182 # Separate optargs to short options:
183 -\?|
-h) func_usage
;;
185 --version) func_version
;;
187 -*) func_fatal_help
"unrecognized option \`$opt'" ;;
188 *) set -- "$opt" ${1+"$@"}; break ;;
192 # Bail if the options were screwed
193 $exit_cmd $EXIT_FAILURE
196 ## ---------------------------- ##
197 ## Find the gnulib module tree. ##
198 ## ---------------------------- ##
201 /* ) gnulibdir
=$GNULIB_TOOL ;; # absolute
202 */* ) gnulibdir
=`pwd`/$GNULIB_TOOL ;; # relative
203 * ) gnulibdir
=`which "$GNULIB_TOOL"` ;; # PATH search
207 while test -h "$gnulibdir"; do
209 # Resolve symbolic link.
210 sedexpr1
='s, -> ,#%%#,'
211 sedexpr2
='s,^.*#%%#\(.*\)$,\1,p'
212 linkval
=`LC_ALL=C ls -l "$gnulibdir" | $SED "$sedexpr1" | $SED -n "$sedexpr2"`
213 test -n "$linkval" ||
break
216 /* ) gnulibdir
="$linkval" ;;
217 * ) gnulibdir
=`echo "$gnulibdir" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
222 gnulibdir
=`echo "$gnulibdir" | $SED "$dirname"`
224 ## ---------------------- ##
225 ## Import Gnulib modules. ##
226 ## ---------------------- ##
228 func_echo
"running: $GNULIB_TOOL --update"
229 $GNULIB_TOOL --update || func_fatal_error
"gnulib-tool failed"
235 func_echo
"running: $AUTORECONF --force --verbose --install"
236 $AUTORECONF --force --verbose --install || func_fatal_error
"autoreconf failed"
238 ## ---------------------------------------- ##
239 ## Gnulib is more up-to-date than automake. ##
240 ## ---------------------------------------- ##
242 func_update
"$gnulibdir"/build-aux
/config.guess config.guess
243 func_update
"$gnulibdir"/build-aux
/config.sub config.sub
244 func_update
"$gnulibdir"/build-aux
/depcomp depcomp
245 func_update
"$gnulibdir"/build-aux
/install-sh install-sh
246 func_update
"$gnulibdir"/build-aux
/mdate-sh
doc
/mdate-sh
247 func_update
"$gnulibdir"/build-aux
/missing missing
248 func_update
"$gnulibdir"/build-aux
/texinfo.tex
doc
/texinfo.tex
249 func_update
"$gnulibdir"/doc
/COPYING COPYING
250 func_update
"$gnulibdir"/doc
/INSTALL INSTALL
255 # eval: (add-hook 'write-file-hooks 'time-stamp)
256 # time-stamp-start: "# bootstrap (GNU M4) version "
257 # time-stamp-format: "%:y-%02m-%02d"
258 # time-stamp-end: "$"