Get rid of the last 'differs in signedness' compiler warnings:
[m4/ericb.git] / bootstrap
blob3bdeafe7115b4e1a6ab894c76da17058f5441d1e
1 #! /bin/sh
3 # bootstrap (GNU M4) version 2007-03-24
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 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 # -p ARG --download-po=ARG whether to download pofiles [yes]
30 # -v --version print version information
31 # -h,-? --help print short or long help message
33 # For --download-po, ARG can also be `no' to skip pofile downloads,
34 # `only' to just update pofiles, or a set of locales to add or update.
36 # You can also set the following variables to help $progname
37 # locate the right tools:
38 # AUTOPOINT, AUTORECONF, AWK, GNULIB_TOOL, M4, RM, SED, WGET
40 # This script bootstraps a CVS checkout of GNU M4 by correctly calling
41 # out to parts of the GNU Build Platform. Currently this requires GNU
42 # Gettext 0.16 or better, Autoconf 2.60 or better, GNU M4 1.4.x or
43 # better, a CVS snapshot of Automake 1.10a or better, a CVS snapshot
44 # of Libtool 2.1a or better, and the latest CVS checkout of Gnulib.
45 # Libtool must be installed; either with the same --prefix as
46 # automake, or made accessible to aclocal's search path via
47 # $AUTOMAKE_prefix/share/aclocal/dirlist.
49 # Report bugs to <bug-m4@gnu.org>
51 : ${AUTOPOINT=autopoint}
52 : ${AUTORECONF=autoreconf}
53 : ${AWK=awk}
54 : ${GNULIB_TOOL=gnulib-tool}
55 : ${M4=m4}
56 : ${RM=rm -f}
57 : ${SED=sed}
58 : ${WGET=wget}
59 export WGET
61 : ${DOWNLOAD_PO=yes}
63 # Translation Project URL, for the registry of all projects.
64 TP_URL="http://www.iro.umontreal.ca/translation/registry.cgi?domain="
66 # Ensure file names are sorted consistently across platforms.
67 # Also, ensure diagnostics are in English, e.g., "wget --help" below.
68 LC_ALL=C
69 export LC_ALL
71 package=m4
72 ltdldir=ltdl
73 config_aux_dir=$ltdldir/config
74 config_macro_dir=$ltdldir/m4
75 bailout_cb=:
77 # List dependencies here too; we don't extract them, otherwise dependent
78 # modules could end up being imported to src/ *and* gnu/!
79 src_modules='getopt version-etc-fsf version-etc'
81 dirname="s,/[^/]*$,,"
82 basename="s,^.*/,,g"
84 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
85 # is ksh but when the shell is invoked as "sh" and the current value of
86 # the _XPG environment variable is not equal to 1 (one), the special
87 # positional parameter $0, within a function call, is the name of the
88 # function.
89 progpath="$0"
91 # The name of this program:
92 progname=`echo "$progpath" | $SED "$basename"`
93 PROGRAM=bootstrap
95 # Detect whether this is a CVS checkout or a tarball
96 CVS_only_file=HACKING
98 # func_echo arg...
99 # Echo program name prefixed message.
100 func_echo ()
102 echo $progname: ${1+"$@"}
105 # func_error arg...
106 # Echo program name prefixed message to standard error.
107 func_error ()
109 echo $progname: ${1+"$@"} >&2
112 # func_fatal_error arg...
113 # Echo program name prefixed message to standard error, and exit.
114 func_fatal_error ()
116 func_error ${1+"$@"}
117 exit $EXIT_FAILURE
120 # func_verbose arg...
121 # Echo program name prefixed message in verbose mode only.
122 func_verbose ()
124 $opt_verbose && func_error ${1+"$@"}
127 # func_missing_arg argname
128 # Echo program name prefixed message to standard error and set global
129 # exit_cmd.
130 func_missing_arg ()
132 func_error "missing argument for $1"
133 exit_cmd=exit
136 # func_fatal_help arg...
137 # Echo program name prefixed message to standard error, followed by
138 # a help hint, and exit.
139 func_fatal_help ()
141 func_error ${1+"$@"}
142 func_fatal_error "Try \`$progname --help' for more information."
145 # func_missing_arg argname
146 # Echo program name prefixed message to standard error and set global
147 # exit_cmd.
148 func_missing_arg ()
150 func_error "missing argument for $1"
151 exit_cmd=exit
154 # func_usage
155 # Echo short help message to standard output and exit.
156 func_usage ()
158 $SED '/^# Usage:/,/# -h/ {
159 s/^# //; s/^# *$//;
160 s/\$progname/'$progname'/;
162 }; d' < "$progpath"
163 echo
164 echo "run \`$progname --help | more' for full usage"
165 exit $EXIT_SUCCESS
168 # func_help
169 # Echo long help message to standard output and exit.
170 func_help ()
172 $SED '/^# Usage:/,/# Report bugs to/ {
173 s/^# //; s/^# *$//;
174 s/\$progname/'$progname'/;
176 }; d' < "$progpath"
177 exit $EXIT_SUCCESS
180 # func_version
181 # Echo version message to standard output and exit.
182 func_version ()
184 $SED '/^# '$PROGRAM' (GNU /,/# warranty; / {
185 s/^# //; s/^# *$//;
186 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
188 }; d' < "$progpath"
189 exit $EXIT_SUCCESS
192 # Parse options once, thoroughly. This comes as soon as possible in
193 # the script to make things like `commit --version' happen quickly.
195 # sed scripts:
196 my_sed_single_opt='1s/^\(..\).*$/\1/;q'
197 my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
198 my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
199 my_sed_long_arg='1s/^--[^=]*=//'
201 # this just eases exit handling
202 while test $# -gt 0; do
203 opt="$1"
204 shift
205 case $opt in
206 -f|--force)
207 CVS_only_file=
210 -p|--download-po)
211 test $# = 0 && func_missing_arg $opt && break
212 case $1 in
213 0|[Nn]*|[Ff]*) DOWNLOAD_PO=no ;;
214 [Oo]*) DOWNLOAD_PO=only ;;
215 esac
218 # Separate optargs to long options:
219 --download-po=*)
220 arg=`echo "$opt" | $SED "$my_sed_long_arg"`
221 opt=`echo "$opt" | $SED "$my_sed_long_opt"`
222 set -- "$opt" "$arg" ${1+"$@"}
225 # Separate optargs to short options:
226 -p*)
227 arg=`echo "$opt" |$SED "$my_sed_single_rest"`
228 opt=`echo "$opt" |$SED "$my_sed_single_opt"`
229 set -- "$opt" "$arg" ${1+"$@"}
232 -\?|-h) func_usage ;;
233 --help) func_help ;;
234 --version) func_version ;;
235 --) break ;;
236 -*) func_fatal_help "unrecognized option \`$opt'" ;;
237 *) set -- "$opt" ${1+"$@"}; break ;;
238 esac
239 done
241 # Bail if the options were screwed
242 $exit_cmd $EXIT_FAILURE
244 if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then
245 func_fatal_error "Bootstrapping from a non-CVS distribution is risky."
249 ## ------------------------------ ##
250 ## Fetch translations. ##
251 ## (taken from GNU tar bootstrap) ##
252 ## ------------------------------ ##
254 func_get_translations()
256 subdir=$1
257 domain=$2
258 po_file=$3
260 func_echo "getting translations into $subdir for $domain..."
262 case $po_file in
263 '') (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`);;
264 esac &&
266 $WGET -nv --cache=off -O "$subdir/$domain.html" "$TP_URL$domain" &&
268 $SED -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" |
269 sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
270 $AWK -F. '
271 { if (lang && $1 != lang) print lang, ver }
272 { lang = $1; ver = substr($0, index($0, ".") + 1) }
273 END { if (lang) print lang, ver }
275 $AWK -v domain="$domain" -v po_file="$po_file" -v subdir="$subdir" '
277 lang = $1
278 if (po_file == (lang ".po")) next
280 ver = $2
281 urlfmt = ""
282 printf "$WGET -nv --cache=off -O %s/%s.po 'http://www.iro.umontreal.ca/translation/teams/PO/%s/%s-%s.%s.po' &&\n", subdir, lang, lang, domain, ver, lang
284 END { print ":" }
286 sh &&
287 ls "$subdir"/*.po | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
288 rm "$subdir/$domain.html"
291 ## ------------------------------ ##
292 ## Update translations. ##
293 ## (taken from GNU tar bootstrap) ##
294 ## ------------------------------ ##
296 func_update_po ()
298 if test $# = 1; then
299 case $1 in
300 *.po) POFILE=$1 ;;
301 *) POFILE=$1.po ;;
302 esac
303 func_get_translations ./po $package "$POFILE" &&
304 LANG=`expr $POFILE : '\(.*\)\.po'` &&
305 { grep -q $LANG po/LINGUAS ||
306 (echo $LANG; cat po/LINGUAS) | sort -o po/LINGUAS; }
307 else
308 func_get_translations ./po $package
312 case $DOWNLOAD_PO in
313 no) ;;
314 only) func_update_po; exit 0 ;;
315 yes) func_update_po ;;
316 *) func_update_po $DOWNLOAD_PO ;;
317 esac
319 ## ---------------- ##
320 ## Version control. ##
321 ## ---------------- ##
323 # gnulib-tool updates ltdl/m4/.cvsignore and gnu/.cvsignore, and keeping
324 # generated files under version control does not make sense. Prepopulate
325 # ltdl/m4's version with generated files not tracked by gnulib-tool.
326 if test -f $config_macro_dir/.cvsignore ; then
328 else
329 func_echo "creating initial $config_macro_dir/.cvsignore"
330 cat > $config_macro_dir/.cvsignore <<\EOF
332 .cvsignore
333 argz.m4
334 codeset.m4
335 getopt.m4
336 gettext.m4
337 glibc2.m4
338 glibc21.m4
339 gnulib-comp.m4
340 iconv.m4
341 intdiv0.m4
342 intl.m4
343 intldir.m4
344 intmax.m4
345 inttypes-pri.m4
346 inttypes_h.m4
347 lcmessage.m4
348 lib-ld.m4
349 lib-link.m4
350 lib-prefix.m4
351 libtool.m4
352 lock.m4
353 longdouble.m4
354 longlong.m4
355 ltdl.m4
356 ltoptions.m4
357 ltsugar.m4
358 ltversion.m4
359 lt~obsolete.m4
360 nls.m4
361 po.m4
362 printf-posix.m4
363 progtest.m4
364 size_max.m4
365 stdint_h.m4
366 uintmax_t.m4
367 ulonglong.m4
368 visibility.m4
369 wchar_t.m4
370 wint_t.m4
371 xsize.m4
375 ## ---------- ##
376 ## Autopoint. ##
377 ## ---------- ##
379 # Released autopoint has the tendency to install macros that have been
380 # obsoleted in current gnulib, so run this before gnulib-tool.
381 func_echo "running: $AUTOPOINT --force"
382 $AUTOPOINT --force
384 ## ---------------------------- ##
385 ## Find the gnulib module tree. ##
386 ## ---------------------------- ##
388 case $GNULIB_TOOL in
389 /* ) gnulibdir=$GNULIB_TOOL ;; # absolute
390 */* ) gnulibdir=`pwd`/$GNULIB_TOOL ;; # relative
391 * ) gnulibdir=`which "$GNULIB_TOOL"` ;; # PATH search
392 esac
394 # Follow symlinks
395 while test -h "$gnulibdir"; do
397 # Resolve symbolic link.
398 sedexpr1='s, -> ,#%%#,'
399 sedexpr2='s,^.*#%%#\(.*\)$,\1,p'
400 linkval=`ls -l "$gnulibdir" | $SED "$sedexpr1" | $SED -n "$sedexpr2"`
401 test -n "$linkval" || break
403 case "$linkval" in
404 /* ) gnulibdir="$linkval" ;;
405 * ) gnulibdir=`echo "$gnulibdir" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
406 esac
408 done
410 gnulibdir=`echo "$gnulibdir" | $SED "$dirname"`
413 ## ---------------------- ##
414 ## Import Gnulib modules. ##
415 ## ---------------------- ##
417 func_echo "running: ${GNULIB_TOOL} --update"
418 ${GNULIB_TOOL} --update
421 ## --------------------------------- ##
422 ## Copy additional src only modules. ##
423 ## --------------------------------- ##
425 func_echo "fetching modules for src directory"
427 for file in `${GNULIB_TOOL} --extract-filelist $src_modules`; do
429 dest=`echo $file | $SED "$basename"`
430 case $file in
431 lib/*) dest=src/$dest ;;
432 m4/*) dest=$config_macro_dir/$dest ;;
433 *) func_echo "Unknown file: $file"
434 exit 1
436 esac
438 # Be sure to show all copying errors before bailing out
439 if test -f $gnulibdir/$file; then
440 func_echo "copying file \`$dest'"
441 cp $gnulibdir/$file $dest
442 else
443 func_error "$gnulibdir/$file does not exist"
444 bailout_cb="exit 1"
446 done
447 $bailout_cb
450 ## ----------- ##
451 ## Autoreconf. ##
452 ## ----------- ##
454 # Disable autopoint, since it was already done above.
455 func_echo "running: AUTOPOINT=true" \
456 "$AUTORECONF --force --verbose --install --no-recursive"
457 AUTOPOINT=true $AUTORECONF --force --verbose --install --no-recursive
460 ## ------- ##
461 ## Wrapup. ##
462 ## ------- ##
464 if test x"$DOWNLOAD_PO" != xno; then
465 func_echo "If your pofiles are up-to-date, you can rerun bootstrap"
466 func_echo "as \`DOWNLOAD_PO=no $progname' to avoid redownloading."
469 exit 0
471 # Local variables:
472 # eval: (add-hook 'write-file-hooks 'time-stamp)
473 # time-stamp-start: "# bootstrap (GNU M4) version "
474 # time-stamp-format: "%:y-%02m-%02d"
475 # time-stamp-end: "$"
476 # End: