]> git.saurik.com Git - bison.git/blob - djgpp/config.bat
Generalize the display of semantic values and locations in traces.
[bison.git] / djgpp / config.bat
1 @echo off
2 echo Configuring GNU Bison for DJGPP v2.x...
3
4 Rem The SmallEnv tests protect against fixed and too small size
5 Rem of the environment in stock DOS shell.
6
7 Rem Find out if NLS is wanted or not,
8 Rem if dependency-tracking is wanted or not,
9 Rem if caching is wanted or not
10 Rem and where the sources are.
11 Rem We always default to NLS support,
12 Rem no dependency tracking
13 Rem and to in place configuration.
14 set ARGS=
15 set NLS=enabled
16 if not "%NLS%" == "enabled" goto SmallEnv
17 set CACHING=enabled
18 if not "%CACHING%" == "enabled" goto SmallEnv
19 set DEPENDENCY_TRACKING=disabled
20 if not "%DEPENDENCY_TRACKING%" == "disabled" goto SmallEnv
21 set LIBICONV_PREFIX=disabled
22 if not "%LIBICONV_PREFIX%" == "disabled" goto SmallEnv
23 set LIBINTL_PREFIX=disabled
24 if not "%LIBINTL_PREFIX%" == "disabled" goto SmallEnv
25 set HTML=enabled
26 if not "%HTML%" == "enabled" goto SmallEnv
27 set XSRC=.
28 if not "%XSRC%" == "." goto SmallEnv
29
30 Rem Loop over all arguments.
31 Rem Special arguments are: NLS, XSRC, CACHE, STATIC_LIBS, LIBICONV_PREFIX, LIBINTL_PREFIX and DEPS.
32 Rem All other arguments are stored into ARGS.
33 :ArgLoop
34 if "%1" == "nls" goto NextArgument
35 if "%1" == "NLS" goto NextArgument
36 if "%1" == "no-nls" goto NoNLS
37 if "%1" == "no-NLS" goto NoNLS
38 if "%1" == "NO-NLS" goto NoNLS
39 goto CachingOption
40 :NoNLS
41 if "%1" == "no-nls" set NLS=disabled
42 if "%1" == "no-NLS" set NLS=disabled
43 if "%1" == "NO-NLS" set NLS=disabled
44 if not "%NLS%" == "disabled" goto SmallEnv
45 goto NextArgument
46 :CachingOption
47 if "%1" == "cache" goto NextArgument
48 if "%1" == "CACHE" goto NextArgument
49 if "%1" == "no-cache" goto NoCaching
50 if "%1" == "no-CACHE" goto NoCaching
51 if "%1" == "NO-CACHE" goto NoCaching
52 goto DependencyOption
53 :NoCaching
54 if "%1" == "no-cache" set CACHING=disabled
55 if "%1" == "no-CACHE" set CACHING=disabled
56 if "%1" == "NO-CACHE" set CACHING=disabled
57 if not "%CACHING%" == "disabled" goto SmallEnv
58 goto NextArgument
59 :DependencyOption
60 if "%1" == "no-dep" goto NextArgument
61 if "%1" == "no-DEP" goto NextArgument
62 if "%1" == "NO-DEP" goto NextArgument
63 if "%1" == "dep" goto DependecyTraking
64 if "%1" == "DEP" goto DependecyTraking
65 goto LibiconvPrefixOption
66 :DependecyTraking
67 if "%1" == "dep" set DEPENDENCY_TRACKING=enabled
68 if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled
69 if not "%DEPENDENCY_TRACKING%" == "enabled" goto SmallEnv
70 goto NextArgument
71 :LibiconvPrefixOption
72 if "%1" == "no-libiconvprefix" goto NextArgument
73 if "%1" == "no-LIBICONVPREFIX" goto NextArgument
74 if "%1" == "NO-LIBICONVPREFIX" goto NextArgument
75 if "%1" == "libiconvprefix" goto WithLibiconvPrefix
76 if "%1" == "LIBICONVPREFIX" goto WithLibiconvPrefix
77 goto LibintlPrefixOption
78 :WithLibiconvPrefix
79 if "%1" == "libiconvprefix" set LIBICONV_PREFIX=enabled
80 if "%1" == "LIBICONVPREFIX" set LIBICONV_PREFIX=enabled
81 if not "%LIBICONV_PREFIX%" == "enabled" goto SmallEnv
82 goto NextArgument
83 :LibintlPrefixOption
84 if "%1" == "no-libiconvprefix" goto NextArgument
85 if "%1" == "no-LIBICONVPREFIX" goto NextArgument
86 if "%1" == "NO-LIBICONVPREFIX" goto NextArgument
87 if "%1" == "libintlprefix" goto _WithLibintlPrefix
88 if "%1" == "LIBINTLPREFIX" goto _WithLibintlPrefix
89 goto HTMLOption
90 :_WithLibintlPrefix
91 if "%1" == "libintlprefix" set LIBINTL_PREFIX=enabled
92 if "%1" == "LIBINTLPREFIX" set LIBINTL_PREFIX=enabled
93 if not "%LIBINTL_PREFIX%" == "enabled" goto SmallEnv
94 :HTMLOption
95 if "%1" == "withhtml" goto NextArgument
96 if "%1" == "withHTML" goto NextArgument
97 if "%1" == "WITHHTML" goto NextArgument
98 if "%1" == "withouthtml" goto _WithoutHTML
99 if "%1" == "withoutHTML" goto _WithoutHTML
100 if "%1" == "WITHOUTHTML" goto _WithoutHTML
101 goto SrcDirOption
102 :_WithoutHTML
103 if "%1" == "withouthtml" set HTML=disabled
104 if "%1" == "withoutHTML" set HTML=disabled
105 if "%1" == "WITHOUTHTML" set HTML=disabled
106 if not "%HTML%" == "disabled" goto SmallEnv
107 goto NextArgument
108 :SrcDirOption
109 echo %1 | grep -q "/"
110 if errorlevel 1 goto CollectArgument
111 set XSRC=%1
112 if not "%XSRC%" == "%1" goto SmallEnv
113 goto NextArgument
114 :CollectArgument
115 set _ARGS=%ARGS% %1
116 if not "%_ARGS%" == "%ARGS% %1" if not "%_ARGS%" == "%ARGS%%1" goto SmallEnv
117 echo %_ARGS% | grep -q "[^ ]"
118 if not errorlevel 0 set ARGS=%_ARGS%
119 set _ARGS=
120 :NextArgument
121 shift
122 if not "%1" == "" goto ArgLoop
123
124 Rem Create an arguments file for the configure script.
125 echo --srcdir=%XSRC% > arguments
126 if "%CACHING%" == "enabled" echo --cache-file=%XSRC%/djgpp/config.cache >> arguments
127 if "%DEPENDENCY_TRACKING%" == "enabled" echo --enable-dependency-tracking >> arguments
128 if "%DEPENDENCY_TRACKING%" == "disabled" echo --disable-dependency-tracking >> arguments
129 if "%LIBICONV_PREFIX%" == "enabled" echo --with-libiconv-prefix >> arguments
130 if "%LIBICONV_PREFIX%" == "disabled" echo --without-libiconv-prefix >> arguments
131 if "%LIBINTL_PREFIX%" == "enabled" echo --with-libintl-prefix >> arguments
132 if "%LIBINTL_PREFIX%" == "disabled" echo --without-libintl-prefix >> arguments
133 if "%HTML%" == "enabled" echo --enable-html >> arguments
134 if "%HTML%" == "disabled" echo --disable-html >> arguments
135 if not "%ARGS%" == "" echo %ARGS% >> arguments
136 set ARGS=
137 set CACHING=
138 set DEPENDENCY_TRACKING=
139
140 if "%XSRC%" == "." goto InPlace
141
142 :NotInPlace
143 redir -e /dev/null update %XSRC%/configure.orig ./configure
144 test -f ./configure
145 if errorlevel 1 update %XSRC%/configure ./configure
146
147 :InPlace
148 Rem Update configuration files
149 echo Updating configuration scripts...
150 test -f ./configure.orig
151 if errorlevel 1 update configure configure.orig
152 sed -f %XSRC%/djgpp/config.sed configure.orig > configure
153 if errorlevel 1 goto SedError
154
155 Rem Make sure they have a config.site file
156 set CONFIG_SITE=%XSRC%/djgpp/config.site
157 if not "%CONFIG_SITE%" == "%XSRC%/djgpp/config.site" goto SmallEnv
158
159 Rem Make sure crucial file names are not munged by unpacking
160 test -f %XSRC%/po/Makefile.in.in
161 if not errorlevel 1 mv -f %XSRC%/po/Makefile.in.in %XSRC%/po/Makefile.in-in
162 test -f %XSRC%/po/Makefile.in-in
163 if errorlevel 1 mv -f %XSRC%/po/Makefile.in %XSRC%/po/Makefile.in-in
164 test -f %XSRC%/runtime-po/Makefile.in.in
165 if not errorlevel 1 mv -f %XSRC%/runtime-po/Makefile.in.in %XSRC%/runtime-po/Makefile.in-in
166 test -f %XSRC%/runtime-po/Makefile.in-in
167 if errorlevel 1 mv -f %XSRC%/runtime-po/Makefile.in %XSRC%/runtime-po/Makefile.in-in
168 test -f %XSRC%/data/c++.m4
169 if not errorlevel 1 mv -f %XSRC%/data/c++.m4 %XSRC%/data/cxx.m4
170 test -f %XSRC%/data/cxx.m4
171 if errorlevel 1 mv -f %XSRC%/data/cpp.m4 %XSRC%/data/cxx.m4
172
173 Rem Fix data/lalr1.cc and data/location.cc to reflect the renaming of c++.m4
174 sed "s/c++\.m4/cxx.m4/" %XSRC%/data/lalr1.cc > lalr1.cc
175 if errorlevel 1 goto lalr1_ccFileError
176 mv ./lalr1.cc %XSRC%/data/lalr1.cc
177 sed "s/c++\.m4/cxx.m4/" %XSRC%/data/location.cc > location.cc
178 if errorlevel 1 goto location.ccFileError
179 mv ./location.cc %XSRC%/data/location.cc
180
181 Rem Define DJGPP specific defs in config.hin
182 echo Editing config.hin...
183 test -f %XSRC%/config_h.orig
184 if errorlevel 1 update %XSRC%/config.hin %XSRC%/config_h.orig
185 sed -f %XSRC%/djgpp/config_h.sed %XSRC%/config_h.orig > config.hin
186 if errorlevel 1 goto SedError2
187 mv -f config.hin %XSRC%/config.hin
188
189
190 Rem Fixing ilicit testsuite file name.
191 test -f %XSRC%/tests/c++.at
192 if not errorlevel 1 mv -f %XSRC%/tests/c++.at %XSRC%/tests/cxx.at
193
194 Rem Fixing ilicit calc++ file names in the calc++ directory.
195 test -d %XSRC%/examples/calc++
196 if not errorlevel 1 mv -f %XSRC%/examples/calc++ %XSRC%/examples/calcxx
197 test -d %XSRC%/examples/calcxx
198 if errorlevel 1 mv -f %XSRC%/examples/calcpp %XSRC%/examples/calcxx
199 test -f %XSRC%/examples/calcxx/calc++-scanner.cc
200 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-scanner.cc %XSRC%/examples/calcxx/calcxx-scanner.cc
201 test -f %XSRC%/examples/calcxx/calcxx-scanner.cc
202 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-scanner.cc %XSRC%/examples/calcxx/calcxx-scanner.cc
203 test -f %XSRC%/examples/calcxx/calc++-scanner.ll
204 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-scanner.ll %XSRC%/examples/calcxx/calcxx-scanner.ll
205 test -f %XSRC%/examples/calcxx/calcxx-scanner.ll
206 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-scanner.ll %XSRC%/examples/calcxx/calcxx-scanner.ll
207 test -f %XSRC%/examples/calcxx/calc++-driver.cc
208 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-driver.cc %XSRC%/examples/calcxx/calcxx-driver.cc
209 test -f %XSRC%/examples/calcxx/calcxx-driver.cc
210 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-driver.cc %XSRC%/examples/calcxx/calcxx-driver.cc
211 test -f %XSRC%/examples/calcxx/calc++-driver.hh
212 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-driver.hh %XSRC%/examples/calcxx/calcxx-driver.hh
213 test -f %XSRC%/examples/calcxx/calcxx-driver.hh
214 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-driver.hh %XSRC%/examples/calcxx/calcxx-driver.hh
215 test -f %XSRC%/examples/calcxx/calc++-parser.cc
216 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.cc %XSRC%/examples/calcxx/calcxx-parser.cc
217 test -f %XSRC%/examples/calcxx/calcxx-parser.cc
218 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.cc %XSRC%/examples/calcxx/calcxx-parser.cc
219 test -f %XSRC%/examples/calcxx/calc++-parser.hh
220 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.hh %XSRC%/examples/calcxx/calcxx-parser.hh
221 test -f %XSRC%/examples/calcxx/calcxx-parser.hh
222 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.hh %XSRC%/examples/calcxx/calcxx-parser.hh
223 test -f %XSRC%/examples/calcxx/calc++-parser.stamp
224 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.stamp %XSRC%/examples/calcxx/calcxx-parser.stamp
225 test -f %XSRC%/examples/calcxx/calcxx-parser.stamp
226 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.stamp %XSRC%/examples/calcxx/calcxx-parser.stamp
227 test -f %XSRC%/examples/calcxx/calc++-parser.yy
228 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.yy %XSRC%/examples/calcxx/calcxx-parser.yy
229 test -f %XSRC%/examples/calcxx/calcxx-parser.yy
230 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.yy %XSRC%/examples/calcxx/calcxx-parser.yy
231 test -f %XSRC%/examples/calcxx/calc++.cc
232 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++.cc %XSRC%/examples/calcxx/calcxx.cc
233 test -f %XSRC%/examples/calcxx/calcxx.cc
234 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp.cc %XSRC%/examples/calcxx/calcxx.cc
235
236 Rem Fixing #include lines in calcxx files.
237 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx.cc > calcxx.cc
238 if errorlevel 1 goto calcxxFileError
239 mv ./calcxx.cc %XSRC%/examples/calcxx/calcxx.cc
240 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-driver.cc > calcxx-driver.cc
241 if errorlevel 1 goto calcxxFileError
242 mv ./calcxx-driver.cc %XSRC%/examples/calcxx/calcxx-driver.cc
243 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-driver.hh > calcxx-driver.hh
244 if errorlevel 1 goto calcxxFileError
245 mv ./calcxx-driver.hh %XSRC%/examples/calcxx/calcxx-driver.hh
246 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-parser.cc > calcxx-parser.cc
247 if errorlevel 1 goto calcxxFileError
248 mv ./calcxx-parser.cc %XSRC%/examples/calcxx/calcxx-parser.cc
249 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-parser.hh > calcxx-parser.hh
250 if errorlevel 1 goto calcxxFileError
251 mv ./calcxx-parser.hh %XSRC%/examples/calcxx/calcxx-parser.hh
252 :sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-parser.yy > calcxx-parser.yy
253 :if errorlevel 1 goto calcxxFileError
254 :mv ./calcxx-parser.yy %XSRC%/examples/calcxx/calcxx-parser.yy
255 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-scanner.cc > calcxx-scanner.cc
256 if errorlevel 1 goto calcxxFileError
257 mv ./calcxx-scanner.cc %XSRC%/examples/calcxx/calcxx-scanner.cc
258 :sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-scanner.ll > calcxx-scanner.ll
259 :if errorlevel 1 goto calcxxFileError
260 :mv ./calcxx-scanner.ll %XSRC%/examples/calcxx/calcxx-scanner.ll
261 sed "s/calc++/calcxx/" %XSRC%/examples/calcxx/test > test
262 if errorlevel 1 goto calcxxFileError
263 mv ./test %XSRC%/examples/calcxx/test
264
265
266 Rem Fixing the scanner files to make file names 8.3 valid.
267 Rem Use only if you want to change the scan-gram.l and scan-skel.l files.
268 : sed "/outfile=/s/\.yy/yy/" %XSRC%/src/scan-gram.l > scan-gram.l
269 : if errorlevel 1 goto ScannerFileError
270 : mv ./scan-gram.l %XSRC%/src/scan-gram.l
271 : sed "/outfile=/s/\.yy/yy/" %XSRC%/src/scan-skel.l > scan-skel.l
272 : if errorlevel 1 goto ScannerFileError
273 : mv ./scan-skel.l %XSRC%/src/scan-skel.l
274
275
276 Rem This is required because DOS/Windows are case-insensitive
277 Rem to file names, and "make install" will do nothing if Make
278 Rem finds a file called `install'.
279 if exist INSTALL ren INSTALL INSTALL.txt
280
281 Rem Set SHELL to a sane default or some configure tests stop working
282 Rem if the package is configured across partitions.
283 if not "%SHELL%" == "" goto HomeName
284 set SHELL=/bin/sh
285 if not "%SHELL%" == "/bin/sh" goto SmallEnv
286 echo No SHELL found in the environment, using default value
287
288 :HomeName
289 Rem Set HOME to a sane default so configure stops complaining.
290 if not "%HOME%" == "" goto HostName
291 set HOME=%XSRC%/djgpp
292 if not "%HOME%" == "%XSRC%/djgpp" goto SmallEnv
293 echo No HOME found in the environment, using default value
294
295 :HostName
296 Rem Set HOSTNAME so it shows in config.status
297 if not "%HOSTNAME%" == "" goto hostdone
298 if "%windir%" == "" goto msdos
299 set OS=MS-Windows
300 if not "%OS%" == "MS-Windows" goto SmallEnv
301 goto haveos
302 :msdos
303 set OS=MS-DOS
304 if not "%OS%" == "MS-DOS" goto SmallEnv
305 :haveos
306 if not "%USERNAME%" == "" goto haveuname
307 if not "%USER%" == "" goto haveuser
308 echo No USERNAME and no USER found in the environment, using default values
309 set HOSTNAME=Unknown PC
310 if not "%HOSTNAME%" == "Unknown PC" goto SmallEnv
311 goto userdone
312 :haveuser
313 set HOSTNAME=%USER%'s PC
314 if not "%HOSTNAME%" == "%USER%'s PC" goto SmallEnv
315 goto userdone
316 :haveuname
317 set HOSTNAME=%USERNAME%'s PC
318 if not "%HOSTNAME%" == "%USERNAME%'s PC" goto SmallEnv
319 :userdone
320 set _HOSTNAME=%HOSTNAME%, %OS%
321 if not "%_HOSTNAME%" == "%HOSTNAME%, %OS%" goto SmallEnv
322 set HOSTNAME=%_HOSTNAME%
323 :hostdone
324 set _HOSTNAME=
325 set OS=
326
327 Rem install-sh is required by the configure script but clashes with the
328 Rem various Makefile install-foo targets, so we MUST have it before the
329 Rem script runs and rename it afterwards
330 test -f %XSRC%/install-sh
331 if not errorlevel 1 goto NoRen0
332 test -f %XSRC%/install-sh.sh
333 if not errorlevel 1 mv -f %XSRC%/install-sh.sh %XSRC%/install-sh
334 :NoRen0
335
336 if "%NLS%" == "disabled" goto WithoutNLS
337
338 :WithNLS
339 Rem Check for the needed libraries and binaries.
340 test -x /dev/env/DJDIR/bin/msgfmt.exe
341 if errorlevel 1 goto MissingNLSTools
342 test -x /dev/env/DJDIR/bin/xgettext.exe
343 if errorlevel 1 goto MissingNLSTools
344 test -f /dev/env/DJDIR/include/libcharset.h
345 if errorlevel 1 goto MissingNLSTools
346 test -f /dev/env/DJDIR/lib/libcharset.a
347 if errorlevel 1 goto MissingNLSTools
348 test -f /dev/env/DJDIR/include/iconv.h
349 if errorlevel 1 goto MissingNLSTools
350 test -f /dev/env/DJDIR/lib/libiconv.a
351 if errorlevel 1 goto MissingNLSTools
352 test -f /dev/env/DJDIR/include/libintl.h
353 if errorlevel 1 goto MissingNLSTools
354 test -f /dev/env/DJDIR/lib/libintl.a
355 if errorlevel 1 goto MissingNLSTools
356
357 Rem Recreate the files in the %XSRC%/po subdir with our ported tools.
358 redir -e /dev/null rm %XSRC%/po/*.gmo
359 redir -e /dev/null rm %XSRC%/po/bison.pot
360 redir -e /dev/null rm %XSRC%/po/cat-id-tbl.c
361 redir -e /dev/null rm %XSRC%/po/stamp-cat-id
362
363 Rem Update the arguments file for the configure script.
364 Rem We prefer without-included-gettext because libintl.a from gettext package
365 Rem is the only one that is garanteed to have been ported to DJGPP.
366 echo --enable-nls --without-included-gettext >> arguments
367 goto ConfigurePackage
368
369 :MissingNLSTools
370 echo Needed libs/tools for NLS not found. Configuring without NLS.
371 :WithoutNLS
372 Rem Update the arguments file for the configure script.
373 echo --disable-nls >> arguments
374
375 :ConfigurePackage
376 echo Running the ./configure script...
377 sh ./configure @arguments
378 if errorlevel 1 goto CfgError
379 rm arguments
380 echo Done.
381 goto End
382
383 :lalr1_ccFileError
384 echo ./data/lalr1.cc file editing failed!
385 goto End
386
387 :location_ccFileError
388 echo ./data/location.cc file editing failed!
389 goto End
390
391 :calcxxFileError
392 echo ./examples/calcxx file editing failed!
393 goto End
394
395 :ScannerFileError
396 echo ./scanner file editing failed!
397 goto End
398
399 :SedError
400 echo ./configure script editing failed!
401 goto End
402
403 :SedError2
404 echo ./config.hin editing failed!
405 goto End
406
407 :CfgError
408 echo ./configure script exited abnormally!
409 goto End
410
411 :SmallEnv
412 echo Your environment size is too small. Enlarge it and run me again.
413 echo Configuration NOT done!
414
415 :End
416 test -f %XSRC%/install-sh.sh
417 if not errorlevel 1 goto NoRen1
418 test -f %XSRC%/install-sh
419 if not errorlevel 1 mv -f %XSRC%/install-sh %XSRC%/install-sh.sh
420 :NoRen1
421 if "%SHELL%" == "/bin/sh" set SHELL=
422 if "%HOME%" == "%XSRC%/djgpp" set HOME=
423 set ARGS=
424 set CONFIG_SITE=
425 set HOSTNAME=
426 set NLS=
427 set CACHING=
428 set DEPENDENCY_TRACKING=
429 set XSRC=