]>
Commit | Line | Data |
---|---|---|
1 | #! /bin/sh | |
2 | ||
3 | # Bootstrap this package from CVS. | |
4 | ||
5 | # Copyright (C) 2003, 2004, 2005, 2006 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 | # Translation Project URL, for the registry of all projects. | |
27 | TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain=' | |
28 | ||
29 | # Ensure file names are sorted consistently across platforms; | |
30 | # e.g., m4/ulonglong_gl.m4 should follow m4/ulonglong.m4. | |
31 | # Also, ensure diagnostics are in English, e.g., "wget --help" below. | |
32 | LC_ALL=C | |
33 | export LC_ALL | |
34 | ||
35 | # Parse options. | |
36 | ||
37 | for option | |
38 | do | |
39 | case $option in | |
40 | --help) | |
41 | echo "$0: usage: $0 [--gnulib-srcdir=DIR] [--cvs-user=USERNAME] [--skip-po]" | |
42 | exit;; | |
43 | --gnulib-srcdir=*) | |
44 | GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;; | |
45 | --cvs-user=*) | |
46 | CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;; | |
47 | --skip-po) | |
48 | SKIP_PO=t;; | |
49 | *) | |
50 | echo >&2 "$0: $option: unknown option" | |
51 | exit 1;; | |
52 | esac | |
53 | done | |
54 | ||
55 | echo "$0: Bootstrapping CVS $package..." | |
56 | ||
57 | cleanup_gnulib() { | |
58 | status=$? | |
59 | rm -fr gnulib | |
60 | exit $status | |
61 | } | |
62 | ||
63 | # Get gnulib files. | |
64 | ||
65 | case ${GNULIB_SRCDIR--} in | |
66 | -) | |
67 | if [ ! -d gnulib ]; then | |
68 | echo "$0: getting gnulib files..." | |
69 | ||
70 | case ${CVS_AUTH-pserver} in | |
71 | pserver) | |
72 | CVS_PREFIX=':pserver:anonymous@';; | |
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 | trap cleanup_gnulib 1 2 13 15 | |
85 | ||
86 | cvs -z3 -q -d ${CVS_PREFIX}cvs.savannah.gnu.org:/cvsroot/gnulib co gnulib || | |
87 | cleanup_gnulib | |
88 | ||
89 | trap - 1 2 13 15 | |
90 | fi | |
91 | GNULIB_SRCDIR=gnulib | |
92 | esac | |
93 | ||
94 | <$GNULIB_SRCDIR/gnulib-tool || exit | |
95 | ||
96 | gnulib_modules=' | |
97 | argmatch | |
98 | dirname | |
99 | error | |
100 | extensions | |
101 | getopt | |
102 | gettext | |
103 | hard-locale | |
104 | hash | |
105 | malloc | |
106 | mbswidth | |
107 | obstack | |
108 | quote | |
109 | quotearg | |
110 | stdbool | |
111 | stdio-safer | |
112 | stpcpy | |
113 | strerror | |
114 | strtoul | |
115 | strverscmp | |
116 | unistd-safer | |
117 | unlocked-io | |
118 | verify | |
119 | xalloc | |
120 | xalloc-die | |
121 | xstrndup | |
122 | ' | |
123 | ||
124 | previous_gnulib_modules= | |
125 | while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do | |
126 | previous_gnulib_modules=$gnulib_modules | |
127 | gnulib_modules=` | |
128 | (echo "$gnulib_modules" | |
129 | for gnulib_module in $gnulib_modules; do | |
130 | $GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module | |
131 | done) | sort -u | |
132 | ` | |
133 | done | |
134 | ||
135 | gnulib_files=` | |
136 | (for gnulib_module in $gnulib_modules; do | |
137 | $GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module | |
138 | done) | sort -u | |
139 | ` | |
140 | ||
141 | gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u` | |
142 | mkdir -p $gnulib_dirs || exit | |
143 | ||
144 | for gnulib_file in $gnulib_files; do | |
145 | dest=$gnulib_file | |
146 | ||
147 | case $gnulib_file in | |
148 | m4/onceonly_2_57.m4) dest=m4/onceonly.m4;; | |
149 | # These will be overwritten by autopoint, which still uses | |
150 | # old jm_.* macro names, so we have to keep both copies. | |
151 | # m4/gettext.m4 isn't mentioned here, since it's patched below. | |
152 | m4/glibc21.m4 | m4/inttypes_h.m4 | m4/lib-ld.m4 | \ | |
153 | m4/lib-prefix.m4 | m4/po.m4 | m4/stdint_h.m4 | m4/uintmax_t.m4 | \ | |
154 | m4/ulonglong.m4) | |
155 | dest=`expr $gnulib_file : '\(.*\).m4'`_gl.m4;; | |
156 | esac | |
157 | ||
158 | rm -f $dest && | |
159 | echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" && | |
160 | cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit | |
161 | done | |
162 | ||
163 | # This suppresses a bogus diagnostic | |
164 | # "warning: macro `AM_LANGINFO_CODESET' not found in library". | |
165 | echo "$0: patching m4/gettext.m4 so that AM_INTL_SUBDIR is empty ..." | |
166 | sed ' | |
167 | /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\ | |
168 | AC_DEFUN([AM_INTL_SUBDIR], []) | |
169 | ' m4/gettext.m4 >m4/gettext_gl.m4 || exit | |
170 | ||
171 | ||
172 | # Get translations. | |
173 | ||
174 | get_translations() { | |
175 | subdir=$1 | |
176 | domain=$2 | |
177 | ||
178 | echo "$0: getting translations into $subdir for $domain..." | |
179 | (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`) && | |
180 | ||
181 | $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" && | |
182 | ||
183 | sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" | | |
184 | sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 | | |
185 | awk -F. ' | |
186 | { if (lang && $1 != lang) print lang, ver } | |
187 | { lang = $1; ver = substr($0, index($0, ".") + 1) } | |
188 | END { if (lang) print lang, ver } | |
189 | ' | awk -v domain="$domain" -v subdir="$subdir" ' | |
190 | { | |
191 | lang = $1 | |
192 | ver = $2 | |
193 | urlfmt = "" | |
194 | printf "$WGET_COMMAND -O %s/%s.po 'http://www.iro.umontreal.ca/translation/teams/PO/%s/%s-%s.%s.po' &&\n", subdir, lang, lang, domain, ver, lang | |
195 | } | |
196 | END { print ":" } | |
197 | ' | sh && | |
198 | ls "$subdir"/*.po | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" && | |
199 | rm "$subdir/$domain.html" | |
200 | } | |
201 | ||
202 | case $SKIP_PO in | |
203 | '') | |
204 | case `wget --help` in | |
205 | *'--no-cache'*) | |
206 | no_cache='--no-cache';; | |
207 | *'--cache=on/off'*) | |
208 | no_cache='--cache=off';; | |
209 | *) | |
210 | no_cache='';; | |
211 | esac | |
212 | ||
213 | WGET_COMMAND="wget -nv $no_cache" | |
214 | export WGET_COMMAND | |
215 | ||
216 | get_translations po $package || exit | |
217 | ||
218 | case $package in | |
219 | bison) | |
220 | get_translations runtime-po $package-runtime || exit | |
221 | esac;; | |
222 | esac | |
223 | ||
224 | ||
225 | # Generate autoconf and automake snippets. | |
226 | ||
227 | (echo '# This file is generated automatically by "bootstrap".' && | |
228 | echo 'AC_DEFUN([GNULIB_AUTOCONF_SNIPPET],[' && | |
229 | $GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_modules && | |
230 | echo '])' | |
231 | ) >m4/gnulib.m4 || exit | |
232 | ||
233 | (echo '# This file is generated automatically by "bootstrap".' && | |
234 | $GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_modules | | |
235 | sed 's/^[ ]*AM_CPPFLAGS[ ]*+=/# (commented out by bootstrap) &/' | |
236 | ) >lib/gnulib.mk || exit | |
237 | ||
238 | ||
239 | # Reconfigure, getting other files. | |
240 | ||
241 | echo "$0: autoreconf --verbose --install --force ..." | |
242 | autoreconf --verbose --install --force || exit | |
243 | ||
244 | ||
245 | # We don't need intl, so remove it. | |
246 | # Remove aclocal.m4 too, so that it gets rebuilt. | |
247 | intl_files_to_remove=' | |
248 | aclocal.m4 | |
249 | intl | |
250 | m4/codeset.m4 | |
251 | m4/gettext.m4 | |
252 | m4/glibc2.m4 | |
253 | m4/glibc21.m4 | |
254 | m4/intdiv0.m4 | |
255 | m4/intmax.m4 | |
256 | m4/inttypes_h.m4 | |
257 | m4/inttypes.m4 | |
258 | m4/inttypes-pri.m4 | |
259 | m4/isc-posix.m4 | |
260 | m4/lcmessage.m4 | |
261 | m4/lib-ld.m4 | |
262 | m4/lib-prefix.m4 | |
263 | m4/longdouble.m4 | |
264 | m4/longlong.m4 | |
265 | m4/po.m4 | |
266 | m4/printf-posix.m4 | |
267 | m4/signed.m4 | |
268 | m4/size_max.m4 | |
269 | m4/stdint_h.m4 | |
270 | m4/uintmax_t.m4 | |
271 | m4/ulonglong.m4 | |
272 | m4/wchar_t.m4 | |
273 | m4/wint_t.m4 | |
274 | m4/xsize.m4 | |
275 | ' | |
276 | echo $0: rm -fr $intl_files_to_remove ... | |
277 | rm -fr $intl_files_to_remove || exit | |
278 | ||
279 | # Undo changes to gnulib files that autoreconf made. | |
280 | for gnulib_file in $gnulib_files; do | |
281 | test ! -f $gnulib_file || cmp -s $gnulib_file $GNULIB_SRCDIR/$gnulib_file || { | |
282 | rm -f $gnulib_file && | |
283 | echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file again" && | |
284 | cp -p $GNULIB_SRCDIR/$gnulib_file $gnulib_file || exit | |
285 | } | |
286 | done | |
287 | ||
288 | # Put bug-reporting address into po/Makevars. | |
289 | echo "$0: sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-bison@gnu.org/' po/Makevars.template >po/Makevars ..." | |
290 | sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-bison@gnu.org/' po/Makevars.template >po/Makevars | |
291 | ||
292 | # Likewise for runtime-po/Makevars, except also change a few other parameters. | |
293 | sed ' | |
294 | s/^\(DOMAIN\) *=.*/\1 = bison-runtime/ | |
295 | s/^\(subdir\) *=.*/\1 = runtime-po/ | |
296 | s/^\(XGETTEXT_OPTIONS\) *=.*/\1 = --keyword=YY_/ | |
297 | ' <po/Makevars >runtime-po/Makevars | |
298 | ||
299 | # Copy identical files from po to runtime-po. | |
300 | (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po) | |
301 | ||
302 | # if src/parse-gram.[ch] are out of date, rebuild them. | |
303 | parse_gram_y=`find src/parse-gram.y \ | |
304 | '(' -newer src/parse-gram.c -o -newer src/parse-gram.h ')' \ | |
305 | -print` || exit | |
306 | case $parse_gram_y in | |
307 | ?*) | |
308 | echo "$0: warning: bootstrapping with old src/parse-gram.[ch] files." | |
309 | ||
310 | echo "$0: touch -c src/parse-gram.[ch] ... " | |
311 | touch -c src/parse-gram.[ch] || exit | |
312 | ||
313 | echo "$0: ./configure --disable-nls ..." | |
314 | ./configure --disable-nls || exit | |
315 | ||
316 | echo "$0: (cd lib && make) ..." | |
317 | (cd lib && make) || exit | |
318 | ||
319 | echo "$0: (cd src && make) ..." | |
320 | (cd src && make) || exit | |
321 | ||
322 | echo "$0: rm -f src/parse-gram.c src/parse-gram.h ..." | |
323 | rm -f src/parse-gram.c src/parse-gram.h || exit | |
324 | ||
325 | echo "$0: (cd src && make parse-gram.c parse-gram.h) ..." | |
326 | (cd src && make parse-gram.c parse-gram.h) || exit | |
327 | ||
328 | echo "$0: make distclean ..." | |
329 | make distclean || exit;; | |
330 | esac | |
331 | ||
332 | echo "$0: done. Now you can run './configure'." |