]> git.saurik.com Git - bison.git/blob - djgpp/config.bat
DJGPP specific files added to EXTRA_DIST
[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 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
178 Rem Define DJGPP specific defs in config.hin
179 echo Editing config.hin...
180 test -f %XSRC%/config_h.orig
181 if errorlevel 1 update %XSRC%/config.hin %XSRC%/config_h.orig
182 sed -f %XSRC%/djgpp/config_h.sed %XSRC%/config_h.orig > config.hin
183 if errorlevel 1 goto SedError2
184 mv -f config.hin %XSRC%/config.hin
185
186
187 Rem Fixing ilicit testsuite file name.
188 test -f %XSRC%/tests/c++.at
189 if not errorlevel 1 mv -f %XSRC%/tests/c++.at %XSRC%/tests/cxx.at
190
191 Rem Fixing ilicit calc++ file names in the calc++ directory.
192 test -d %XSRC%/examples/calc++
193 if not errorlevel 1 mv -f %XSRC%/examples/calc++ %XSRC%/examples/calcxx
194 test -d %XSRC%/examples/calcxx
195 if errorlevel 1 mv -f %XSRC%/examples/calcpp %XSRC%/examples/calcxx
196 test -f %XSRC%/examples/calcxx/calc++-scanner.cc
197 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-scanner.cc %XSRC%/examples/calcxx/calcxx-scanner.cc
198 test -f %XSRC%/examples/calcxx/calcxx-scanner.cc
199 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-scanner.cc %XSRC%/examples/calcxx/calcxx-scanner.cc
200 test -f %XSRC%/examples/calcxx/calc++-scanner.ll
201 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-scanner.ll %XSRC%/examples/calcxx/calcxx-scanner.ll
202 test -f %XSRC%/examples/calcxx/calcxx-scanner.ll
203 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-scanner.ll %XSRC%/examples/calcxx/calcxx-scanner.ll
204 test -f %XSRC%/examples/calcxx/calc++-driver.cc
205 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-driver.cc %XSRC%/examples/calcxx/calcxx-driver.cc
206 test -f %XSRC%/examples/calcxx/calcxx-driver.cc
207 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-driver.cc %XSRC%/examples/calcxx/calcxx-driver.cc
208 test -f %XSRC%/examples/calcxx/calc++-driver.hh
209 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-driver.hh %XSRC%/examples/calcxx/calcxx-driver.hh
210 test -f %XSRC%/examples/calcxx/calcxx-driver.hh
211 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-driver.hh %XSRC%/examples/calcxx/calcxx-driver.hh
212 test -f %XSRC%/examples/calcxx/calc++-parser.cc
213 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.cc %XSRC%/examples/calcxx/calcxx-parser.cc
214 test -f %XSRC%/examples/calcxx/calcxx-parser.cc
215 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.cc %XSRC%/examples/calcxx/calcxx-parser.cc
216 test -f %XSRC%/examples/calcxx/calc++-parser.hh
217 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.hh %XSRC%/examples/calcxx/calcxx-parser.hh
218 test -f %XSRC%/examples/calcxx/calcxx-parser.hh
219 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.hh %XSRC%/examples/calcxx/calcxx-parser.hh
220 test -f %XSRC%/examples/calcxx/calc++-parser.stamp
221 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.stamp %XSRC%/examples/calcxx/calcxx-parser.stamp
222 test -f %XSRC%/examples/calcxx/calcxx-parser.stamp
223 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.stamp %XSRC%/examples/calcxx/calcxx-parser.stamp
224 test -f %XSRC%/examples/calcxx/calc++-parser.yy
225 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++-parser.yy %XSRC%/examples/calcxx/calcxx-parser.yy
226 test -f %XSRC%/examples/calcxx/calcxx-parser.yy
227 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp-parser.yy %XSRC%/examples/calcxx/calcxx-parser.yy
228 test -f %XSRC%/examples/calcxx/calc++.cc
229 if not errorlevel 1 mv -f %XSRC%/examples/calcxx/calc++.cc %XSRC%/examples/calcxx/calcxx.cc
230 test -f %XSRC%/examples/calcxx/calcxx.cc
231 if errorlevel 1 mv -f %XSRC%/examples/calcxx/calcpp.cc %XSRC%/examples/calcxx/calcxx.cc
232
233 Rem Fixing #include lines in calcxx files.
234 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx.cc > calcxx.cc
235 if errorlevel 1 goto calcxxFileError
236 mv ./calcxx.cc %XSRC%/examples/calcxx/calcxx.cc
237 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-driver.cc > calcxx-driver.cc
238 if errorlevel 1 goto calcxxFileError
239 mv ./calcxx-driver.cc %XSRC%/examples/calcxx/calcxx-driver.cc
240 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-driver.hh > calcxx-driver.hh
241 if errorlevel 1 goto calcxxFileError
242 mv ./calcxx-driver.hh %XSRC%/examples/calcxx/calcxx-driver.hh
243 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-parser.cc > calcxx-parser.cc
244 if errorlevel 1 goto calcxxFileError
245 mv ./calcxx-parser.cc %XSRC%/examples/calcxx/calcxx-parser.cc
246 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-parser.hh > calcxx-parser.hh
247 if errorlevel 1 goto calcxxFileError
248 mv ./calcxx-parser.hh %XSRC%/examples/calcxx/calcxx-parser.hh
249 :sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-parser.yy > calcxx-parser.yy
250 :if errorlevel 1 goto calcxxFileError
251 :mv ./calcxx-parser.yy %XSRC%/examples/calcxx/calcxx-parser.yy
252 sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-scanner.cc > calcxx-scanner.cc
253 if errorlevel 1 goto calcxxFileError
254 mv ./calcxx-scanner.cc %XSRC%/examples/calcxx/calcxx-scanner.cc
255 :sed "/#[ ]*include/s/++/xx/" %XSRC%/examples/calcxx/calcxx-scanner.ll > calcxx-scanner.ll
256 :if errorlevel 1 goto calcxxFileError
257 :mv ./calcxx-scanner.ll %XSRC%/examples/calcxx/calcxx-scanner.ll
258 sed "s/calc++/calcxx/" %XSRC%/examples/calcxx/test > test
259 if errorlevel 1 goto calcxxFileError
260 mv ./test %XSRC%/examples/calcxx/test
261
262
263 Rem Fixing the scanner files to make file names 8.3 valid.
264 Rem Use only if you want to change the scan-gram.l and scan-skel.l files.
265 : sed "/outfile=/s/\.yy/yy/" %XSRC%/src/scan-gram.l > scan-gram.l
266 : if errorlevel 1 goto ScannerFileError
267 : mv ./scan-gram.l %XSRC%/src/scan-gram.l
268 : sed "/outfile=/s/\.yy/yy/" %XSRC%/src/scan-skel.l > scan-skel.l
269 : if errorlevel 1 goto ScannerFileError
270 : mv ./scan-skel.l %XSRC%/src/scan-skel.l
271
272
273 Rem This is required because DOS/Windows are case-insensitive
274 Rem to file names, and "make install" will do nothing if Make
275 Rem finds a file called `install'.
276 if exist INSTALL ren INSTALL INSTALL.txt
277
278 Rem Set SHELL to a sane default or some configure tests stop working
279 Rem if the package is configured across partitions.
280 if not "%SHELL%" == "" goto HomeName
281 set SHELL=/bin/sh
282 if not "%SHELL%" == "/bin/sh" goto SmallEnv
283 echo No SHELL found in the environment, using default value
284
285 :HomeName
286 Rem Set HOME to a sane default so configure stops complaining.
287 if not "%HOME%" == "" goto HostName
288 set HOME=%XSRC%/djgpp
289 if not "%HOME%" == "%XSRC%/djgpp" goto SmallEnv
290 echo No HOME found in the environment, using default value
291
292 :HostName
293 Rem Set HOSTNAME so it shows in config.status
294 if not "%HOSTNAME%" == "" goto hostdone
295 if "%windir%" == "" goto msdos
296 set OS=MS-Windows
297 if not "%OS%" == "MS-Windows" goto SmallEnv
298 goto haveos
299 :msdos
300 set OS=MS-DOS
301 if not "%OS%" == "MS-DOS" goto SmallEnv
302 :haveos
303 if not "%USERNAME%" == "" goto haveuname
304 if not "%USER%" == "" goto haveuser
305 echo No USERNAME and no USER found in the environment, using default values
306 set HOSTNAME=Unknown PC
307 if not "%HOSTNAME%" == "Unknown PC" goto SmallEnv
308 goto userdone
309 :haveuser
310 set HOSTNAME=%USER%'s PC
311 if not "%HOSTNAME%" == "%USER%'s PC" goto SmallEnv
312 goto userdone
313 :haveuname
314 set HOSTNAME=%USERNAME%'s PC
315 if not "%HOSTNAME%" == "%USERNAME%'s PC" goto SmallEnv
316 :userdone
317 set _HOSTNAME=%HOSTNAME%, %OS%
318 if not "%_HOSTNAME%" == "%HOSTNAME%, %OS%" goto SmallEnv
319 set HOSTNAME=%_HOSTNAME%
320 :hostdone
321 set _HOSTNAME=
322 set OS=
323
324 Rem install-sh is required by the configure script but clashes with the
325 Rem various Makefile install-foo targets, so we MUST have it before the
326 Rem script runs and rename it afterwards
327 test -f %XSRC%/install-sh
328 if not errorlevel 1 goto NoRen0
329 test -f %XSRC%/install-sh.sh
330 if not errorlevel 1 mv -f %XSRC%/install-sh.sh %XSRC%/install-sh
331 :NoRen0
332
333 if "%NLS%" == "disabled" goto WithoutNLS
334
335 :WithNLS
336 Rem Check for the needed libraries and binaries.
337 test -x /dev/env/DJDIR/bin/msgfmt.exe
338 if errorlevel 1 goto MissingNLSTools
339 test -x /dev/env/DJDIR/bin/xgettext.exe
340 if errorlevel 1 goto MissingNLSTools
341 test -f /dev/env/DJDIR/include/libcharset.h
342 if errorlevel 1 goto MissingNLSTools
343 test -f /dev/env/DJDIR/lib/libcharset.a
344 if errorlevel 1 goto MissingNLSTools
345 test -f /dev/env/DJDIR/include/iconv.h
346 if errorlevel 1 goto MissingNLSTools
347 test -f /dev/env/DJDIR/lib/libiconv.a
348 if errorlevel 1 goto MissingNLSTools
349 test -f /dev/env/DJDIR/include/libintl.h
350 if errorlevel 1 goto MissingNLSTools
351 test -f /dev/env/DJDIR/lib/libintl.a
352 if errorlevel 1 goto MissingNLSTools
353
354 Rem Recreate the files in the %XSRC%/po subdir with our ported tools.
355 redir -e /dev/null rm %XSRC%/po/*.gmo
356 redir -e /dev/null rm %XSRC%/po/bison.pot
357 redir -e /dev/null rm %XSRC%/po/cat-id-tbl.c
358 redir -e /dev/null rm %XSRC%/po/stamp-cat-id
359
360 Rem Update the arguments file for the configure script.
361 Rem We prefer without-included-gettext because libintl.a from gettext package
362 Rem is the only one that is garanteed to have been ported to DJGPP.
363 echo --enable-nls --without-included-gettext >> arguments
364 goto ConfigurePackage
365
366 :MissingNLSTools
367 echo Needed libs/tools for NLS not found. Configuring without NLS.
368 :WithoutNLS
369 Rem Update the arguments file for the configure script.
370 echo --disable-nls >> arguments
371
372 :ConfigurePackage
373 echo Running the ./configure script...
374 sh ./configure @arguments
375 if errorlevel 1 goto CfgError
376 rm arguments
377 echo Done.
378 goto End
379
380 :lalr1_ccFileError
381 echo ./data/lalr1.cc file editing failed!
382 goto End
383
384 :calcxxFileError
385 echo ./examples/calcxx file editing failed!
386 goto End
387
388 :ScannerFileError
389 echo ./scanner file editing failed!
390 goto End
391
392 :SedError
393 echo ./configure script editing failed!
394 goto End
395
396 :SedError2
397 echo ./config.hin editing failed!
398 goto End
399
400 :CfgError
401 echo ./configure script exited abnormally!
402 goto End
403
404 :SmallEnv
405 echo Your environment size is too small. Enlarge it and run me again.
406 echo Configuration NOT done!
407
408 :End
409 test -f %XSRC%/install-sh.sh
410 if not errorlevel 1 goto NoRen1
411 test -f %XSRC%/install-sh
412 if not errorlevel 1 mv -f %XSRC%/install-sh %XSRC%/install-sh.sh
413 :NoRen1
414 if "%SHELL%" == "/bin/sh" set SHELL=
415 if "%HOME%" == "%XSRC%/djgpp" set HOME=
416 set ARGS=
417 set CONFIG_SITE=
418 set HOSTNAME=
419 set NLS=
420 set CACHING=
421 set DEPENDENCY_TRACKING=
422 set XSRC=