* m4/gnulib-cache.m4: Augment with 'gnulib-tool --import stdint'.
[m4/ericb.git] / bootstrap
blob74bced8f28f419ef62843c94ea7dabbb271ac2f5
1 #! /bin/sh
3 # bootstrap (GNU M4) version 2006-09-21
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,
24 # MA 02110-1301, USA.
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}
45 : ${RM=rm -f}
46 : ${SED=sed}
48 dirname="s,/[^/]*$,,"
49 basename="s,^.*/,,g"
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
55 # function.
56 progpath="$0"
58 # The name of this program:
59 progname=`echo "$progpath" | $SED "$basename"`
60 PROGRAM=bootstrap
62 # Detect whether this is a CVS checkout or a tarball
63 CVS_only_file=HACKING
65 # func_echo arg...
66 # Echo program name prefixed message.
67 func_echo ()
69 echo $progname: ${1+"$@"}
73 # func_error arg...
74 # Echo program name prefixed message to standard error.
75 func_error ()
77 echo $progname: ${1+"$@"} >&2
80 # func_fatal_error arg...
81 # Echo program name prefixed message to standard error, and exit.
82 func_fatal_error ()
84 func_error ${1+"$@"}
85 exit $EXIT_FAILURE
88 # func_verbose arg...
89 # Echo program name prefixed message in verbose mode only.
90 func_verbose ()
92 $opt_verbose && func_error ${1+"$@"}
95 # func_missing_arg argname
96 # Echo program name prefixed message to standard error and set global
97 # exit_cmd.
98 func_missing_arg ()
100 func_error "missing argument for $1"
101 exit_cmd=exit
104 # func_fatal_help arg...
105 # Echo program name prefixed message to standard error, followed by
106 # a help hint, and exit.
107 func_fatal_help ()
109 func_error ${1+"$@"}
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
115 # exit_cmd.
116 func_missing_arg ()
118 func_error "missing argument for $1"
119 exit_cmd=exit
122 # func_usage
123 # Echo short help message to standard output and exit.
124 func_usage ()
126 $SED '/^# Usage:/,/# -h/ {
127 s/^# //; s/^# *$//;
128 s/\$progname/'$progname'/;
130 }; d' < "$progpath"
131 echo
132 echo "run \`$progname --help | more' for full usage"
133 exit $EXIT_SUCCESS
136 # func_help
137 # Echo long help message to standard output and exit.
138 func_help ()
140 $SED '/^# Usage:/,/# Report bugs to/ {
141 s/^# //; s/^# *$//;
142 s/\$progname/'$progname'/;
144 }; d' < "$progpath"
145 exit $EXIT_SUCCESS
148 # func_version
149 # Echo version message to standard output and exit.
150 func_version ()
152 $SED '/^# '$PROGRAM' (GNU /,/# warranty; / {
153 s/^# //; s/^# *$//;
154 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
156 }; d' < "$progpath"
157 exit $EXIT_SUCCESS
160 # func_update
161 # Copy $1 to $2 if it is newer.
162 func_update ()
164 if test -f "$2" && cmp -s "$1" "$2" ; then
165 func_verbose "$2 is up-to-date"
166 else
167 func_echo "copying $1 -> $2"
168 cp "$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.
175 # sed scripts:
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
183 opt="$1"
184 shift
185 case $opt in
186 # Separate optargs to short options:
187 -f|--force) CVS_only_file= ;;
188 -\?|-h) func_usage ;;
189 --help) func_help ;;
190 --version) func_version ;;
191 --) break ;;
192 -*) func_fatal_help "unrecognized option \`$opt'" ;;
193 *) set -- "$opt" ${1+"$@"}; break ;;
194 esac
195 done
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 ## ---------------------------- ##
209 case $GNULIB_TOOL in
210 /* ) gnulibdir=$GNULIB_TOOL ;; # absolute
211 */* ) gnulibdir=`pwd`/$GNULIB_TOOL ;; # relative
212 * ) gnulibdir=`which "$GNULIB_TOOL"` ;; # PATH search
213 esac
215 # Follow symlinks
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
224 case "$linkval" in
225 /* ) gnulibdir="$linkval" ;;
226 * ) gnulibdir=`echo "$gnulibdir" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
227 esac
229 done
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"
240 ## ----------- ##
241 ## Autoreconf. ##
242 ## ----------- ##
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/COPYING COPYING
259 func_update "$gnulibdir"/doc/INSTALL INSTALL
261 exit 0
263 # Local variables:
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: "$"
268 # End: