]> git.saurik.com Git - bison.git/blame - bootstrap
Credit Satya for the graphviz change.
[bison.git] / bootstrap
CommitLineData
01c56de4
AD
1#! /bin/sh
2
1f65350a 3# Bootstrap this package from CVS.
01c56de4 4
b4068c7c 5# Copyright (C) 2003, 2004, 2005, 2006 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
3b2942e6
PE
24nl='
25'
5a2baae7 26
62a9592d 27# Ensure file names are sorted consistently across platforms.
b5240ba5 28# Also, ensure diagnostics are in English, e.g., "wget --help" below.
a9f027b9
PE
29LC_ALL=C
30export LC_ALL
31
e3ddc1e3
PE
32usage() {
33 echo >&2 "\
34Usage: $0 [OPTION]...
35Bootstrap this package from the CVS sources.
36
37Options:
38 --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
39 sources reside. Use this if you already
40 have gnulib sources on your machine, and
41 do not want to waste your bandwidth dowloading
42 them again.
43 --force Bootstrap even if the sources didn't come from CVS.
44 --skip-po Do not download po files.
45 --cvs-user=USERNAME Set the CVS username to be used when accessing
46 the gnulib repository.
47
48If the file .bootstrap.conf exists in the current working directory, its
49contents are read as shell variables to configure the bootstrap.
50
51Running without arguments will suffice in most cases.
52"
53}
3b2942e6
PE
54
55# Configuration.
56
57# List of gnulib modules needed.
58gnulib_modules=
59
60# Any gnulib files needed that are not in modules.
61gnulib_files=
62
63# Translation Project URL, for the registry of all projects
64# and for the translation-team master directory.
65TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain='
66TP_PO_URL='http://www.iro.umontreal.ca/translation/teams/PO/'
67
68extract_package_name='
69 /^AC_INIT(/{
70 /.*,.*,.*,/{
71 s///
72 s/[][]//g
73 p
74 q
75 }
76 s/AC_INIT(\[*//
77 s/]*,.*//
78 s/^GNU //
79 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
80 s/[^A-Za-z0-9_]/-/g
81 p
82 }
83'
84package=`sed -n "$extract_package_name" configure.ac` || exit
85
86# Extra files from gnulib, which override files from other sources.
87gnulib_extra_files='
88 build-aux/install-sh
89 build-aux/missing
90 build-aux/mdate-sh
91 build-aux/texinfo.tex
92 build-aux/depcomp
93 build-aux/config.guess
94 build-aux/config.sub
95 doc/INSTALL
96'
97
98# Other locale categories that need message catalogs.
99EXTRA_LOCALE_CATEGORIES=
100
101# Additional xgettext options to use. Use "\\\newline" to break lines.
102XGETTEXT_OPTIONS='\\\
103 --flag=_:1:pass-c-format\\\
104 --flag=N_:1:pass-c-format\\\
105 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
106'
107
108# Files we don't want to import.
109excluded_files=
110
e3ddc1e3
PE
111# File that should exist with CVS checkout, but not with
112# the distributed version.
113CVS_only_file=CVS
114
3b2942e6
PE
115# Override the default configuration, if necessary.
116test -r bootstrap.conf && . ./bootstrap.conf
117
118# Translate configuration into internal form.
119
1f65350a
PE
120# Parse options.
121
122for option
123do
124 case $option in
125 --help)
e3ddc1e3 126 usage
1f65350a
PE
127 exit;;
128 --gnulib-srcdir=*)
e23d0dd7 129 GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
1f65350a 130 --cvs-user=*)
e23d0dd7 131 CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
1f65350a
PE
132 --skip-po)
133 SKIP_PO=t;;
e3ddc1e3
PE
134 --force)
135 CVS_only_file=;;
1f65350a
PE
136 *)
137 echo >&2 "$0: $option: unknown option"
138 exit 1;;
139 esac
140done
141
e3ddc1e3
PE
142if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then
143 echo "$0: Bootstrapping from a non-CVS distribution is a bit risky." >&2
144 exit 1
145fi
146
1f65350a
PE
147echo "$0: Bootstrapping CVS $package..."
148
e10a80ee
PE
149cleanup_gnulib() {
150 status=$?
151 rm -fr gnulib
152 exit $status
153}
154
1f65350a
PE
155# Get gnulib files.
156
157case ${GNULIB_SRCDIR--} in
158-)
159 if [ ! -d gnulib ]; then
160 echo "$0: getting gnulib files..."
161
26546b42
PE
162 case ${CVS_AUTH-pserver} in
163 pserver)
164 CVS_PREFIX=':pserver:anonymous@';;
1f65350a
PE
165 ssh)
166 CVS_PREFIX="$CVS_USER${CVS_USER+@}";;
167 *)
168 echo "$0: $CVS_AUTH: Unknown CVS access method" >&2
169 exit 1;;
170 esac
171
172 case $CVS_RSH in
3b2942e6 173 '') CVS_RSH=ssh; export CVS_RSH;;
1f65350a
PE
174 esac
175
e10a80ee
PE
176 trap cleanup_gnulib 1 2 13 15
177
26546b42 178 cvs -z3 -q -d ${CVS_PREFIX}cvs.savannah.gnu.org:/cvsroot/gnulib co gnulib ||
e10a80ee 179 cleanup_gnulib
1f65350a 180
e10a80ee 181 trap - 1 2 13 15
1f65350a
PE
182 fi
183 GNULIB_SRCDIR=gnulib
184esac
185
284d8a13
PE
186gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
187<$gnulib_tool || exit
1f65350a 188
1f65350a
PE
189# Get translations.
190
5a2baae7
PE
191get_translations() {
192 subdir=$1
193 domain=$2
194
3b2942e6
PE
195 case $WGET_COMMAND in
196 '')
197 echo "$0: wget not available; skipping translations";;
198 ?*)
199 echo "$0: getting translations into $subdir for $domain..." &&
200
201 (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`) &&
202 $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
203
204 sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" |
205 sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
206 awk -F. '
207 { if (lang && $1 != lang) print lang, ver }
208 { lang = $1; ver = substr($0, index($0, ".") + 1) }
209 END { if (lang) print lang, ver }
210 ' | awk -v domain="$domain" -v subdir="$subdir" '
211 {
212 lang = $1
213 ver = $2
214 urlfmt = ""
215 printf "{ $WGET_COMMAND -O %s/%s.po '\'"$TP_PO_URL"'/%s/%s-%s.%s.po'\'' &&\n", subdir, lang, lang, domain, ver, lang
216 printf " msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang
217 printf " echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang
218 printf " rm -f %s/%s.po; }; } &&\n", subdir, lang
219 }
220 END { print ":" }
221 ' | WGET_COMMAND="$WGET_COMMAND" sh;;
222 esac &&
223 ls "$subdir"/*.po 2>/dev/null |
224 sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
225 rm -f "$subdir/$domain.html"
5a2baae7
PE
226}
227
1f65350a
PE
228case $SKIP_PO in
229'')
b5240ba5
PE
230 case `wget --help` in
231 *'--no-cache'*)
3b2942e6 232 WGET_COMMAND='wget -nv --no-cache';;
b5240ba5 233 *'--cache=on/off'*)
3b2942e6
PE
234 WGET_COMMAND='wget -nv --cache=off';;
235 *'--non-verbose'*)
236 WGET_COMMAND='wget -nv';;
b5240ba5 237 *)
3b2942e6 238 WGET_COMMAND='';;
b5240ba5
PE
239 esac
240
5a2baae7 241 get_translations po $package || exit
f7ab6a50 242
3b2942e6 243 if test -d runtime-po; then
5a2baae7 244 get_translations runtime-po $package-runtime || exit
3b2942e6 245 fi;;
1f65350a
PE
246esac
247
e70f46d1
PE
248symlink_to_gnulib()
249{
250 src=$GNULIB_SRCDIR/$1
251 dst=${2-$1}
252 dot_dots=
253
254 case $src in
255 /*) ;;
256 *)
257 case /$dst/ in
258 *//* | */../* | */./* | /*/*/*/*/*/)
259 echo >&2 "$0: invalid symlink calculation: $src -> $dst"
260 exit 1;;
261 /*/*/*/*/) dot_dots=../../../;;
262 /*/*/*/) dot_dots=../../;;
263 /*/*/) dot_dots=../;;
264 esac;;
265 esac
266
267 test -f "$src" && {
268 test -h "$dst" &&
269 src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
270 dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
271 test "$src_i" = "$dst_i" || {
272 echo "$0: ln -fs $dot_dots$src $dst" &&
273 ln -fs "$dot_dots$src" "$dst"
274 }
275 }
276}
277
3b2942e6
PE
278cp_mark_as_generated()
279{
280 cp_src=$1
281 cp_dst=$2
1f65350a 282
e70f46d1
PE
283 if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
284 symlink_to_gnulib "$cp_dst"
285 else
286 case $cp_dst in
287 *.[ch]) c1='/* '; c2=' */';;
288 *.texi) c1='@c '; c2= ;;
289 *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
290 *) c1= ; c2= ;;
291 esac
1f65350a 292
e70f46d1
PE
293 if test -z "$c1"; then
294 cmp -s "$cp_src" "$cp_dst" || {
295 echo "$0: cp -f $cp_src $cp_dst" &&
296 cp -f "$cp_src" "$cp_dst"
297 }
298 else
299 # Copy the file first to get proper permissions if it
300 # doesn't already exist. Then overwrite the copy.
301 cp "$cp_src" "$cp_dst-t" &&
302 (
303 echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
304 echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
305 cat "$cp_src"
306 ) > $cp_dst-t &&
307 if cmp -s "$cp_dst-t" "$cp_dst"; then
308 rm -f "$cp_dst-t"
309 else
310 echo "$0: cp $cp_src $cp_dst # with edits" &&
311 mv -f "$cp_dst-t" "$cp_dst"
312 fi
313 fi
314 fi
3b2942e6 315}
1f65350a 316
3b2942e6
PE
317slurp() {
318 for dir in . `(cd $1 && find * -type d -print)`; do
319 copied=
320 sep=
321 for file in `ls $1/$dir`; do
322 test -d $1/$dir/$file && continue
323 for excluded_file in $excluded_files; do
324 test "$dir/$file" = "$excluded_file" && continue 2
325 done
326 if test $file = Makefile.am; then
e70f46d1
PE
327 copied=$copied${sep}gnulib.mk; sep=$nl
328 remove_intl='/^[^#].*\/intl/s/^/#/'
e3ddc1e3
PE
329 no_dep=no-dependencies
330 remove_no_dep="/^AUTOMAKE_OPTIONS =.* $no_dep/s/ $no_dep//"
331 sed_xform="$remove_intl;$remove_no_dep"
332 sed "$sed_xform" $1/$dir/$file | cmp -s - $dir/gnulib.mk || {
e70f46d1
PE
333 echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
334 rm -f $dir/gnulib.mk &&
e3ddc1e3 335 sed "$sed_xform" $1/$dir/$file >$dir/gnulib.mk
e70f46d1
PE
336 }
337 elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
3b2942e6
PE
338 grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
339 grep -q '^/[^/]*/[0-9]'; then
340 echo "$0: $dir/$file overrides $1/$dir/$file"
341 else
342 copied=$copied$sep$file; sep=$nl
343 if test $file = gettext.m4; then
344 echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
345 rm -f $dir/$file
346 sed '
347 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
348 AC_DEFUN([AM_INTL_SUBDIR], [
349 /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
350 AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
351 $a\
352 AC_DEFUN([gl_LOCK_EARLY], [])
353 ' $1/$dir/$file >$dir/$file
354 else
3b2942e6
PE
355 cp_mark_as_generated $1/$dir/$file $dir/$file
356 fi
357 fi || exit
358 done
359
360 ig=$dir/.cvsignore
361 if test -n "$copied" && test -f $ig; then
362 echo "$copied" | sort -u - $ig | cmp -s - $ig ||
363 echo "$copied" | sort -u - $ig -o $ig || exit
364 fi
365 done
366}
1f65350a
PE
367
368
3b2942e6
PE
369# Create boot temporary directories to import from gnulib and gettext.
370
371bt='.#bootmp'
372bt2=${bt}2
373rm -fr $bt $bt2 &&
374mkdir $bt $bt2 || exit
375
376# Import from gnulib.
377
378gnulib_tool_options="\
379 --import\
380 --no-changelog\
381 --aux-dir $bt/build-aux\
382 --doc-base $bt/doc\
383 --lib lib$package\
384 --m4-base $bt/m4/\
385 --source-base $bt/lib/\
386 --tests-base $bt/tests\
e3ddc1e3 387 --local-dir gl\
3b2942e6
PE
388"
389echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
390$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
391slurp $bt || exit
392
393for file in $gnulib_files; do
e70f46d1 394 symlink_to_gnulib $file || exit
3b2942e6 395done
1f65350a 396
e23d0dd7 397
3b2942e6 398# Import from gettext.
62a9592d 399
3b2942e6
PE
400echo "$0: (cd $bt2; autopoint) ..."
401cp configure.ac $bt2 &&
402(cd $bt2 && autopoint && rm configure.ac) &&
403slurp $bt2 $bt || exit
b4068c7c 404
3b2942e6
PE
405rm -fr $bt $bt2 || exit
406
407
408# Reconfigure, getting other files.
62a9592d
PE
409
410for command in \
411 'aclocal --force -I m4' \
412 'autoconf --force' \
413 'autoheader --force' \
414 'automake --add-missing --copy --force-missing';
415do
416 echo "$0: $command ..."
417 $command || exit
418done
419
420
3b2942e6
PE
421# Get some extra files from gnulib, overriding existing files.
422
423for file in $gnulib_extra_files; do
3b2942e6 424 case $file in
e70f46d1
PE
425 */INSTALL) dst=INSTALL;;
426 *) dst=$file;;
3b2942e6 427 esac
e70f46d1 428 symlink_to_gnulib $file $dst || exit
3b2942e6
PE
429done
430
431
432# Create gettext configuration.
11daa4e7 433echo "$0: Creating po/Makevars from po/Makevars.template ..."
3b2942e6 434rm -f po/Makevars
11daa4e7 435sed '
3b2942e6
PE
436 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
437 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
11daa4e7
PE
438 /^XGETTEXT_OPTIONS *=/{
439 s/$/ \\/
440 a\
3b2942e6 441 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
11daa4e7
PE
442 }
443' po/Makevars.template >po/Makevars
1f65350a 444
3b2942e6 445if test -d runtime-po; then
0e2f006a 446 # Similarly for runtime-po/Makevars, but not quite the same.
3b2942e6
PE
447 rm -f runtime-po/Makevars
448 sed '
0e2f006a
PE
449 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
450 /^subdir *=.*/s/=.*/= runtime-po/
451 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
452 /^XGETTEXT_OPTIONS *=/{
453 s/$/ \\/
454 a\
455 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
456 }
457 ' <po/Makevars.template >runtime-po/Makevars
3b2942e6
PE
458
459 # Copy identical files from po to runtime-po.
460 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
461fi
1f65350a
PE
462
463echo "$0: done. Now you can run './configure'."