1build(3)                            ANTLR3C                           build(3)
2
3
4

NAME

6       build - Building From Source The C runtime is provided in source code
7       form only as there are too many binary versions to sensibly maintain
8       binaries on www.antlr.org.
9
10       The runtime code is provided with .sln and .vcproj files for Visual
11       Studio 2005 and 2008, and configure files for building and installation
12       on UNIX or other systems that support this tool. If your system is
13       neither Windows nor configure compatible, then you should find it
14       reasonable to build the code manually (see section 'Building
15       Manually'.)
16

Source Code Organization

18       The source code expands from a tar/zip file to give you the following
19       directories:
20
21./ The location of the configure script and the antlr3config.h file
22         generated by the running the configure script.This directory also
23         contains the solution and project files for visual studio 2005 and
24         2008.
25
26./src The location of all the C files in the project.
27
28./include The location of all the header files for the project
29
30./doxygen The location of documentation files such as the one that
31         generates this page
32
33       • Other ancillary directories used by the build or documentation
34         process.
35

Building for Windows

37       If you are building for Cygwin, or a similar UNIX on Windows System,
38       follow the 'Building With Configure' instructions below.
39
40       Note that the runtime is no longer compatible with the VC6 Microsoft
41       compiler. If you absolutely need to build with this compiler, you can
42       probably hack the source code to deall with the pieces that VC6 cannot
43       handle such as the ULL suffix for constants.
44
45       If you wish to build the binaries for Windows using Visual Studio 2005,
46       or 2008 you may build using the IDE:
47
48       1.  Open the C.sln file
49
50       2.  Select batch Build from the Build menu
51
52       3.  Select all configurations and press the build button.
53
54       If you wish or need to build the libraries from the command line, then
55       you must use a Windows command shell configured for access to
56       VS2005/VS2008 compilers, such as the one that is started from:
57
58       Start->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio
59       2005 Command Prompt
60
61       There appears to be no way to build all targets at once in a batch mode
62       from the command line, so you may build one or all of the following:
63
64          C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build ReleaseDLL
65          C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build Release
66          C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build DebugDLL
67          C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build Debug
68
69
70       After the build is complete you will find the \c.\cDLL and \c.\cLIB files under the directory containing C.sln,
71       in a subdirectory named after the /Build target. In the Release and Debug targets, you will find that there is only a \c.\cLIB archive file,
72       which you can link directly into your own projects if you wish to avoid the DLL. In \c ReleaseDLL and \c DebugDLL you will find both a
73       \c .LIB file which you should link your projects with and a DLL. The library and names on Windows are as follows:
74
75       \verbatim
76
77
78       • ReleaseDLL : ANTLR3C.DLL and ANTLR3C_DLL.LIB
79
80       • DebugDLL : ANTLR3CD.DLL and ANTLR3CD_DLL.LIB
81
82       • Release : ANTLR3C.LIB
83
84       • Debug : ANTLR3CD.LIB
85
86       There currently no .msi modules or other installs built for Windows, so you must place the DLLs in a directory referenced
87       by the PATH environment variable and make the include directory available to your project configurations.
88
89
90       \section configure Building with configure
91
92       Before starting, make sure that you are using a source code distribution and not the source code directly from the
93       Perforce repository. If you use the source from the perforce tree directly, you will find that there is no configure
94       script as this is generated as part of the distribution build by the maintainers. If you feel the need to build from
95       the distribution tree then you must have all the autobuild packages available on your system and can generate the
96       configure script using autoreconf. If you are not familiar with these tools, then please use the tgz files in the
97       dist subdirectory (or downloaded from the ANTLR web site).
98
99       The source code file should be expanded in a directory of your choice (probably your working directory) using the command:
100
101       \verbatim
102
103
104        gzip -dc antlrtgzname.tar.gz | tar xvf -
105
106       Where: <b>antlrtgzname.tar.gz</b> is of course the name of the tar when you downloaded it. You should find a \b configure script in the sub directory thus created.
107
108       The configure script accepts the usual options, such as --prefix= but the default is to build in the source directory and to place libraries in
109       <b>/usr/local/lib</b> and include files (for building your recognizers) in <b>/usr/local/include</b>. There are also a number of antlr specific options, which you may wish to utilize. The command:
110       \verbatim
111
112
113        ./configure --help
114
115       Will document the latest incarnations of these options in case this documentation is ever out of date. At this time the options are:
116
117       \verbatim
118
119
120        --enable-debuginfo Compiles debug info into the library (default no)
121       --enable-64bit Turns on flags that produce 64 bit object code if any
122       are required (default no)
123
124       Unless you need 64 bit builds, or a change in library types, you will generally use the configure command without options:
125
126       Here is a sample configure output:
127
128       \verbatim
129
130
131        [jimi@localhost dist]$ tar zvxf libantlr3c-3.0.0-rc8.tar.gz
132
133       libantlr3c-3.0.0-rc8/ libantlr3c-3.0.0-rc8/antlr3config.h
134       libantlr3c-3.0.0-rc8/src/ libantlr3c-3.0.0-rc8/src/antlr3stringstream.c
135       ... libantlr3c-3.0.0-rc8/antlr3config.h.in
136
137       [jimi@localhost dist]$ cd libantlr3c-3.0.0-rc
138
139
140       [jimi@localhost libantlr3c-3.0.0-rc8]$ ./configure
141
142       checking for a BSD-compatible install... /usr/bin/install -c
143       checking whether build environment is sane... yes
144       checking for a thread-safe mkdir -p... /bin/mkdir -p
145       checking for gawk... gawk
146       checking whether make sets $(MAKE)... yes
147       checking for xlc... no
148       checking for aCC... no
149       checking for gcc... gcc
150       ...
151       checking for strdup... yes
152       configure: creating ./config.status
153       config.status: creating Makefile
154       config.status: creating antlr3config.h
155       config.status: antlr3config.h is unchanged
156       config.status: executing depfiles commands
157
158
159       Having configured the library successfully, you need only make it, and install it:
160
161       \verbatim
162
163
164        [jimi@localhost libantlr3c-3.0.0-rc8]$ make
165
166       make  all-am
167       make[1]: Entering directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
168       /bin/sh ./libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -Iinclude -Iinclude    -O2  -MT antlr3baserecognizer.lo -MD -MP -MF .deps/antlr3baserecognizer.Tpo -c -o antlr3baserecognizer.lo `test -f 'src/antlr3baserecognizer.c' || echo './'`src/antlr3baserecognizer.c
169       ...
170       gcc  -shared  .libs/antlr3baserecognizer.o .libs/antlr3basetree.o .libs/antlr3basetreeadaptor.o .libs/antlr3bitset.o .libs/antlr3collections.o .libs/antlr3commontoken.o .libs/antlr3commontree.o .libs/antlr3commontreeadaptor.o .libs/antlr3commontreenodestream.o .libs/antlr3cyclicdfa.o .libs/antlr3encodings.o .libs/antlr3exception.o .libs/antlr3filestream.o .libs/antlr3inputstream.o .libs/antlr3intstream.o .libs/antlr3lexer.o .libs/antlr3parser.o .libs/antlr3string.o .libs/antlr3stringstream.o .libs/antlr3tokenstream.o .libs/antlr3treeparser.o .libs/antlr3rewritestreams.o .libs/antlr3ucs2inputstream.o   -Wl,-soname -Wl,libantlr3c.so -o .libs/libantlr3c.so
171       ar cru .libs/libantlr3c.a  antlr3baserecognizer.o antlr3basetree.o antlr3basetreeadaptor.o antlr3bitset.o antlr3collections.o antlr3commontoken.o antlr3commontree.o antlr3commontreeadaptor.o antlr3commontreenodestream.o antlr3cyclicdfa.o antlr3encodings.o antlr3exception.o antlr3filestream.o antlr3inputstream.o antlr3intstream.o antlr3lexer.o antlr3parser.o antlr3string.o antlr3stringstream.o antlr3tokenstream.o antlr3treeparser.o antlr3rewritestreams.o antlr3ucs2inputstream.o
172       ranlib .libs/libantlr3c.a
173       creating libantlr3c.la
174
175       (cd .libs && rm -f libantlr3c.la && ln -s ../libantlr3c.la libantlr3c.la)
176       make[1]: Leaving directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
177
178
179       [jimi@localhost libantlr3c-3.0.0-rc8]$ sudo make install
180
181
182       make[1]: Entering directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
183       test -z '/usr/local/lib' || /bin/mkdir -p '/usr/local/lib'
184        /bin/sh ./libtool --mode=install /usr/bin/install -c  'libantlr3c.la' '/usr/local/lib/libantlr3c.la'
185       /usr/bin/install -c .libs/libantlr3c.so /usr/local/lib/libantlr3c.so
186       /usr/bin/install -c .libs/libantlr3c.lai /usr/local/lib/libantlr3c.la
187       /usr/bin/install -c .libs/libantlr3c.a /usr/local/lib/libantlr3c.a
188       ...
189        /usr/bin/install -c -m 644 'include/antlr3stringstream.h' '/usr/local/include/antlr3stringstream.h'
190       ...
191        /usr/bin/install -c -m 644 'antlr3config.h' '/usr/local/include/antlr3config.h'
192       make[1]: Leaving directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
193
194       [jimi@localhost libantlr3c-3.0.0-rc8]$
195
196
197       You are now ready to generate C recognizers and compile and link them with the ANTLR 3 C Runtime.
198
199
200       \section buildman Building Manually
201
202       The only step that configure performs that cannot be done
203       manually (without effort) is to produce the header file
204       \c antlr3config.h, which contains typedefs of the fundamental types
205       that your local C compiler supports. The easiest way to produce
206       this file for your system, if you cannot port \b automake and \b configure
207       to the system is:
208
209       -# Run configure on a system that does support configure
210       -# Copy the generated \c antlr3config.h file to the target system
211       -# Edit the file locally and change any types that differ on this
212         system to the target systems. There are only a few types and you should
213         find this relatively easy.
214
215       Having produced a compatible antlr3config.h file, then you should be able to
216       compile the source files in the \c ./src subdirectory, providing an include path
217       to the location of \c antlr3config.h and the \c ./include subdirectory. Something akin
218       to:
219       \verbatim
220
221
222        ~/C/src: cc -c -O -I.. -I../include *.c
223
224       Having produced the .o (or equivalent) files for the local system you can then
225       build an archive or shared library for the C runtime.
226
227       When you wish to build and link with the C runtime, specify the path to the
228       supplied header files, and the path to the library that you built.
229
230Version 3.3.1                   Wed Jul 20 2022                       build(3)
Impressum