]> git.saurik.com Git - bison.git/blame - bootstrap
* bootstrap (cleanup_gnulib): New function. Use it to clean up
[bison.git] / bootstrap
CommitLineData
01c56de4
AD
1#! /bin/sh
2
1f65350a 3# Bootstrap this package from CVS.
01c56de4 4
727e8b0b 5# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
1f65350a
PE
6
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2, or (at your option)
10# any later version.
11
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
0fb669f9
PE
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20# 02110-1301, USA.
1f65350a
PE
21
22# Written by Paul Eggert.
23
24package=bison
25
a9f027b9
PE
26# Ensure file names are sorted consistently across platforms;
27# e.g., m4/ulonglong_gl.m4 should follow m4/ulonglong.m4.
b5240ba5 28# Also, ensure diagnostics are in English, e.g., "wget --help" below.
a9f027b9
PE
29LC_ALL=C
30export LC_ALL
31
1f65350a
PE
32# Parse options.
33
34for option
35do
36 case $option in
37 --help)
38 echo "$0: usage: $0 [--gnulib-srcdir=DIR] [--cvs-user=USERNAME] [--skip-po]"
39 exit;;
40 --gnulib-srcdir=*)
e23d0dd7 41 GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
1f65350a 42 --cvs-user=*)
e23d0dd7 43 CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
1f65350a
PE
44 --skip-po)
45 SKIP_PO=t;;
46 *)
47 echo >&2 "$0: $option: unknown option"
48 exit 1;;
49 esac
50done
51
52echo "$0: Bootstrapping CVS $package..."
53
54build_cvs_prefix() {
55 CVS_PREFIX=:${1}:
56 if [ "${2}" != - ]; then
57 CVS_PREFIX=${CVS_PREFIX}${2}@
58 fi
59}
60
e10a80ee
PE
61cleanup_gnulib() {
62 status=$?
63 rm -fr gnulib
64 exit $status
65}
66
1f65350a
PE
67# Get gnulib files.
68
69case ${GNULIB_SRCDIR--} in
70-)
71 if [ ! -d gnulib ]; then
72 echo "$0: getting gnulib files..."
73
1f65350a
PE
74 case ${CVS_AUTH-anoncvs} in
75 anoncvs)
76 CVS_PREFIX='anoncvs@';;
77 ssh)
78 CVS_PREFIX="$CVS_USER${CVS_USER+@}";;
79 *)
80 echo "$0: $CVS_AUTH: Unknown CVS access method" >&2
81 exit 1;;
82 esac
83
84 case $CVS_RSH in
85 '') export CVS_RSH=ssh;;
86 esac
87
e10a80ee
PE
88 trap cleanup_gnulib 1 2 13 15
89
90 cvs -z3 -q -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/gnulib co gnulib ||
91 cleanup_gnulib
1f65350a 92
e10a80ee 93 trap - 1 2 13 15
1f65350a
PE
94 fi
95 GNULIB_SRCDIR=gnulib
96esac
97
98<$GNULIB_SRCDIR/gnulib-tool || exit
99
100gnulib_modules='
1f65350a
PE
101argmatch
102dirname
103error
42e826a4 104extensions
1f65350a 105getopt
c3d5a4a7 106gettext
1f65350a
PE
107hard-locale
108hash
109malloc
110mbswidth
111obstack
112quote
113quotearg
114stdbool
3ea5f0ec 115stdio-safer
1f65350a 116stpcpy
55f0c7b1
PE
117strerror
118strtoul
b50d2359 119strverscmp
3ea5f0ec 120unistd-safer
fb9c0b33 121unlocked-io
8a6f72f3 122verify
1f65350a 123xalloc
a9f027b9 124xalloc-die
1f65350a
PE
125xstrndup
126'
127
128previous_gnulib_modules=
129while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
130 previous_gnulib_modules=$gnulib_modules
131 gnulib_modules=`
132 (echo "$gnulib_modules"
133 for gnulib_module in $gnulib_modules; do
134 $GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module
135 done) | sort -u
136 `
137done
138
139gnulib_files=`
140 (for gnulib_module in $gnulib_modules; do
141 $GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
142 done) | sort -u
143`
144
145gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
146mkdir -p $gnulib_dirs || exit
147
148for gnulib_file in $gnulib_files; do
149 dest=$gnulib_file
150
151 case $gnulib_file in
152 m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
a9f027b9
PE
153 # These will be overwritten by autopoint, which still uses
154 # old jm_.* macro names, so we have to keep both copies.
155 # m4/gettext.m4 isn't mentioned here, since it's patched below.
156 m4/glibc21.m4 | m4/inttypes_h.m4 | m4/lib-ld.m4 | \
157 m4/lib-prefix.m4 | m4/po.m4 | m4/stdint_h.m4 | m4/uintmax_t.m4 | \
158 m4/ulonglong.m4)
159 dest=`expr $gnulib_file : '\(.*\).m4'`_gl.m4;;
1f65350a
PE
160 esac
161
162 rm -f $dest &&
163 echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
164 cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
165done
166
7e7b77c1
PE
167# This suppresses a bogus diagnostic
168# "warning: macro `AM_LANGINFO_CODESET' not found in library".
169echo "$0: patching m4/gettext.m4 so that AM_INTL_SUBDIR is empty ..."
170sed '
171 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
172 AC_DEFUN([AM_INTL_SUBDIR], [])
173' m4/gettext.m4 >m4/gettext_gl.m4 || exit
174
1f65350a
PE
175
176# Get translations.
177
178case $SKIP_PO in
179'')
b5240ba5
PE
180 case `wget --help` in
181 *'--no-cache'*)
182 no_cache='--no-cache';;
183 *'--cache=on/off'*)
184 no_cache='--cache=off';;
185 *)
186 no_cache='';;
187 esac
188
6712933e 189 echo "$0: getting translations into po (please ignore the robots.txt ERROR 404)..."
1f65350a
PE
190 (cd po &&
191 rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
b5240ba5 192 wget -nv -nd -r -l 1 -A .po $no_cache \
ff498c4a 193 http://www.iro.umontreal.ca/translation/maint/$package/ &&
1f65350a 194 ls *.po | sed 's/\.po$//' >LINGUAS
f7ab6a50
PE
195 ) || exit
196
197 case $package in
198 bison)
199 echo "$0: getting translations into po (please ignore the robots.txt ERROR 404)..."
200 (cd runtime-po &&
201 rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po$/p'` &&
b5240ba5 202 wget -nv -nd -r -l 1 -A .po $no_cache \
f7ab6a50 203 http://www.iro.umontreal.ca/translation/maint/$package-runtime/ &&
4ff8b7f7
PE
204
205 # For translations that have not yet been upgraded to the new
206 # runtime-po domain, prime the pump by extracting the relevant
207 # strings from the obsolete translations.
208 # This code can be removed once the bison-runtime domain
209 # has been translated by each team.
210 for po in ../po/*.po; do
211 test -f "$po" || continue
212 runpo=`basename $po`
213 test -f $runpo || {
214 msggrep -K \
215 -e 'memory exhausted' \
216 -e 'syntax error' \
217 $po 2>/dev/null |
218 sed '
219 s/^#~ //
220 /^msgid "syntax error; also memory exhausted"$/,/^$/d
221 /^$/,${ /^#/d; }
222 ' >$runpo-
223 if cmp -s $runpo- $runpo; then
224 rm $runpo-
225 else
226 mv $runpo- $runpo
227 fi
228 test -s $runpo || rm -f $runpo
229 } || exit
230 done &&
231
f7ab6a50
PE
232 ls *.po | sed 's/\.po$//' >LINGUAS
233 ) || exit
234 esac;;
1f65350a
PE
235esac
236
237
238# Generate autoconf and automake snippets.
239
240(echo '# This file is generated automatically by "bootstrap".' &&
241 echo 'AC_DEFUN([GNULIB_AUTOCONF_SNIPPET],[' &&
242 $GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_modules &&
243 echo '])'
244) >m4/gnulib.m4 || exit
245
246(echo '# This file is generated automatically by "bootstrap".' &&
247 $GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_modules
248) >lib/gnulib.mk || exit
249
250
251# Reconfigure, getting other files.
252
253echo "$0: autoreconf --verbose --install --force ..."
254autoreconf --verbose --install --force || exit
255
e23d0dd7 256
1f65350a 257# We don't need intl, so remove it.
e23d0dd7
PE
258# Remove aclocal.m4 too, so that it gets rebuilt.
259intl_files_to_remove='
260 aclocal.m4
261 intl
262 m4/codeset.m4
a9f027b9 263 m4/gettext.m4
3ea5f0ec 264 m4/glibc2.m4
e23d0dd7
PE
265 m4/glibc21.m4
266 m4/intdiv0.m4
267 m4/intmax.m4
268 m4/inttypes_h.m4
269 m4/inttypes.m4
270 m4/inttypes-pri.m4
271 m4/isc-posix.m4
272 m4/lcmessage.m4
a9f027b9
PE
273 m4/lib-ld.m4
274 m4/lib-prefix.m4
e23d0dd7
PE
275 m4/longdouble.m4
276 m4/longlong.m4
a9f027b9 277 m4/po.m4
e23d0dd7
PE
278 m4/printf-posix.m4
279 m4/signed.m4
280 m4/size_max.m4
281 m4/stdint_h.m4
282 m4/uintmax_t.m4
283 m4/ulonglong.m4
284 m4/wchar_t.m4
285 m4/wint_t.m4
286 m4/xsize.m4
287'
288echo $0: rm -fr $intl_files_to_remove ...
289rm -fr $intl_files_to_remove || exit
290
1f65350a
PE
291# Put bug-reporting address into po/Makevars.
292echo "$0: sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-bison@gnu.org/' po/Makevars.template >po/Makevars ..."
293sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-bison@gnu.org/' po/Makevars.template >po/Makevars
294
f7ab6a50
PE
295# Likewise for runtime-po/Makevars, except also change a few other parameters.
296sed '
297 s/^\(DOMAIN\) *=.*/\1 = bison-runtime/
298 s/^\(subdir\) *=.*/\1 = runtime-po/
30757c8c 299 s/^\(XGETTEXT_OPTIONS\) *=.*/\1 = --keyword=YY_/
f7ab6a50
PE
300' <po/Makevars >runtime-po/Makevars
301
302# Copy identical files from po to runtime-po.
30757c8c 303(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
1f65350a
PE
304
305# if src/parse-gram.[ch] are out of date, rebuild them.
b9c85d5c 306parse_gram_y=`find src/parse-gram.y \
1f65350a 307 '(' -newer src/parse-gram.c -o -newer src/parse-gram.h ')' \
b9c85d5c 308 -print` || exit
1f65350a
PE
309case $parse_gram_y in
310?*)
311 echo "$0: warning: bootstrapping with old src/parse-gram.[ch] files."
312
313 echo "$0: touch -c src/parse-gram.[ch] ... "
314 touch -c src/parse-gram.[ch] || exit
315
316 echo "$0: ./configure --disable-nls ..."
317 ./configure --disable-nls || exit
318
319 echo "$0: (cd lib && make) ..."
320 (cd lib && make) || exit
321
322 echo "$0: (cd src && make) ..."
323 (cd src && make) || exit
324
325 echo "$0: rm -f src/parse-gram.c src/parse-gram.h ..."
326 rm -f src/parse-gram.c src/parse-gram.h || exit
327
328 echo "$0: (cd src && make parse-gram.c parse-gram.h) ..."
329 (cd src && make parse-gram.c parse-gram.h) || exit
330
331 echo "$0: make distclean ..."
332 make distclean || exit;;
333esac
334
335echo "$0: done. Now you can run './configure'."