3 # bootstrap (GNU M4) version 2006-07-17
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 # -p ARG --download-po=ARG whether to download pofiles [yes]
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, AWK, GNULIB_TOOL, RM, SED, WGET
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 the latest releases of GNU Gettext and Autoconf, and
39 # bleeding edge CVS snapshots of GNU Automake, Libtool & Gnulib.
41 # Report bugs to <bug-m4@gnu.org>
43 : ${AUTORECONF=autoreconf}
45 : ${GNULIB_TOOL=gnulib-tool}
53 config_aux_dir
=$ltdldir/config
54 config_macro_dir
=$ltdldir/m4
57 # List dependencies here too; we don't extract them, otherwise dependent
58 # modules could end up being imported to src/ *and* gnu/!
59 src_modules
='getopt version-etc-fsf version-etc'
64 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
65 # is ksh but when the shell is invoked as "sh" and the current value of
66 # the _XPG environment variable is not equal to 1 (one), the special
67 # positional parameter $0, within a function call, is the name of the
71 # The name of this program:
72 progname
=`echo "$progpath" | $SED "$basename"`
76 # Echo program name prefixed message.
79 echo $progname: ${1+"$@"}
83 # Echo program name prefixed message to standard error.
86 echo $progname: ${1+"$@"} >&2
89 # func_fatal_error arg...
90 # Echo program name prefixed message to standard error, and exit.
98 # Echo program name prefixed message in verbose mode only.
101 $opt_verbose && func_error
${1+"$@"}
104 # func_missing_arg argname
105 # Echo program name prefixed message to standard error and set global
109 func_error
"missing argument for $1"
113 # func_fatal_help arg...
114 # Echo program name prefixed message to standard error, followed by
115 # a help hint, and exit.
119 func_fatal_error
"Try \`$progname --help' for more information."
122 # func_missing_arg argname
123 # Echo program name prefixed message to standard error and set global
127 func_error
"missing argument for $1"
132 # Echo short help message to standard output and exit.
135 $SED '/^# Usage:/,/# -h/ {
137 s/\$progname/'$progname'/;
141 echo "run \`$progname --help | more' for full usage"
146 # Echo long help message to standard output and exit.
149 $SED '/^# Usage:/,/# Report bugs to/ {
151 s/\$progname/'$progname'/;
158 # Echo version message to standard output and exit.
161 $SED '/^# '$PROGRAM' (GNU /,/# warranty; / {
163 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
169 # Parse options once, thoroughly. This comes as soon as possible in
170 # the script to make things like `commit --version' happen quickly.
173 my_sed_single_opt
='1s/^\(..\).*$/\1/;q'
174 my_sed_single_rest
='1s/^..\(.*\)$/\1/;q'
175 my_sed_long_opt
='1s/^\(--[^=]*\)=.*/\1/;q'
176 my_sed_long_arg
='1s/^--[^=]*=//'
178 # this just eases exit handling
179 while test $# -gt 0; do
184 test $# = 0 && func_missing_arg
$opt && break
186 0|
[Nn
]*|
[Ff
]*) DOWNLOAD_PO
=no
;;
187 [Oo
]*) DOWNLOAD_PO
=only
;;
191 # Separate optargs to long options:
193 arg
=`echo "$opt" | $SED "$my_sed_long_arg"`
194 opt
=`echo "$opt" | $SED "$my_sed_long_opt"`
195 set -- "$opt" "$arg" ${1+"$@"}
198 # Separate optargs to short options:
200 arg
=`echo "$opt" |$SED "$my_sed_single_rest"`
201 opt
=`echo "$opt" |$SED "$my_sed_single_opt"`
202 set -- "$opt" "$arg" ${1+"$@"}
205 -\?|
-h) func_usage
;;
207 --version) func_version
;;
209 -*) func_fatal_help
"unrecognized option \`$opt'" ;;
210 *) set -- "$opt" ${1+"$@"}; break ;;
214 if test -z "$sendmail_to"; then
216 # can't have a from address without a destination address
217 test -n "$sendmail_from" &&
218 func_error
"can't use --from without --sendmail." && exit_cmd
=exit
220 # can't use a signature file without a destination address
221 test -n "$signature_file" &&
222 func_error
"can't use --signature without --sendmail." && exit_cmd
=exit
225 # Bail if the options were screwed
226 $exit_cmd $EXIT_FAILURE
229 ## ------------------------------ ##
230 ## Fetch translations. ##
231 ## (taken from GNU tar bootstrap) ##
232 ## ------------------------------ ##
234 TP_URL
="http://www.iro.umontreal.ca/translation/maint/m4/"
243 func_echo
"getting translation for $1..."
244 $WGET -r --cache=off
$TP_URL/$POFILE
246 func_echo
"getting translations into po..."
248 rm -f dummy
`ls | sed -n '/\.gmo$/p; /\.po/p'` &&
249 $WGET -nv -nd -r -l 1 -A .po
--cache=off
$TP_URL &&
250 rm -f index.html index.html.
[0-9]*
251 ls *.po |
sed 's/\.po$//' > LINGUAS
258 only
) func_update_po
; exit 0 ;;
259 yes) func_update_po
;;
260 *) func_update_po
$DOWNLOAD_PO ;;
263 ## ---------------------------- ##
264 ## Find the gnulib module tree. ##
265 ## ---------------------------- ##
268 /* ) gnulibdir
=$GNULIB_TOOL ;; # absolute
269 */* ) gnulibdir
=`pwd`/$GNULIB_TOOL ;; # relative
270 * ) gnulibdir
=`which "$GNULIB_TOOL"` ;; # PATH search
274 while test -h "$gnulibdir"; do
276 # Resolve symbolic link.
277 sedexpr1
='s, -> ,#%%#,'
278 sedexpr2
='s,^.*#%%#\(.*\)$,\1,p'
279 linkval
=`LC_ALL=C ls -l "$gnulibdir" | $SED "$sedexpr1" | $SED -n "$sedexpr2"`
280 test -n "$linkval" ||
break
283 /* ) gnulibdir
="$linkval" ;;
284 * ) gnulibdir
=`echo "$gnulibdir" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
289 gnulibdir
=`echo "$gnulibdir" | $SED "$dirname"`
292 ## ---------------------- ##
293 ## Import Gnulib modules. ##
294 ## ---------------------- ##
296 func_echo
"running: ${GNULIB_TOOL} --update"
297 ${GNULIB_TOOL} --update
299 func_echo
"patching include directories in gnulib regex module"
300 mv $config_macro_dir/regex.
m4 $config_macro_dir/regex-m4.old
301 sed 's,lib/regex.c,gnu/regex.c,g' $config_macro_dir/regex-m4.old
> $config_macro_dir/regex.
m4 && \
302 $RM $config_macro_dir/regex-m4.old
304 func_echo
"hiding gnulib jm_\* macros"
305 cat >> $config_macro_dir/gnulib.
m4 <<\EOF
306 AC_DEFUN
([gl_AC_HEADER_INTTYPES_H
], [jm_AC_HEADER_INTTYPES_H
])
307 AC_DEFUN
([gl_AC_HEADER_STDINT_H
], [jm_AC_HEADER_STDINT_H
])
308 AC_DEFUN
([gl_AC_TYPE_UINTMAX_T
], [jm_AC_TYPE_UINTMAX_T
])
312 ## --------------------------------- ##
313 ## Copy additional src only modules. ##
314 ## --------------------------------- ##
316 func_echo
"fetching modules for src directory"
318 for file in `${GNULIB_TOOL} --extract-filelist $src_modules`; do
320 dest
=`echo $file | $SED "$basename"`
322 lib
/*) dest
=src
/$dest ;;
323 m
4/*) dest
=$config_macro_dir/$dest ;;
324 *) func_echo
"Unknown file: $file"
329 # Be sure to show all copying errors before bailing out
330 if test -f $gnulibdir/$file; then
331 func_echo
"copying file \`$dest'"
332 cp $gnulibdir/$file $dest
334 func_error
"$gnulibdir/$file does not exist"
345 func_echo
"running: $AUTORECONF --force --verbose --install --no-recursive"
346 $AUTORECONF --force --verbose --install --no-recursive
354 func_echo
"generating testsuite"
356 $AWK -f .
/generate.
awk ..
/doc
/m4.texinfo
> generated.
at
359 if test x
"$DOWNLOAD_PO" != xno
; then
360 func_echo
"If your pofiles are uptodate, you can rerun bootstrap"
361 func_echo
"as \`DOWNLOAD_PO=no $progname' to avoid redownloading."
367 # eval: (add-hook 'write-file-hooks 'time-stamp)
368 # time-stamp-start: "# bootstrap (GNU M4) version "
369 # time-stamp-format: "%:y-%02m-%02d"
370 # time-stamp-end: "$"