xref: /aosp_15_r20/external/antlr/runtime/C/doxygen/build.dox (revision 16467b971bd3e2009fad32dd79016f2c7e421deb)
1*16467b97STreehugger Robot/// \page build Building From Source
2*16467b97STreehugger Robot///
3*16467b97STreehugger Robot/// The C runtime is provided in source code form only as there are too many binary
4*16467b97STreehugger Robot/// versions to sensibly maintain binaries on www.antlr.org.
5*16467b97STreehugger Robot///
6*16467b97STreehugger Robot/// The runtime code is provided with .sln and .vcproj files for Visual Studio 2005 and 2008,
7*16467b97STreehugger Robot/// and \b configure files for building and installation on UNIX or other systems that support this tool. If your
8*16467b97STreehugger Robot/// system is neither Windows nor \b configure compatible, then you should find it
9*16467b97STreehugger Robot/// reasonable to build the code manually (see section "Building Manually".)
10*16467b97STreehugger Robot///
11*16467b97STreehugger Robot/// \section src Source Code Organization
12*16467b97STreehugger Robot///
13*16467b97STreehugger Robot/// The source code expands from a tar/zip file to give you the following
14*16467b97STreehugger Robot/// directories:
15*16467b97STreehugger Robot///
16*16467b97STreehugger Robot/// - <b>./</b> The location of the configure script and the antlr3config.h file
17*16467b97STreehugger Robot///   generated by the running the configure script.This directory also
18*16467b97STreehugger Robot///   contains the solution and project files for visual studio 2005 and
19*16467b97STreehugger Robot///   2008.
20*16467b97STreehugger Robot/// - <b>./src</b> The location of all the C files in the project.
21*16467b97STreehugger Robot/// - <b>./include</b> The location of all the header files for the project
22*16467b97STreehugger Robot/// - <b>./doxygen</b> The location of documentation files such as the one that generates this page
23*16467b97STreehugger Robot/// - Other ancillary directories used by the build or documentation process.
24*16467b97STreehugger Robot///
25*16467b97STreehugger Robot/// \section winbuild Building for Windows
26*16467b97STreehugger Robot///
27*16467b97STreehugger Robot/// If you are building for Cygwin, or a similar UNIX on Windows System, follow the "Building With Configure" instructions below.
28*16467b97STreehugger Robot///
29*16467b97STreehugger Robot/// Note that the runtime is no longer compatible with the VC6 Microsoft compiler. If you absolutely need to build with
30*16467b97STreehugger Robot/// this compiler, you can probably hack the source code to deall with the pieces that VC6 cannot handle such as the
31*16467b97STreehugger Robot/// ULL suffix for constants.
32*16467b97STreehugger Robot///
33*16467b97STreehugger Robot/// If you wish to build the binaries for Windows using Visual Studio 2005, or 2008 you may build using the IDE:
34*16467b97STreehugger Robot///  -# Open the C.sln file
35*16467b97STreehugger Robot///  -# Select batch Build from the Build menu
36*16467b97STreehugger Robot///  -# Select all configurations and press the build button.
37*16467b97STreehugger Robot///
38*16467b97STreehugger Robot/// If you wish or need to build the libraries from the command line, then you must
39*16467b97STreehugger Robot/// use a Windows command shell configured for access to VS2005/VS2008 compilers, such as the one that is
40*16467b97STreehugger Robot/// started from:
41*16467b97STreehugger Robot///
42*16467b97STreehugger Robot/// <i>Start->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt</i>
43*16467b97STreehugger Robot///
44*16467b97STreehugger Robot/// There appears to be no way to build all targets at once in a batch mode from the command line,
45*16467b97STreehugger Robot/// so you may build one or all of the following:
46*16467b97STreehugger Robot/// \verbatim
47*16467b97STreehugger Robot   C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build ReleaseDLL
48*16467b97STreehugger Robot   C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build Release
49*16467b97STreehugger Robot   C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build DebugDLL
50*16467b97STreehugger Robot   C:\antlrsrc\code\antlr\main\runtime\C> DEVENV C.sln /Build Debug
51*16467b97STreehugger Robot\endverbatim
52*16467b97STreehugger Robot///
53*16467b97STreehugger Robot/// After the build is complete you will find the \c.\cDLL and \c.\cLIB files under the directory containing C.sln,
54*16467b97STreehugger Robot/// 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,
55*16467b97STreehugger Robot/// 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
56*16467b97STreehugger Robot/// \c .LIB file which you should link your projects with and a DLL. The library and names on Windows are as follows:
57*16467b97STreehugger Robot///
58*16467b97STreehugger Robot/// \verbatim
59*16467b97STreehugger Robot  - ReleaseDLL  :   ANTLR3C.DLL and ANTLR3C_DLL.LIB
60*16467b97STreehugger Robot  - DebugDLL    :  ANTLR3CD.DLL and ANTLR3CD_DLL.LIB
61*16467b97STreehugger Robot  - Release     :   ANTLR3C.LIB
62*16467b97STreehugger Robot  - Debug       :  ANTLR3CD.LIB
63*16467b97STreehugger Robot\endverbatim
64*16467b97STreehugger Robot///
65*16467b97STreehugger Robot/// There currently no .msi modules or other installs built for Windows, so you must place the DLLs in a directory referenced
66*16467b97STreehugger Robot/// by the PATH environment variable and make the include directory available to your project configurations.
67*16467b97STreehugger Robot///
68*16467b97STreehugger Robot///
69*16467b97STreehugger Robot/// \section configure Building with configure
70*16467b97STreehugger Robot///
71*16467b97STreehugger Robot/// Before starting, make sure that you are using a source code distribution and not the source code directly from the
72*16467b97STreehugger Robot/// Perforce repository. If you use the source from the perforce tree directly, you will find that there is no configure
73*16467b97STreehugger Robot/// script as this is generated as part of the distribution build by the maintainers. If you feel the need to build from
74*16467b97STreehugger Robot/// the distribution tree then you must have all the autobuild packages available on your system and can generate the
75*16467b97STreehugger Robot/// configure script using autoreconf. If you are not familiar with these tools, then please use the tgz files in the
76*16467b97STreehugger Robot/// dist subdirectory (or downloaded from the ANTLR web site).
77*16467b97STreehugger Robot///
78*16467b97STreehugger Robot/// The source code file should be expanded in a directory of your choice (probably your working directory) using the command:
79*16467b97STreehugger Robot///
80*16467b97STreehugger Robot/// \verbatim
81*16467b97STreehugger Robotgzip -dc antlrtgzname.tar.gz | tar xvf -
82*16467b97STreehugger Robot\endverbatim
83*16467b97STreehugger Robot///
84*16467b97STreehugger Robot/// 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.
85*16467b97STreehugger Robot///
86*16467b97STreehugger Robot/// 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
87*16467b97STreehugger Robot/// <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:
88*16467b97STreehugger Robot/// \verbatim
89*16467b97STreehugger Robot./configure --help
90*16467b97STreehugger Robot\endverbatim
91*16467b97STreehugger Robot///
92*16467b97STreehugger Robot/// Will document the latest incarnations of these options in case this documentation is ever out of date. At this time the options are:
93*16467b97STreehugger Robot///
94*16467b97STreehugger Robot/// \verbatim
95*16467b97STreehugger Robot  --enable-debuginfo   Compiles debug info into the library (default no)
96*16467b97STreehugger Robot  --enable-64bit       Turns on flags that produce 64 bit object code if
97*16467b97STreehugger Robot                       any are required (default no)
98*16467b97STreehugger Robot\endverbatim
99*16467b97STreehugger Robot///
100*16467b97STreehugger Robot/// Unless you need 64 bit builds, or a change in library types, you will generally use the configure command without options:
101*16467b97STreehugger Robot///
102*16467b97STreehugger Robot/// Here is a sample configure output:
103*16467b97STreehugger Robot///
104*16467b97STreehugger Robot/// \verbatim
105*16467b97STreehugger Robot[jimi@localhost dist]$ tar zvxf libantlr3c-3.0.0-rc8.tar.gz
106*16467b97STreehugger Robot
107*16467b97STreehugger Robotlibantlr3c-3.0.0-rc8/
108*16467b97STreehugger Robotlibantlr3c-3.0.0-rc8/antlr3config.h
109*16467b97STreehugger Robotlibantlr3c-3.0.0-rc8/src/
110*16467b97STreehugger Robotlibantlr3c-3.0.0-rc8/src/antlr3stringstream.c
111*16467b97STreehugger Robot...
112*16467b97STreehugger Robotlibantlr3c-3.0.0-rc8/antlr3config.h.in
113*16467b97STreehugger Robot\endverbatim
114*16467b97STreehugger Robot/// \verbatim
115*16467b97STreehugger Robot[jimi@localhost dist]$ cd libantlr3c-3.0.0-rc
116*16467b97STreehugger Robot\endverbatim
117*16467b97STreehugger Robot/// \verbatim
118*16467b97STreehugger Robot[jimi@localhost libantlr3c-3.0.0-rc8]$ ./configure
119*16467b97STreehugger Robot
120*16467b97STreehugger Robotchecking for a BSD-compatible install... /usr/bin/install -c
121*16467b97STreehugger Robotchecking whether build environment is sane... yes
122*16467b97STreehugger Robotchecking for a thread-safe mkdir -p... /bin/mkdir -p
123*16467b97STreehugger Robotchecking for gawk... gawk
124*16467b97STreehugger Robotchecking whether make sets $(MAKE)... yes
125*16467b97STreehugger Robotchecking for xlc... no
126*16467b97STreehugger Robotchecking for aCC... no
127*16467b97STreehugger Robotchecking for gcc... gcc
128*16467b97STreehugger Robot...
129*16467b97STreehugger Robotchecking for strdup... yes
130*16467b97STreehugger Robotconfigure: creating ./config.status
131*16467b97STreehugger Robotconfig.status: creating Makefile
132*16467b97STreehugger Robotconfig.status: creating antlr3config.h
133*16467b97STreehugger Robotconfig.status: antlr3config.h is unchanged
134*16467b97STreehugger Robotconfig.status: executing depfiles commands
135*16467b97STreehugger Robot\endverbatim
136*16467b97STreehugger Robot///
137*16467b97STreehugger Robot/// Having configured the library successfully, you need only make it, and install it:
138*16467b97STreehugger Robot///
139*16467b97STreehugger Robot/// \verbatim
140*16467b97STreehugger Robot[jimi@localhost libantlr3c-3.0.0-rc8]$ make
141*16467b97STreehugger Robot\endverbatim
142*16467b97STreehugger Robot/// \verbatim
143*16467b97STreehugger Robotmake  all-am
144*16467b97STreehugger Robotmake[1]: Entering directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
145*16467b97STreehugger Robot/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
146*16467b97STreehugger Robot...
147*16467b97STreehugger Robotgcc  -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
148*16467b97STreehugger Robotar 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
149*16467b97STreehugger Robotranlib .libs/libantlr3c.a
150*16467b97STreehugger Robotcreating libantlr3c.la
151*16467b97STreehugger Robot
152*16467b97STreehugger Robot(cd .libs && rm -f libantlr3c.la && ln -s ../libantlr3c.la libantlr3c.la)
153*16467b97STreehugger Robotmake[1]: Leaving directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
154*16467b97STreehugger Robot\endverbatim
155*16467b97STreehugger Robot/// \verbatim
156*16467b97STreehugger Robot[jimi@localhost libantlr3c-3.0.0-rc8]$ sudo make install
157*16467b97STreehugger Robot\endverbatim
158*16467b97STreehugger Robot/// \verbatim
159*16467b97STreehugger Robotmake[1]: Entering directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
160*16467b97STreehugger Robottest -z "/usr/local/lib" || /bin/mkdir -p "/usr/local/lib"
161*16467b97STreehugger Robot /bin/sh ./libtool --mode=install /usr/bin/install -c  'libantlr3c.la' '/usr/local/lib/libantlr3c.la'
162*16467b97STreehugger Robot/usr/bin/install -c .libs/libantlr3c.so /usr/local/lib/libantlr3c.so
163*16467b97STreehugger Robot/usr/bin/install -c .libs/libantlr3c.lai /usr/local/lib/libantlr3c.la
164*16467b97STreehugger Robot/usr/bin/install -c .libs/libantlr3c.a /usr/local/lib/libantlr3c.a
165*16467b97STreehugger Robot...
166*16467b97STreehugger Robot /usr/bin/install -c -m 644 'include/antlr3stringstream.h' '/usr/local/include/antlr3stringstream.h'
167*16467b97STreehugger Robot...
168*16467b97STreehugger Robot /usr/bin/install -c -m 644 'antlr3config.h' '/usr/local/include/antlr3config.h'
169*16467b97STreehugger Robotmake[1]: Leaving directory `/home/jimi/antlrsrc/code/antlr/main/runtime/C/dist/libantlr3c-3.0.0-rc8'
170*16467b97STreehugger Robot
171*16467b97STreehugger Robot[jimi@localhost libantlr3c-3.0.0-rc8]$
172*16467b97STreehugger Robot\endverbatim
173*16467b97STreehugger Robot///
174*16467b97STreehugger Robot/// You are now ready to generate C recognizers and compile and link them with the ANTLR 3 C Runtime.
175*16467b97STreehugger Robot///
176*16467b97STreehugger Robot///
177*16467b97STreehugger Robot/// \section buildman Building Manually
178*16467b97STreehugger Robot///
179*16467b97STreehugger Robot/// The only step that configure performs that cannot be done
180*16467b97STreehugger Robot/// manually (without effort) is to produce the header file
181*16467b97STreehugger Robot/// \c antlr3config.h, which contains typedefs of the fundamental types
182*16467b97STreehugger Robot/// that your local C compiler supports. The easiest way to produce
183*16467b97STreehugger Robot/// this file for your system, if you cannot port \b automake and \b configure
184*16467b97STreehugger Robot/// to the system is:
185*16467b97STreehugger Robot///
186*16467b97STreehugger Robot/// -# Run configure on a system that does support configure
187*16467b97STreehugger Robot/// -# Copy the generated \c antlr3config.h file to the target system
188*16467b97STreehugger Robot/// -# Edit the file locally and change any types that differ on this
189*16467b97STreehugger Robot///   system to the target systems. There are only a few types and you should
190*16467b97STreehugger Robot///   find this relatively easy.
191*16467b97STreehugger Robot///
192*16467b97STreehugger Robot/// Having produced a compatible antlr3config.h file, then you should be able to
193*16467b97STreehugger Robot/// compile the source files in the \c ./src subdirectory, providing an include path
194*16467b97STreehugger Robot/// to the location of \c antlr3config.h and the \c ./include subdirectory. Something akin
195*16467b97STreehugger Robot/// to:
196*16467b97STreehugger Robot/// \verbatim
197*16467b97STreehugger Robot
198*16467b97STreehugger Robot~/C/src: cc -c -O -I.. -I../include *.c
199*16467b97STreehugger Robot
200*16467b97STreehugger Robot\endverbatim
201*16467b97STreehugger Robot///
202*16467b97STreehugger Robot/// Having produced the .o (or equivalent) files for the local system you can then
203*16467b97STreehugger Robot/// build an archive or shared library for the C runtime.
204*16467b97STreehugger Robot///
205*16467b97STreehugger Robot/// When you wish to build and link with the C runtime, specify the path to the
206*16467b97STreehugger Robot/// supplied header files, and the path to the library that you built.
207*16467b97STreehugger Robot///