]> git.saurik.com Git - bison.git/blob - bootstrap
* bootstrap: Don't assume $(...) works; use `...` instead.
[bison.git] / bootstrap
1 #! /bin/sh
2
3 # Bootstrap this package from CVS.
4
5 # Copyright (C) 2003, 2004 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., 59 Temple Place - Suite 330, Boston, MA
20 # 02111-1307, USA.
21
22 # Written by Paul Eggert.
23
24 package=bison
25
26 # Parse options.
27
28 for option
29 do
30 case $option in
31 --help)
32 echo "$0: usage: $0 [--gnulib-srcdir=DIR] [--cvs-user=USERNAME] [--skip-po]"
33 exit;;
34 --gnulib-srcdir=*)
35 GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
36 --cvs-user=*)
37 CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
38 --skip-po)
39 SKIP_PO=t;;
40 *)
41 echo >&2 "$0: $option: unknown option"
42 exit 1;;
43 esac
44 done
45
46 # Check that gettext version matches what's in configure.ac.
47 # FIXME: We shouldn't have to modify configure.ac every time
48 # a new gettext version comes out.
49 {
50 gettext_version_output=`LC_ALL=C gettext --version` &&
51 case $gettext_version_output in
52 'gettext (GNU '*) ;;
53 *) false;;
54 esac
55 } || {
56 echo >&2 "$0: Please install GNU gettext first."
57 exit 1
58 }
59 newline='
60 '
61 last_word_in_first_line="[^$newline]* \\([^$newline]*\\)"
62 gettext_have=`expr "$gettext_version_output" : "$last_word_in_first_line"`
63 gettext_need=`
64 sed -n '/^AM_GNU_GETTEXT_VERSION/{ s/.*\[//; s/].*//; p; q; }' configure.ac
65 `
66 [ "$gettext_have" = "$gettext_need" ] || {
67 echo >&2 "$0: Your gettext version is $gettext_have."
68 echo >&2 "$0: Please install and use gettext-$gettext_need instead."
69 exit 1
70 }
71
72 echo "$0: Bootstrapping CVS $package..."
73
74 build_cvs_prefix() {
75 CVS_PREFIX=:${1}:
76 if [ "${2}" != - ]; then
77 CVS_PREFIX=${CVS_PREFIX}${2}@
78 fi
79 }
80
81 # Get gnulib files.
82
83 case ${GNULIB_SRCDIR--} in
84 -)
85 if [ ! -d gnulib ]; then
86 echo "$0: getting gnulib files..."
87
88 trap exit 1 2 13 15
89 trap 'rm -fr gnulib; exit 1' 0
90
91 case ${CVS_AUTH-anoncvs} in
92 anoncvs)
93 CVS_PREFIX='anoncvs@';;
94 ssh)
95 CVS_PREFIX="$CVS_USER${CVS_USER+@}";;
96 *)
97 echo "$0: $CVS_AUTH: Unknown CVS access method" >&2
98 exit 1;;
99 esac
100
101 case $CVS_RSH in
102 '') export CVS_RSH=ssh;;
103 esac
104
105 cvs -z3 -q -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/gnulib co gnulib || exit
106
107 trap 0
108 fi
109 GNULIB_SRCDIR=gnulib
110 esac
111
112 <$GNULIB_SRCDIR/gnulib-tool || exit
113
114 gnulib_modules='
115 alloca
116 argmatch
117 dirname
118 error
119 getopt
120 hard-locale
121 hash
122 malloc
123 mbswidth
124 obstack
125 quote
126 quotearg
127 stdbool
128 stpcpy
129 xalloc
130 xstrndup
131 '
132
133 previous_gnulib_modules=
134 while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
135 previous_gnulib_modules=$gnulib_modules
136 gnulib_modules=`
137 (echo "$gnulib_modules"
138 for gnulib_module in $gnulib_modules; do
139 $GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module
140 done) | sort -u
141 `
142 done
143
144 gnulib_files=`
145 (for gnulib_module in $gnulib_modules; do
146 $GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
147 done) | sort -u
148 `
149
150 gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
151 mkdir -p $gnulib_dirs || exit
152
153 for gnulib_file in $gnulib_files; do
154 dest=$gnulib_file
155
156 case $gnulib_file in
157 m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
158 esac
159
160 rm -f $dest &&
161 echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
162 cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
163 done
164
165
166 # Get translations.
167
168 case $SKIP_PO in
169 '')
170 echo "$0: getting translations into po (please ignore the robots.txt ERROR 404)..."
171 (cd po &&
172 rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
173 wget -nv -nd -r -l 1 -A .po -C off \
174 http://www2.iro.umontreal.ca/~gnutra/po/maint/$package/ &&
175 ls *.po | sed 's/\.po$//' >LINGUAS
176 ) || exit;;
177 esac
178
179
180 # Generate autoconf and automake snippets.
181
182 (echo '# This file is generated automatically by "bootstrap".' &&
183 echo 'AC_DEFUN([GNULIB_AUTOCONF_SNIPPET],[' &&
184 $GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_modules &&
185 echo '])'
186 ) >m4/gnulib.m4 || exit
187
188 (echo '# This file is generated automatically by "bootstrap".' &&
189 $GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_modules
190 ) >lib/gnulib.mk || exit
191
192
193 # Reconfigure, getting other files.
194
195 echo "$0: autoreconf --verbose --install --force ..."
196 autoreconf --verbose --install --force || exit
197
198
199 # We don't need intl, so remove it.
200 # Remove aclocal.m4 too, so that it gets rebuilt.
201 intl_files_to_remove='
202 aclocal.m4
203 intl
204 m4/codeset.m4
205 m4/glibc21.m4
206 m4/intdiv0.m4
207 m4/intmax.m4
208 m4/inttypes_h.m4
209 m4/inttypes.m4
210 m4/inttypes-pri.m4
211 m4/isc-posix.m4
212 m4/lcmessage.m4
213 m4/longdouble.m4
214 m4/longlong.m4
215 m4/printf-posix.m4
216 m4/signed.m4
217 m4/size_max.m4
218 m4/stdint_h.m4
219 m4/uintmax_t.m4
220 m4/ulonglong.m4
221 m4/wchar_t.m4
222 m4/wint_t.m4
223 m4/xsize.m4
224 '
225 echo $0: rm -fr $intl_files_to_remove ...
226 rm -fr $intl_files_to_remove || exit
227
228 echo "$0: patching m4/gettext.m4 so that AM_INTL_SUBDIR is empty ..."
229 sed '
230 /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
231 AC_DEFUN([AM_INTL_SUBDIR], [])
232 ' m4/gettext.m4 >m4/gettext.m4t &&
233 mv m4/gettext.m4t m4/gettext.m4 || exit
234
235 # Patch what appears to be a bug in gettext 0.14.1;
236 # remove this once the bug is fixed.
237 grep @top_builddir@ po/Makefile.in.in >/dev/null || {
238 echo "$0: prepending 'top_builddir=@top_builddir@' to po/Makefile.in.in ... "
239 old_contents=`cat po/Makefile.in.in` || exit
240 cat >po/Makefile.in.in <<EOF
241 top_builddir=@top_builddir@
242 $old_contents
243 EOF
244 }
245
246 # Put bug-reporting address into po/Makevars.
247 echo "$0: sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-bison@gnu.org/' po/Makevars.template >po/Makevars ..."
248 sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-bison@gnu.org/' po/Makevars.template >po/Makevars
249
250
251 # if src/parse-gram.[ch] are out of date, rebuild them.
252 parse_gram_y=`find src/parse-gram.y \
253 '(' -newer src/parse-gram.c -o -newer src/parse-gram.h ')' \
254 -print` || exit
255 case $parse_gram_y in
256 ?*)
257 echo "$0: warning: bootstrapping with old src/parse-gram.[ch] files."
258
259 echo "$0: touch -c src/parse-gram.[ch] ... "
260 touch -c src/parse-gram.[ch] || exit
261
262 echo "$0: ./configure --disable-nls ..."
263 ./configure --disable-nls || exit
264
265 echo "$0: (cd lib && make) ..."
266 (cd lib && make) || exit
267
268 echo "$0: (cd src && make) ..."
269 (cd src && make) || exit
270
271 echo "$0: rm -f src/parse-gram.c src/parse-gram.h ..."
272 rm -f src/parse-gram.c src/parse-gram.h || exit
273
274 echo "$0: (cd src && make parse-gram.c parse-gram.h) ..."
275 (cd src && make parse-gram.c parse-gram.h) || exit
276
277 echo "$0: make distclean ..."
278 make distclean || exit;;
279 esac
280
281 echo "$0: done. Now you can run './configure'."