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