1 | A N T L R |
---|
2 | ====================================================================== |
---|
3 | |
---|
4 | Contents of this files is about i n s t a l l i n g ANTLR. If you |
---|
5 | want to get some general information please checkout file |
---|
6 | |
---|
7 | README.txt |
---|
8 | |
---|
9 | which is part of this package. You may als visit "doc/index.html" for |
---|
10 | further information as well as http://www.antlr.org in general. |
---|
11 | |
---|
12 | If you want to know about the very basic steps on u s i n g ANTLR |
---|
13 | then have a look into section |
---|
14 | |
---|
15 | ANTLR IS INSTALLED - WHAT'S NEXT? |
---|
16 | |
---|
17 | in file README.txt or in this file. You may also follow a simple |
---|
18 | mini-tutorial at |
---|
19 | |
---|
20 | http://www.antlr.org/article/cutpaste/index.html |
---|
21 | |
---|
22 | You may want to checkout also some target specific information on how |
---|
23 | to use ANTLR. Take a look at: |
---|
24 | |
---|
25 | doc/index.html - main entry for all documentation |
---|
26 | doc/runtime.html - when using JAVA |
---|
27 | doc/cpp-runtime.html - when using C++ |
---|
28 | doc/python-runtime.html - when using Python |
---|
29 | doc/csharp-runtime.html - when using C# |
---|
30 | |
---|
31 | If you don't have a precompiled version but rather a source code dis- |
---|
32 | tribution and you want to know some details on how to build and inst- |
---|
33 | all then you have come to the right place, |
---|
34 | |
---|
35 | PLEASE READ ON |
---|
36 | |
---|
37 | Otherwise please skip this document! |
---|
38 | |
---|
39 | |
---|
40 | ---------------------------------------------------------------------- |
---|
41 | TABLE OF CONTENTS |
---|
42 | |
---|
43 | * WHERE CAN I DOWNLOAD ANTLR? |
---|
44 | * REQUIREMENTS? |
---|
45 | * BUILD AND INSTALL? BRIEF VERSION! |
---|
46 | * BUILD AND INSTALL? LONG VERSION! |
---|
47 | * ANTLR IS INSTALLED - WHAT'S NEXT? |
---|
48 | * BUILD AND INSTALL ON WINDOWS NT/95/98/2000/XP? |
---|
49 | * FURTHER DETAILS ON ANTLR'S BUILD SETUP? |
---|
50 | * FAQ? |
---|
51 | * LIST OF CONFIGURED VARIABLES? |
---|
52 | * PLATFORMS? |
---|
53 | |
---|
54 | ______________________________________________________________________ |
---|
55 | WHERE CAN I DOWNLOAD ANTLR? |
---|
56 | |
---|
57 | ANTLR can be obtained from http://www.antlr.org either as |
---|
58 | |
---|
59 | * precompiled binary (RPM, MSI installer etc) |
---|
60 | * source distribution (tar + zipped) |
---|
61 | |
---|
62 | ______________________________________________________________________ |
---|
63 | REQUIREMENTS? |
---|
64 | |
---|
65 | To get most out of ANTLR you should build ANTLR on UNIX or UNIX like |
---|
66 | system. For example, you need a bourne shell and a couple of common |
---|
67 | UNIX tools like "grep", "mkdir", "cp", "rm", "sed", "cat" and "chmod". |
---|
68 | |
---|
69 | You need also a GNU make or compatible make. |
---|
70 | |
---|
71 | Such a ANTLR friendly eco-system is given on Windows by having CYGWIN |
---|
72 | or MSYS installed. An out-of-the-box Window system may will not work |
---|
73 | for installation. |
---|
74 | |
---|
75 | If you want to know on which systems ANTLR has been developed, which |
---|
76 | systems are known to work and known to fail then please move your |
---|
77 | cursor down near the end of this document. |
---|
78 | |
---|
79 | ______________________________________________________________________ |
---|
80 | BUILD AND INSTALL ANTLR? BRIEF VERSION! |
---|
81 | |
---|
82 | Here's a very brief summary of how to build and install ANTLR. |
---|
83 | |
---|
84 | $ cd $HOME |
---|
85 | $ gzip -d -c antlr-x.y.z.tar.gz | tar xvf - |
---|
86 | $ cd antlr-x.y.z |
---|
87 | $ ./configure --disable-examples |
---|
88 | $ make install |
---|
89 | |
---|
90 | Of course you can unpack ANTLR wherever you want on your machine - |
---|
91 | given enough space and permissions. For simplicuty, I'm just using |
---|
92 | $HOME and this may work for any user. |
---|
93 | |
---|
94 | ANTLR's source distribution contains lot's of examples. Making them |
---|
95 | can be quit longish. You may want to skip those examples if you are |
---|
96 | just interested in building the core libraries. Note that examples |
---|
97 | are not installed. |
---|
98 | |
---|
99 | Python users: Note that "make install" will not add antlr.py to your |
---|
100 | local Python installation. This needs to be done manually by you. To |
---|
101 | simplify this you may the script "pyantlr.sh". Checkout this script |
---|
102 | in directory "scripts" or, when installed, in directory "sbin". |
---|
103 | |
---|
104 | ______________________________________________________________________ |
---|
105 | BUILD AND INSTALL ANTLR? LONG VERSION! |
---|
106 | |
---|
107 | This section presents details on the build process. |
---|
108 | |
---|
109 | 1. Unpack |
---|
110 | ========= |
---|
111 | |
---|
112 | To build ANTLR you need to unpack ANTLR's source distribution. This |
---|
113 | will create a new directory named antlr-x.y.z in your current working |
---|
114 | directory. Typical unpacking steps are: |
---|
115 | |
---|
116 | $ cd $HOME ; |
---|
117 | $ gzip -d -c antlr-x.y.z.tar.gz | tar xvf - |
---|
118 | |
---|
119 | Here I'm unpacking ANTLR in my $HOME directory but you may unpack in |
---|
120 | any directory that suits you. If you have gnu tar, then you can use |
---|
121 | the simpler |
---|
122 | |
---|
123 | $ tar xvfz antlr-x.y.z.tar.gz |
---|
124 | |
---|
125 | to unpack the distro. |
---|
126 | |
---|
127 | For the rest of this document I will use ${srcdir} as a place holder |
---|
128 | to name the directory containing ANTLR sources. In the example given |
---|
129 | above, the following would be true: |
---|
130 | |
---|
131 | srcdir == $HOME/antlr-x.y.z |
---|
132 | |
---|
133 | |
---|
134 | 2. Build Directory |
---|
135 | ================== |
---|
136 | Create a build directory and change into that directory. A build dir- |
---|
137 | ectory can be any directory on your system. In the very brief version |
---|
138 | shown above I'm using the source directory -- ${srcdir} -- as build |
---|
139 | directory. However, the general way and also the better approach is |
---|
140 | to use a new, fresh and clean directory. If at any later stage some- |
---|
141 | thing goes wrong you can just remove the whole build directory and |
---|
142 | start from scratch again. You can also have ${srcdir} in read-only |
---|
143 | mode as no files are touched or changed with this approach. This is |
---|
144 | not the case if ${srcdir} and build directory are equal. |
---|
145 | |
---|
146 | $ mkdir -p $HOME/tmp/antlr |
---|
147 | $ cd $HOME/tmp/antlr |
---|
148 | |
---|
149 | |
---|
150 | 3. Configure |
---|
151 | ============ |
---|
152 | |
---|
153 | Building ANTLR is accomplished by the well known GNU autoconf/make |
---|
154 | approach. That is you run a shell script to create specialized |
---|
155 | files -- usually Makefiles -- for your particular environment. |
---|
156 | |
---|
157 | Within the build directory run configure like |
---|
158 | |
---|
159 | |
---|
160 | $ ${srcdir}/configure --prefix=${installdir} |
---|
161 | |
---|
162 | |
---|
163 | where ${srcdir} points to your package directory (see step 1). |
---|
164 | |
---|
165 | Option --prefix==${installdir} tells configure where you want to |
---|
166 | have ANTLR installed on your system. Using this option is not |
---|
167 | mandatory. If you are not using it then configure will use |
---|
168 | |
---|
169 | "/usr/local" |
---|
170 | |
---|
171 | as default installation directory. That is binaries will be |
---|
172 | installed in /usr/local/bin, libraries go into "/usr/local/lib" etc. |
---|
173 | |
---|
174 | Note that "configure" will search your $PATH for command line tools |
---|
175 | to compile Java, C++ and C# source code, execute Python etc. This |
---|
176 | behaviour of configure can be changed by using command line options |
---|
177 | and/or environment variables. |
---|
178 | |
---|
179 | To see a list of available configure options just run |
---|
180 | |
---|
181 | ${srcdir}/configure --help |
---|
182 | |
---|
183 | |
---|
184 | |
---|
185 | 4. Build |
---|
186 | ======== |
---|
187 | |
---|
188 | $ make |
---|
189 | |
---|
190 | This will (hopefully) build all needed ANTLR libraries within the |
---|
191 | "lib" directory. If something fails for your system, and you want to |
---|
192 | submit a bug report, you may wish to include your "config.status" |
---|
193 | file, your host type, operating system and compiler information, |
---|
194 | make output, and anything else you think will be helpful. |
---|
195 | |
---|
196 | If "make" complains about unknown rules etc. then it's usually |
---|
197 | because you are not running GNU make. Configure will search for a GNU |
---|
198 | make in $PATH and in some well known locations. If there's no GNU |
---|
199 | make on your system, then configure will report an error in step 3, |
---|
200 | otherwise the first suitable GNU make wins. However, if configure |
---|
201 | detects that "make" is not identical with the found one, configure |
---|
202 | will show a reminder message as last action. The reminder message |
---|
203 | will then tell you which make your are supposed to use. |
---|
204 | |
---|
205 | |
---|
206 | |
---|
207 | 5. Test |
---|
208 | ======= |
---|
209 | |
---|
210 | You may also wish to validate the correctness of the new ANTLR by |
---|
211 | running regression tests. It will makes you very confident if all |
---|
212 | test run through: |
---|
213 | |
---|
214 | $ make test |
---|
215 | |
---|
216 | However, please don't panic if a test fails. In most cases it is |
---|
217 | rather a problem of running the test itself than a problem with |
---|
218 | ANTLR. When sure about a bug let us know please. Be sure to include |
---|
219 | information on your system, the ANTLR version used and other relevant |
---|
220 | information. |
---|
221 | |
---|
222 | |
---|
223 | |
---|
224 | 6. Install |
---|
225 | ========== |
---|
226 | |
---|
227 | Depending on your ${installdir} directory you may need to have |
---|
228 | write permission to copy files. If you gained permissions required -- |
---|
229 | perhaps by becoming super user -- install ANTLR by |
---|
230 | |
---|
231 | |
---|
232 | $ make install |
---|
233 | |
---|
234 | Python users: Note that "make install" will NOT add antlr.py to your |
---|
235 | local Python installation. This needs to be done manually by you. To |
---|
236 | simplify this you may the script "pyantlr.sh". Checkout this script |
---|
237 | in directory "scripts" or, when installed, in directory "sbin". |
---|
238 | |
---|
239 | 7. Clean |
---|
240 | ======== |
---|
241 | |
---|
242 | Having installed ANTLR it is save to remove source and build |
---|
243 | directory. |
---|
244 | |
---|
245 | |
---|
246 | 8. Enjoy! |
---|
247 | ========= |
---|
248 | |
---|
249 | ______________________________________________________________________ |
---|
250 | ANTLR IS INSTALLED - WHAT'S NEXT? |
---|
251 | |
---|
252 | Please read "doc/getting-started.html" on what you are supposed to |
---|
253 | do. Here's a very brief summary for the impatient: |
---|
254 | |
---|
255 | ANTLR is a command line tool. To run ANTLR you need to have JAVA |
---|
256 | installed. The basic steps are: |
---|
257 | |
---|
258 | a. write a grammar file - mygrammar.g |
---|
259 | |
---|
260 | b. run ANTLR like |
---|
261 | |
---|
262 | $ CLASSPATH=<path-to>/antlr.jar |
---|
263 | |
---|
264 | $ java antlr.Tool mygrammar.g |
---|
265 | |
---|
266 | c. write a driver program using source code generated by ANTLR, ie. |
---|
267 | Main.java, main.cpp, Main.cs or main.py |
---|
268 | |
---|
269 | d. link generated code, your driver code, ANTLR's core library and |
---|
270 | any additional library you are using together to get an |
---|
271 | executable |
---|
272 | |
---|
273 | f. run the executable on arbitrary input to be parsed |
---|
274 | |
---|
275 | For a set of standard examples have a look into directory "examples" |
---|
276 | and appropriate subdirectories. You may want to run make like |
---|
277 | |
---|
278 | $ make verbose=1 |
---|
279 | |
---|
280 | to see which compiler is used and which flags are passed etc. You may |
---|
281 | also follow a simple mini-tutorial at |
---|
282 | |
---|
283 | http://www.antlr.org/article/cutpaste/index.html |
---|
284 | |
---|
285 | if you are absolutly new to ANTLR. |
---|
286 | |
---|
287 | ______________________________________________________________________ |
---|
288 | BUILD AND INSTALL ON WINDOWS NT/95/98/2000/XP? |
---|
289 | |
---|
290 | There is no difference in building and installing Windows. However, |
---|
291 | you are need have either Cygwin or MSYS installed. We haven't tried |
---|
292 | MKS yet. |
---|
293 | |
---|
294 | If you run configure with Cygwin (or MSYS) then gcj will usually be |
---|
295 | chosen for compiling Java and gcc for compiling C++. In most cases |
---|
296 | however, C# will be automatically disabled as no compiler can be |
---|
297 | found. |
---|
298 | |
---|
299 | Configure is not looking up the registry to check for installed soft- |
---|
300 | ware. Instead, configure will just check the $PATH for known compiler |
---|
301 | names and also check some well know locations like "/usr/local/bin" |
---|
302 | etc. |
---|
303 | |
---|
304 | In order to make configure aware of a certain compiler or tool you |
---|
305 | need, make sure that your compiler or tool can be found by looking up |
---|
306 | $PATH. For example, Microsoft Visual C++ comes with a batch file |
---|
307 | named vcvars32.bat. Just run this batch file prior of running bash to |
---|
308 | have "cl" in your $PATH. |
---|
309 | |
---|
310 | Configure knows about this compiler names: |
---|
311 | |
---|
312 | bcc32 cl g++ for C++ |
---|
313 | jikes javac gcj for Java |
---|
314 | csc mcs cscc for C# |
---|
315 | python for Python |
---|
316 | |
---|
317 | The order in which the names appear is also the search order. That |
---|
318 | means that the whole $PATH gets searched for bcc32, then for cl and |
---|
319 | finally for g++. |
---|
320 | |
---|
321 | In other words, it is sufficient to have "cl" in $PATH to have it |
---|
322 | selected by configure, regardless whether there is g++ available or |
---|
323 | not. Similar, if you also have bcc32 in $PATH, then the Borland C++ |
---|
324 | Compiler will be choosen. |
---|
325 | |
---|
326 | If you have more that one compiler in your $PATH and the "wrong" |
---|
327 | compiler is selected - Do you have to give up on this? |
---|
328 | |
---|
329 | Not at all. |
---|
330 | |
---|
331 | In case you have more than one compiler/tool in your $PATH, you can |
---|
332 | tell configure which one you like to have. For example: |
---|
333 | |
---|
334 | --with-cxx=g++ |
---|
335 | |
---|
336 | This will favor g++ regardless whether there's a cl or bcc in PATH. |
---|
337 | You can archive the very same by |
---|
338 | |
---|
339 | CXX=g++ ${srcdir}/configure |
---|
340 | |
---|
341 | That is by using an environment variable. Try --help for the full |
---|
342 | list of --with-xxx options and environment variables. |
---|
343 | |
---|
344 | ______________________________________________________________________ |
---|
345 | DETAILS ON CONFIGURE? |
---|
346 | |
---|
347 | This section will present some further details on how you can tell |
---|
348 | configure to behave the way you want: |
---|
349 | |
---|
350 | |
---|
351 | 1. Choose Language |
---|
352 | ================== |
---|
353 | |
---|
354 | ANTLR is implemented in Java and has code generator plugins for Java, |
---|
355 | C++, C# and Python. |
---|
356 | |
---|
357 | The default behaviour of configure is to check whether a suitable |
---|
358 | compiler or tool for a particular language is available. If not, then |
---|
359 | configure will show a warning message and will automatically disable |
---|
360 | support for this language. |
---|
361 | |
---|
362 | In a very bizarre case it is therefore possible to end up with a |
---|
363 | configuration with no language support at all. Please study therefore |
---|
364 | configure's output whether you end up with the system you want. |
---|
365 | |
---|
366 | On the contrary, configure will enable, as mentioned, every target |
---|
367 | language with sufficient compiler/tool support. To speed up the |
---|
368 | build process you may also disable languages (and configure them |
---|
369 | later again). This can be done by command line options: |
---|
370 | |
---|
371 | --disable-cxx | --enable-cxx=no --> disable C++ |
---|
372 | --disable-java | --enable-java=no --> disable Java |
---|
373 | --disable-csharp | --enable-csharp=no --> disable C# |
---|
374 | --disable-python | --enable-python=no --> disable Python |
---|
375 | |
---|
376 | Be warned that when disabling Java you can't even build ANTLR itself. |
---|
377 | |
---|
378 | |
---|
379 | 2. Be Verbose |
---|
380 | ============= |
---|
381 | |
---|
382 | A typical 'make' run reports all kinds of actions exactly the way |
---|
383 | they get carried out. This makes the output of a make run hard to |
---|
384 | read and it's difficult to keep track "where" make is right now and |
---|
385 | what's going on. |
---|
386 | |
---|
387 | ANTLR's make run has been designed to be readable. By default make |
---|
388 | will report what's going on in a kind of logical way. For example, |
---|
389 | when compiling ANTLR itself you will see a message like |
---|
390 | |
---|
391 | *** compiling 209 Java file(s) |
---|
392 | |
---|
393 | This information is usually enough to keep track what's going on. If |
---|
394 | compilation fails, then the exact command line causing the problem |
---|
395 | will be shown and you can study the arguments whether additional |
---|
396 | flags are required etc. |
---|
397 | |
---|
398 | However, you can tell configure to be verbose as usual by |
---|
399 | |
---|
400 | |
---|
401 | --enable-verbose |
---|
402 | |
---|
403 | |
---|
404 | Having enabled verbosity, the command to compile ANTLR will be shown |
---|
405 | similar like this (using javac): |
---|
406 | |
---|
407 | CLASSPATH= |
---|
408 | /opt/jdk32/142_03/bin/javac \ |
---|
409 | -d . \ |
---|
410 | -sourcepath /home/geronimo/src/antlrmain \ |
---|
411 | -classpath /home/geronimo/obj/antlr-linux/lib/antlr.jar \ |
---|
412 | Version.java \ |
---|
413 | ANTLRParser.java \ |
---|
414 | ... |
---|
415 | [[skipped 206 files]] |
---|
416 | ... |
---|
417 | /home/geronimo/src/antlrmain/antlr/debug/misc/JTreeASTPanel.java |
---|
418 | |
---|
419 | |
---|
420 | You have used --enable-verbose and output is too much. Do I need to |
---|
421 | configure again? |
---|
422 | |
---|
423 | No. Just run make like |
---|
424 | |
---|
425 | $ make verbose=0 |
---|
426 | |
---|
427 | to turn off verbosity for this make run. You can also do this |
---|
428 | |
---|
429 | $ verbose=0 |
---|
430 | $ export verbose |
---|
431 | $ make |
---|
432 | |
---|
433 | to turn verbosity off without using arguments to make. |
---|
434 | |
---|
435 | Of course, you can also turn verbosity on (verbose=1) in the very same |
---|
436 | way, regardless of what you have configured earlier. |
---|
437 | |
---|
438 | |
---|
439 | 3. Debug Version |
---|
440 | ================ |
---|
441 | |
---|
442 | A typical open source configuration sets compiler options to contain |
---|
443 | debug information. |
---|
444 | |
---|
445 | ANTLR's approach is a bit different. We believe that you want to |
---|
446 | u s e ANTLR and not to d e b u g it. In other words, we believe |
---|
447 | you are voting for speed. |
---|
448 | |
---|
449 | Therefore configure will set compiler flags that go for speed and we |
---|
450 | omit all flags introducing some debug information. |
---|
451 | |
---|
452 | If you need to go for debug information, turn those flags on by using |
---|
453 | |
---|
454 | --enable-debug |
---|
455 | |
---|
456 | Similar to verbose discussed in the previous section you can override |
---|
457 | this configuration setting by using |
---|
458 | |
---|
459 | $ make debug=0 -- no debug information |
---|
460 | $ make debug=1 -- turn debugging on |
---|
461 | |
---|
462 | without the need to reconfigure. But be aware that --enable-debug is |
---|
463 | just changing flags given to your compiler. It will not change any |
---|
464 | names. For example, the name of ANTLR's core library is libantlr.a |
---|
465 | (using g++) regardless of whether debug is on or off. |
---|
466 | |
---|
467 | |
---|
468 | 4. Examples |
---|
469 | =========== |
---|
470 | |
---|
471 | You may leave out the examples just by |
---|
472 | |
---|
473 | --disable-examples |
---|
474 | |
---|
475 | Note that you can't undo this without reconfiguration. Nevertheless, |
---|
476 | we recommend to configure with examples, test them and to study them |
---|
477 | to get a full understanding on how ANTLR works and - last but not |
---|
478 | least - about all it's capabilities. |
---|
479 | |
---|
480 | |
---|
481 | 5. Bootstrap |
---|
482 | ============ |
---|
483 | |
---|
484 | ANTLR's parser engine (ie. the parser that accepts a grammar file) is |
---|
485 | written in ANTLR itself. From a logical point of view you would need |
---|
486 | ANTLR to build ANTLR. This chicken and egg problem is solved simply |
---|
487 | by having generated source files enclosed in the package. |
---|
488 | |
---|
489 | However, if you are doing some surgery on ANTLR's internals you need |
---|
490 | to have a existing ANTLR version around. |
---|
491 | |
---|
492 | You can tell configure about this external ANTLR version by |
---|
493 | |
---|
494 | --with-antlr-jar=${some-install-dir}/lib/antlr.jar |
---|
495 | |
---|
496 | or by |
---|
497 | |
---|
498 | --with-antlr-cmd=${some-tool-running-antlr} |
---|
499 | |
---|
500 | |
---|
501 | The former version will add given jar file to the $CLASSPATH when |
---|
502 | trying to compile grammar files ( *.g). |
---|
503 | |
---|
504 | Very similar you can also use --with-antlr-cmd to provide a program |
---|
505 | or shell script to compile grammar files. The name of the program |
---|
506 | does not matter but it needs to be exectuable and it should support |
---|
507 | all flags that can be given to ANTLR (check java antlr.Tools -h). |
---|
508 | |
---|
509 | NOTE: |
---|
510 | |
---|
511 | Bootstraping ANTLR with an external jar file or program does will |
---|
512 | only taken into account if there's no lib/antlr.jar available in the |
---|
513 | build directory. In other words, if you bootstraped once and you make |
---|
514 | changes later on ANTLR's internals, then the previously build jar |
---|
515 | file antlr.jar will be used - regardless of your configuration |
---|
516 | options. |
---|
517 | |
---|
518 | |
---|
519 | 6. Which Make? |
---|
520 | ============== |
---|
521 | |
---|
522 | You need a GNU make to run the build. This is especially true when |
---|
523 | building ANTLR on Windows. Nevertheless, some efforts has been done |
---|
524 | to lower the dependency on GNU make for portability reasons. But we |
---|
525 | are not done yet. |
---|
526 | |
---|
527 | If you have GNU make installed on your system but it's not in your |
---|
528 | PATH or you want to have a special version of make, you may tell this |
---|
529 | configure by either |
---|
530 | |
---|
531 | --with-make=${list-of-candidates} |
---|
532 | |
---|
533 | or by using environment variable $MAKE like |
---|
534 | |
---|
535 | MAKE=${list-of-candidates} ${srcdir}/configure |
---|
536 | |
---|
537 | Which variant you are using is a matter of your personal taste. But |
---|
538 | be aware that the command line argument is overriding the environment |
---|
539 | variable. Consider this example: |
---|
540 | |
---|
541 | MAKE=x-make ${srcdir}/configure --with-make="y-make z-make" |
---|
542 | |
---|
543 | Here configure will check your $PATH for y-make and z-make bug x-make |
---|
544 | is ignored. |
---|
545 | |
---|
546 | Note that the withespace seperated ${list-of-candidates} may also |
---|
547 | contain absolute path names. In that case $PATH is not consulted but |
---|
548 | the file is directly checked for existence. Here's an example: |
---|
549 | |
---|
550 | MAKE='make /usr/bin/make' ${srcdir}/configure |
---|
551 | |
---|
552 | Here your $PATH is consulted whether a "make" exsists. Then |
---|
553 | /usr/bin/make is checked for existence. |
---|
554 | |
---|
555 | The first make found which is then a GNU make is the one choose to be |
---|
556 | used to build ANTLR. |
---|
557 | |
---|
558 | For consistency reasons you may also use --with-makeflags or variable |
---|
559 | $MAKEFLAGS to pass specific flags to make. However, this information |
---|
560 | is not yet used. Right now the flags used are the flags provided when |
---|
561 | calling make. |
---|
562 | |
---|
563 | 7. Which Java? |
---|
564 | ============== |
---|
565 | |
---|
566 | ANTLR has been tested with SUN Java 1.4.x using either SUN's javac |
---|
567 | Java compiler, IBM's jikes or GNU's gcj. Other systems have not been |
---|
568 | tested and are not expected to work. |
---|
569 | |
---|
570 | The default search order is |
---|
571 | |
---|
572 | jikes javac gcj |
---|
573 | |
---|
574 | It is therefore sufficient to have "jikes" in your $PATH to get it |
---|
575 | choosen by configure - regardless whether it precedes a javac or not |
---|
576 | in $PATH. |
---|
577 | |
---|
578 | You may change this default search by providing a list of candidates |
---|
579 | by either |
---|
580 | |
---|
581 | --with-javac=${candidate-list} |
---|
582 | |
---|
583 | or by |
---|
584 | |
---|
585 | JAVAC=${candidate-list} |
---|
586 | |
---|
587 | The candidates should be seperated by whitespace and may be relative |
---|
588 | or absolute path names. Only in the former case a lookup in $PATH |
---|
589 | takes place. |
---|
590 | |
---|
591 | By default options passed to a Java compiler are those who are |
---|
592 | sufficient to compile ANTLR. You may pass other flags by either |
---|
593 | |
---|
594 | --with-javacflags=${flags} |
---|
595 | |
---|
596 | JAVACFLAGS=${flags} |
---|
597 | |
---|
598 | In most cases you want to leave the default flags intact but rather |
---|
599 | add your additional flags. To support this, ANTLR's build management |
---|
600 | interprets ${flags} like this: |
---|
601 | |
---|
602 | ${flags} STANDARD FLAGS RESULT |
---|
603 | --------------+-----------------+---------------------- |
---|
604 | + f1 f2 .. fn | F1 .. FN | F1 .. FN f1 f2 .. fn |
---|
605 | - f1 f2 .. fn | F1 .. FN | f1 f2 .. fn F1 .. FN |
---|
606 | = f1 f2 .. fn | F1 .. FN | f1 f2 .. fn |
---|
607 | f1 f2 .... fn | F1 .. F | f1 f2 .. fn |
---|
608 | --------------+-----------------+---------------------- |
---|
609 | |
---|
610 | In other words, you can either tell configure to append (+), to |
---|
611 | prepend (-) or to substitute(=) your flags. |
---|
612 | |
---|
613 | |
---|
614 | Note that this is also possible when running make. For example, |
---|
615 | |
---|
616 | $ make JAVAC=jikes JAVACFLAGS="+ -verbose" |
---|
617 | |
---|
618 | would use jikes to compile regardless of what has been configured |
---|
619 | before. Additionally the flag "-verbose" is used. |
---|
620 | |
---|
621 | |
---|
622 | So far we talked about compiling Java. Let's have now a look on how |
---|
623 | to execute class files. By default configure searches for |
---|
624 | |
---|
625 | java gij |
---|
626 | |
---|
627 | to run Java. As discussed before it is sufficient to have a Java in |
---|
628 | $PATH to get java selected. It has also to be noted that gij is still |
---|
629 | in experimental stage and not fully supported now. |
---|
630 | |
---|
631 | As before you may also provide additional flags to Java by using |
---|
632 | either |
---|
633 | |
---|
634 | --with-javaflags=${flags} |
---|
635 | |
---|
636 | or by using environment variable |
---|
637 | |
---|
638 | JAVAFLAGS=${flags} |
---|
639 | |
---|
640 | Again, ${flags} are getting interpreted according to table shown |
---|
641 | above. |
---|
642 | |
---|
643 | 8. Which C++ Compiler? |
---|
644 | ====================== |
---|
645 | |
---|
646 | The algorithm on how the C++ compiler is choosen and how to pass |
---|
647 | additional flags are very much the same as discussed before for the |
---|
648 | Java compiler. |
---|
649 | |
---|
650 | The default candidate list for choosing a C++ compiler is |
---|
651 | |
---|
652 | bcc32 cl g++ on Windows ; and |
---|
653 | aCC CC xlC xlC_r g++ cxx c++ on UNIX. |
---|
654 | |
---|
655 | To change this list use |
---|
656 | |
---|
657 | --with-cxx=${candidates} |
---|
658 | |
---|
659 | and use |
---|
660 | |
---|
661 | --with-cxxflags=${flags} |
---|
662 | |
---|
663 | to pass additional flags to the standard compiler flags. You can also |
---|
664 | use $CXX and $CXXFLAGS if you like. This will then also work when |
---|
665 | running make. |
---|
666 | |
---|
667 | |
---|
668 | 9. Which C# Compiler? |
---|
669 | ===================== |
---|
670 | |
---|
671 | The only candidate for C# as time of writing is |
---|
672 | |
---|
673 | csc |
---|
674 | |
---|
675 | for compiling C# source code. To change this option |
---|
676 | |
---|
677 | --with-csharpc=${candidates} |
---|
678 | |
---|
679 | and use |
---|
680 | |
---|
681 | --with-csharpcflags=${flags} |
---|
682 | |
---|
683 | for providing a list of additional options. Note that ${flags} are |
---|
684 | getting interpreted as discussed in the previous sections. |
---|
685 | |
---|
686 | Instead of command line arguments to configure you may also use |
---|
687 | $CSHARPC and $CSHARPCFLAGS. This variables are also working when |
---|
688 | running make. |
---|
689 | |
---|
690 | 10. Which Python? |
---|
691 | ================= |
---|
692 | |
---|
693 | Configure is searching for "python" in your $PATH and in some well |
---|
694 | known locations. If no "python" can be found, language support for |
---|
695 | Python is disabled. |
---|
696 | |
---|
697 | You may use |
---|
698 | |
---|
699 | --with-python="${candidates}" |
---|
700 | |
---|
701 | to provide a list of Python candidates and further you may use |
---|
702 | |
---|
703 | --with-pythonflags="${flags}" |
---|
704 | |
---|
705 | to provide a list of (additional) flags to be passed to Python on |
---|
706 | execution. Note that ${flags} is getting interpreted as discussed in |
---|
707 | the previous sections. |
---|
708 | |
---|
709 | You may also use $PYTHON and $PYTHONFLAGS instead. This variables are |
---|
710 | then also working when running make. Note that those variable may |
---|
711 | override what has been configured before without any warning. |
---|
712 | |
---|
713 | |
---|
714 | |
---|
715 | ______________________________________________________________________ |
---|
716 | FURTHER DETAILS ON ANTLR'S BUILD SETUP? |
---|
717 | |
---|
718 | |
---|
719 | In allmost all cases it is assumed to be sufficient to change compiler |
---|
720 | settings by using either --with-${lang}flags or by using ${LANG}FLAGS. |
---|
721 | |
---|
722 | It's most likely not sufficient if you want to support a new compiler, |
---|
723 | tool or a new operating system. |
---|
724 | |
---|
725 | The general idea is to have a configured shell script for each tool |
---|
726 | or compiler being used rather than doing the scripting within the |
---|
727 | Makefile itself. The reason for this is that scripting in Makefiles is |
---|
728 | rather hard to read and a pain to debug (for example, there's no line |
---|
729 | information). |
---|
730 | |
---|
731 | The configured shell scripts are to be found in subdirectory "scripts" |
---|
732 | within the build directory. Their originals are located in |
---|
733 | |
---|
734 | ${srcdir}/scripts |
---|
735 | |
---|
736 | This scripts are known at time of writing: |
---|
737 | |
---|
738 | antlr.sh.in - runs "java antlr.Tools" |
---|
739 | cxx.sh.in - run C++ compiler |
---|
740 | cpp.sh.in - run C/C++ preprocessor (for dependencies). |
---|
741 | jars.sh.in - how to make a static library (aka jar file)(Java) |
---|
742 | javac.sh.in - run Java compiler (also when using jikes etc) |
---|
743 | lib.sh.in - how to make a static library (C++) |
---|
744 | link.sh.in - how to make a executable (C++) |
---|
745 | python.sh.in - how to run python |
---|
746 | |
---|
747 | A Makefile contains nothing more than variables and rules and in all- |
---|
748 | most all cases (but simple exceptions) the command behind a rule is |
---|
749 | just executing a script. |
---|
750 | |
---|
751 | Note that these scripts are not intended to be used to compile C++, |
---|
752 | Java etc in general. Instead this scripts are specialized for ANTLR. |
---|
753 | |
---|
754 | For example, the script "lib.sh" has a very simple interface. All |
---|
755 | you can provide is a list of object files. There is no option to |
---|
756 | tell about the library name to be build. Instead the library name |
---|
757 | is set by configure and available by using @ANTLR_LIB@ in all |
---|
758 | configured files. |
---|
759 | |
---|
760 | Unfortunatly, all scripts are rather complex and limiting ourselfs of |
---|
761 | not using shell functions (portability) is not going make changes |
---|
762 | easier. |
---|
763 | |
---|
764 | In general you should only edit the upper part of any script till |
---|
765 | there's a line like "**NO CHANGE NECESSARY BELOW THIS LINE - EXPERTS |
---|
766 | ONLY**". |
---|
767 | |
---|
768 | |
---|
769 | Then let's have now a closer look at cxx.sh.in. The other scripts are |
---|
770 | very similar. I'm going to discuss here only the relevant parts - this |
---|
771 | is open source after all any you may try to understand it by reading |
---|
772 | the source code :-) |
---|
773 | |
---|
774 | ARGV="$*" |
---|
775 | |
---|
776 | In general all arguments given to the script file are collected with- |
---|
777 | in variable $ARGV. In some scripts, the very first argument has a |
---|
778 | special meaning - usually it tells about the target to be created. In |
---|
779 | such a case |
---|
780 | |
---|
781 | TARGET |
---|
782 | |
---|
783 | would hold the first argument given and ARGV would hold all others. |
---|
784 | |
---|
785 | if test -z "${CXX}" ; then |
---|
786 | CXX="@CXX@" |
---|
787 | cxx="@cxx@" |
---|
788 | else |
---|
789 | cxx="`basename $CXX`" |
---|
790 | cxx="`echo $cxx|sed 's,\..*$,,'`" |
---|
791 | fi |
---|
792 | |
---|
793 | This script snippet checks about the compiler to be used for compiling |
---|
794 | C++ source. Note that we have two variables, CXX and cxx. The former |
---|
795 | holds usually the absolute path of the compiler as configured. The |
---|
796 | later, cxx, contains the logical compiler name. The logical compiler |
---|
797 | name is "gcc" for GNU, "cl" for Microsoft C++ etc. etc. |
---|
798 | |
---|
799 | The logical compiler name is usually configured and available as @cxx@. |
---|
800 | However, a user overrides the configuration by using environment |
---|
801 | variable CXX, the logical compiler name is computed by removing any |
---|
802 | extension. |
---|
803 | |
---|
804 | In a further section (similar in other scripts) we set specific flags |
---|
805 | depending on the l o g i c a l compiler name. As you can see it is |
---|
806 | rather important to the logical name proper. |
---|
807 | |
---|
808 | case "${cxx}" in |
---|
809 | gcc) |
---|
810 | cxxflags="-felide-constructors -pipe" |
---|
811 | case "${DEBUG}" in |
---|
812 | 0) |
---|
813 | cxxflags="-O2 -DNDEBUG ${cxxflags}" |
---|
814 | ;; |
---|
815 | 1) |
---|
816 | cxxflags="-g ${cxxflags} -W -Wall" |
---|
817 | ;; |
---|
818 | esac |
---|
819 | ;; |
---|
820 | cl) |
---|
821 | cxxflags="/nologo -GX -GR" |
---|
822 | [[skipped]] |
---|
823 | esac |
---|
824 | |
---|
825 | In the snippet shown you can see the handling of "gcc" and "cl". Note that |
---|
826 | the compiler flags are saved in $cxxflags and not in $CXXFLAGS. Reason |
---|
827 | for this is that handling of environment variable $CXXFLAGS is rather |
---|
828 | longish due to ANTLR's special interpretation mechanism (as discussed |
---|
829 | in an earlier section). |
---|
830 | |
---|
831 | In some cases flags may depend on platform in use. In that case you may |
---|
832 | do something like: |
---|
833 | |
---|
834 | |
---|
835 | case ${cxx} in |
---|
836 | gcc) |
---|
837 | case @build_os@ in |
---|
838 | cygwin) |
---|
839 | ## cygwin specific flags .. |
---|
840 | ;; |
---|
841 | sparc) |
---|
842 | ## sparc specific .. |
---|
843 | ;; |
---|
844 | *) |
---|
845 | ## all others |
---|
846 | ;; |
---|
847 | esac |
---|
848 | .. |
---|
849 | esac |
---|
850 | |
---|
851 | Of course you can utilize here the full scripting power to set flags |
---|
852 | required to get compilation job done. |
---|
853 | |
---|
854 | ______________________________________________________________________ |
---|
855 | FAQ? |
---|
856 | |
---|
857 | 1. How to setup jikes boot classpath? |
---|
858 | ===================================== |
---|
859 | |
---|
860 | Jikes (http://www-124.ibm.com/developerworks/oss/jikes) is just a |
---|
861 | Java compiler that needs to know about Java's core classes, ie. |
---|
862 | rt.jar, for a successful build of ANTLR. By default configure tries |
---|
863 | to locate rt.jar by searching $PATH for a java executable and |
---|
864 | relative to where found, for ../jre/lib/rt.jar. |
---|
865 | |
---|
866 | If this search fails or if you want to pass a different Java core or |
---|
867 | further core libraries, you may use either option |
---|
868 | |
---|
869 | --with-bootclasspath="${args}" |
---|
870 | |
---|
871 | or environment variable |
---|
872 | |
---|
873 | BOOTCLASSPATH="${args}" |
---|
874 | |
---|
875 | The list of arguments, ${args}, is supposed to be list of whitespace |
---|
876 | seperated files or directories. Configure will validate that each |
---|
877 | argument exists and will fail otherwise. Besides this there are no |
---|
878 | further validations done - you are supposed to know what you are |
---|
879 | doing. Note also that configure will not perform any search in case |
---|
880 | a bootclasspath is given. |
---|
881 | |
---|
882 | The arguments given are concatenated using platform specific argument |
---|
883 | seperator (ie. ";" or ":") and passed to option --bootclasspath. |
---|
884 | |
---|
885 | 2. Can I just say "make" after having unpacked ANTLR? |
---|
886 | ===================================================== |
---|
887 | |
---|
888 | No - as explained previously you need to run "configure" before you |
---|
889 | can issue a "make". |
---|
890 | |
---|
891 | 3. How do I cleanup afterwards? |
---|
892 | =============================== |
---|
893 | |
---|
894 | You do a "make clean" to remove all object files. If you do a "make |
---|
895 | distclean", then all files generated by ANTLR are also removed. In |
---|
896 | this case you need a external antlr.jar somewhere to rebuild. |
---|
897 | |
---|
898 | If you are using a external build directory you may just remove the |
---|
899 | whole directory without any harm. |
---|
900 | |
---|
901 | 4. Is it safe to edit a Makefile? |
---|
902 | ================================= |
---|
903 | |
---|
904 | In general do not edit files named Makefile. Instead edit files |
---|
905 | named Makefile.in. Configure or config.status will override changes |
---|
906 | you made in a Makefile on any run. |
---|
907 | |
---|
908 | 5. I changed Makefile.in - what's next? |
---|
909 | ======================================= |
---|
910 | |
---|
911 | Just run make again. Each Makefile contains a rule that automatically |
---|
912 | remakes itself if corresponding Makefile.in has changed. |
---|
913 | |
---|
914 | This automatic rule works fine in general. However, if you change |
---|
915 | Makefile/Makefile.in in such a way that make rejects it's execution |
---|
916 | then you need to remake Makefile yourself. |
---|
917 | |
---|
918 | This can be done by |
---|
919 | |
---|
920 | $ cd ${builddir} |
---|
921 | $ ./config.status ${your-makefile} |
---|
922 | |
---|
923 | Here's an example. Assume that "antlr/Makefile" is corrupted. The do |
---|
924 | this: |
---|
925 | |
---|
926 | ./config.status antlr/Makefile |
---|
927 | |
---|
928 | You can also issue just a |
---|
929 | |
---|
930 | $ ./config.status |
---|
931 | |
---|
932 | In this case all configured files are regenerated. |
---|
933 | |
---|
934 | 6. My configure has changed - what's next? |
---|
935 | ============================================= |
---|
936 | |
---|
937 | You need to reconfigure each build directory to get the changes. So |
---|
938 | far no automatic rule has been implemented. The easiest way of being |
---|
939 | up-to-date is: |
---|
940 | |
---|
941 | $ cd ${builddir} && ./config.status --recheck && make |
---|
942 | |
---|
943 | 7. Where do I find antlr.jar? |
---|
944 | ============================= |
---|
945 | |
---|
946 | Have a look at "lib". Should be there - but it is subject of having |
---|
947 | enabled Java or not. Note that Java gets automatically disabled if |
---|
948 | there's no sufficient Java compiler found (warning message would be |
---|
949 | dumped in that case). |
---|
950 | |
---|
951 | 8. How can I make "make" nosiy? |
---|
952 | =============================== |
---|
953 | |
---|
954 | By default make just tells you what's going on in a very brief way. |
---|
955 | To change this just do this: |
---|
956 | |
---|
957 | $ make verbose=1 |
---|
958 | |
---|
959 | You can also tell configure to turn verbosity on by default by using |
---|
960 | option |
---|
961 | |
---|
962 | --enable-verbose. |
---|
963 | |
---|
964 | Run "configure --help" for a list of options available. |
---|
965 | |
---|
966 | 9. Am I able to run "make" in a subdirectory? |
---|
967 | ============================================= |
---|
968 | |
---|
969 | Sure. |
---|
970 | |
---|
971 | 10. Is it safe to remove configured subdirectory? |
---|
972 | ================================================= |
---|
973 | |
---|
974 | In general "yes" but you want to do this only within the build tree. |
---|
975 | |
---|
976 | For example, let's assume that you are tired of getting standard |
---|
977 | examples tested. Then just move on and remove subdirectory |
---|
978 | "examples". |
---|
979 | |
---|
980 | |
---|
981 | ______________________________________________________________________ |
---|
982 | LIST OF CONFIGURED VARIABLES? |
---|
983 | |
---|
984 | ANTLRFLAGS |
---|
985 | ANTLR_ACTION_FILES |
---|
986 | ANTLR_ANTLR_FILES |
---|
987 | ANTLR_COMPILE_CMD |
---|
988 | ANTLR_CYGWIN |
---|
989 | ANTLR_JAR |
---|
990 | ANTLR_LIB |
---|
991 | ANTLR_MINGW |
---|
992 | ANTLR_NET |
---|
993 | ANTLR_PY |
---|
994 | ANTLR_TOKDEF_FILES |
---|
995 | ANTLR_WIN32 |
---|
996 | ANTLR_WITH_ANTLR_CMD |
---|
997 | ANTLR_WITH_ANTLR_JAR |
---|
998 | AR |
---|
999 | ARFLAGS |
---|
1000 | AS |
---|
1001 | BOOTCLASSPATH |
---|
1002 | CSHARPC |
---|
1003 | CSHARPCFLAGS |
---|
1004 | CSHARP_COMPILE_CMD |
---|
1005 | CXX_COMPILE_CMD |
---|
1006 | CXX_LIB_CMD |
---|
1007 | CXX_LINK_CMD |
---|
1008 | CYGPATH |
---|
1009 | DEBUG |
---|
1010 | EXEEXT |
---|
1011 | JAR |
---|
1012 | JARFLAGS |
---|
1013 | JAR_CMD |
---|
1014 | JAVA |
---|
1015 | JAVAC |
---|
1016 | JAVACFLAGS |
---|
1017 | JAVAFLAGS |
---|
1018 | JAVA_CMD |
---|
1019 | JAVA_COMPILE_CMD |
---|
1020 | LIBEXT |
---|
1021 | MAKE |
---|
1022 | OBJEXT]) |
---|
1023 | PATCHLEVEL |
---|
1024 | PYTHON |
---|
1025 | PYTHONFLAGS |
---|
1026 | SUBVERSION |
---|
1027 | VERBOSE |
---|
1028 | VERSION |
---|
1029 | WITH_EXAMPLES |
---|
1030 | abs_this_builddir |
---|
1031 | cxx |
---|
1032 | jar |
---|
1033 | java |
---|
1034 | javac |
---|
1035 | |
---|
1036 | ______________________________________________________________________ |
---|
1037 | PLATFORMS? |
---|
1038 | |
---|
1039 | ANTLR has been developed and tested on platforms listed below. A |
---|
1040 | platform is considered supported and tested if basically all standard |
---|
1041 | examples are working. |
---|
1042 | |
---|
1043 | Devel for ANTLR 2.7.5 took place on: |
---|
1044 | |
---|
1045 | i686-linux2.6.3-7mk |
---|
1046 | - Java 1.4.2, gcj 3.3.4, jikes 1.16, 1.17, 1.18, 1.19, 1.20, 1.21, 1.22 |
---|
1047 | - gcc 3.3.2, gcc 3.3.4 |
---|
1048 | - Python 2.3, 2.4 |
---|
1049 | - DotGNU 0.6.0 |
---|
1050 | |
---|
1051 | i686-cygwin_nt-5.1 |
---|
1052 | - Java 1.4.2, gcj 3.3.3, jikes 1.22 |
---|
1053 | - gcc 3.3.3, bcc32 5.6 (Borland C++), cl 13.10.3077 (Microsoft C++) |
---|
1054 | - csc 7.10.6001.4 (Visual C# .NET Compiler) |
---|
1055 | - Python 2.2, 2.3, 2.4 |
---|
1056 | - Mono 1.0.5 |
---|
1057 | |
---|
1058 | ANTLR has been tested on: |
---|
1059 | |
---|
1060 | MinGW-3.1.0.1 (needs manual install of cygpath!) |
---|
1061 | - MSys 1.0.10 |
---|
1062 | - Java 1.5.0-b64 |
---|
1063 | - gcc 3.4.1 |
---|
1064 | |
---|
1065 | PowerPC or RS/6000: |
---|
1066 | * powerpc-apple-darwin6.8 (MacOS 1o, "Jaguar") |
---|
1067 | - Java 1.4.1, jikes 1.15 |
---|
1068 | - gcc 3.1 |
---|
1069 | - Python 2.2 |
---|
1070 | - Mono (?) also reported to work. |
---|
1071 | |
---|
1072 | SPARC: |
---|
1073 | * sparc-sun-solaris2.8 |
---|
1074 | - Java 1.4.1 |
---|
1075 | - SUN CC 5.6 |
---|
1076 | |
---|
1077 | Known n o t to work: |
---|
1078 | - jikes 1.13 and older due to missing classpath and bootclasspath |
---|
1079 | options. Jikes 1.14 and 1.15 are not tested due to compilation |
---|
1080 | problems compiling jikes itself (on Mandrake 1o). |
---|
1081 | |
---|
1082 | - Python < 2.2 will not work. |
---|
1083 | |
---|
1084 | - gcc 2.* will not work. |
---|
1085 | |
---|
1086 | - You need to have GNU make (for building). |
---|
1087 | ====================================================================== |
---|
1088 | INSTALL.txt - last update January 11th, 2005 |
---|
1089 | |
---|
1090 | |
---|