1 FreeType 2 compilation how-to
6 Welcome to this new beta of the FreeType 2 library. You'll find in this
7 document instructions on how to compile the library on your favorite
10 *** UNIX USERS : Even though the FT2 build system doesn't
11 ************** : use the Autoconf/Automake tools, these will
12 ************** : be introduced in the Unix-specific parts of
13 ************** : the build in our final release..
16 I. QUICK COMMAND-LINE GUIDE:
17 ----------------------------
19 Install GNU Make, then try the following on Unix or any system with gcc:
21 make // this will setup the build
22 make // this will build the library
26 make setup visualc // setup the build for VisualC++ on Win32
27 make // build the library
29 Then, go to the "demos" directory and type
33 To compile the demo programs..
35 If this doesn't work, read the following..
39 II. COMMAND-LINE COMPILATION:
40 -----------------------------
42 Note that if you do not want to compile FreeType 2 from a command line
43 shell, please skip to section III below (DETAILED COMPILATION)
45 FreeType 2 includes a powerful and flexible build system that allows you
46 to easily compile it on a great variety of platforms from the command
47 line. To do so, just follow these simple instructions:
51 Because GNU Make is the only Make tool supported to compile FreeType 2,
52 you should install it on your machine.
54 Because the FT2 build system relies on many important features of GNU
55 Make, trying to build the library with any other Make tool will *fail*.
60 Go to the root FT2 directory, then simply invoke GNU Make from the
61 command line, this will launch the FreeType 2 Host Platform detection
62 routines. A summary will be displayed, for example, on Win32:
64 ========================================================================
65 FreeType build system -- automatic system detection
67 The following settings are used:
71 configuration directory ./builds/win32
72 configuration rules ./builds/win32/w32-gcc.mk
74 If this does not correspond to your system or settings please remove
75 the file 'config.mk' from this directory then read the INSTALL file
78 Otherwise, simply type 'make' again to build the library.
79 =========================================================================
81 If the detected settings correspond to your platform and compiler,
82 skip to step e/. Note that if your platform is completely alien to
83 the build system, the detected platform will be "ansi".
86 c/ Configure the build system for a different compiler:
88 If the build system correctly detected your platform, but you want to
89 use a different compiler than the one specified in the summary (for
90 most platforms, gcc is the defaut compiler), simply invoke GNU Make
97 to use Visual C++ on Win32, type: "make setup visualc"
98 to use LCC-Win32 on Win32, type: "make setup lcc"
100 The <compiler> name to use is platform-dependent. The list of available
101 compilers for your system is available in the file
102 "builds/<system>/detect.mk" (note that we hope to make the list
103 displayed at user demand in the final release)..
105 If you're satisfying by the new configuration summary, skip to step e/
108 d/ Configure the build system for an unknown platform/compiler:
110 What the auto-detection/setup phase of the build system does is simply
111 copy a file to the current directory under the name "config.mk".
113 For example, on OS/2+gcc, it would simply copy "builds/os2/os2-gcc.mk"
116 If for some reason your platform isn't correctly detected, simply copy
117 manually the configuration sub-makefile to "./config.mk" and go to
120 Note that this file is a sub-Makefile used to specify Make variables
121 used to invoke the compiler and linker during the build, you can easily
122 create your own version from one of the existing configuration files,
123 then copy it to the current directory under the name "./config.mk".
126 e/ Build the library:
128 The auto-detection/setup phase should have copied a file in the current
129 directory, called "./config.mk". This file contains definitions of various
130 Make variables used to invoke the compiler and linker during the build.
132 To launch the build, simply invoke GNU Make again: the top Makefile will
133 detect the configuration file and run the build with it..
136 f/ Build the demonstration programs:
138 Once the library is compiled, go to "demos", then invoke GNU Make.
140 Note that the demonstration programs include a tiny graphics sub-system
141 that includes "drivers" to display Windows on Win32, X11 and OS/2. The
142 build system should automatically detect which driver to use based on
143 the current platform.
145 UNIX USERS TAKE NOTE: XXXXXX
147 When building the demos, the build system tries to detect your X11 path
148 by looking for the patterns "X11R5/bin", "X11R6/bin" or "X11/bin" in
149 your current path. If no X11 path is found, the demo programs will not
150 be able to display graphics and will fail. Change your current path
151 if you encounter this problem.
153 Note that the release version will use Autoconf to detect everything
154 on Unix, so this will not be necessary !!
157 II. DETAILED COMPILATION PROCEDURE:
158 -----------------------------------
160 If you don't want to compile FreeType 2 from the command-line (for example
161 from a graphical IDE on a Mac or Windows), you'll need to understand how the
162 FreeType files are organized.
164 FreeType 2 has a very module design, and it is made of several components.
165 Each component must be compiled as a stand-alone object file, even when it
166 is really made of several C source files. For example, the "base layer"
167 component is made of the following C files:
171 ftcalc.c - computations
172 ftobjs.c - object management
173 ftstream.c - stream input
174 ftlist.c - simple list management
175 ftoutln.c - simple outline processing
176 ftextend.c - extensions support
178 However, you can create a single object file by compiling the file
179 "src/base/ftbase.c", whose content is basically:
181 #include <base/ftcalc.c>
182 #include <base/ftobjs.c>
183 #include <base/ftstream.c>
184 #include <base/ftlist.c>
185 #include <base/ftoutln.c>
186 #include <base/ftextend.c>
188 Similarly, each component has a single "englobing" C file to compile it
189 as a stand-alone object, i.e. :
191 src/base/ftbase.c - the base layer, high-level interface
192 src/sfnt/sfnt.c - the "sfnt" module
193 src/psnames/psnames.c - the Postscript Names module
194 src/truetype/truetype.c - the TrueType font driver
195 src/type1/type1.c - the Type 1 font driver
198 To compile one component, do the following:
200 - add the top-level "include" directory to your compilation include path
202 - add the "src" directory to your compilation include path.
204 - compile the component "source" file (see list below), you don't need
205 to be in the component's directory..
207 For example, the following line can be used to compile the truetype driver
211 cc -c -Iinclude -Isrc src/truetype/truetype.c
215 cd freetype2/src/truetype
216 cc -c -I../../include -I.. truetype.c
218 The complete list of files to compile for a feature-complete build of
221 src/base/ftsystem.c - system-specific memory and i/o support
222 src/base/ftinit.c - initialisation layer
223 src/base/ftdebug.c - debugging component (empty in release build)
224 src/base/ftbase.c - the "base layer" component
225 src/base/ftglyph.c - optional convenience functions
226 src/raster1/raster1.c - the monochrome bitmap renderer
227 src/smooth/smooth.c - the anti-aliased bitmap renderer
228 src/sfnt/sfnt.c - the "sfnt" module
229 src/psnames/psnames.c - the "psnames" module
230 src/truetype/truetype.c - the TrueType font driver
231 src/type1/type1.c - the Type 1 font driver (incl. Multiple Masters)
232 src/cid/type1cid.c - the Type 1 CID-keyed font driver
233 src/cff/cff.c - the OpenType/CFF/CEF font driver
234 src/winfonts/winfnt.c - the Windows FNT/FON font driver
236 All font drivers are optional. the "sfnt" and "psnames" modules are
237 mandatory for certain drivers.
240 III. Support for flat-directory compilation:
241 ----------------------------------------
243 It is now possible to put all FreeType 2 source files into a single
244 directory, with the exception of the "include" hierarchy.
246 Note that you'll still need to only compile the 'wrapper' sources described
247 above. Define the "FT_FLAT_COMPILE" macro when compiling. Here's an
250 1/ Copy all files in current directory:
252 cp freetype2/src/base/*.[hc] .
253 cp freetype2/src/raster1/*.[hc] .
254 cp freetype2/src/smooth/*.[hc] .
259 cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftsystem.c
260 cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftinit.c
261 cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftdebug.c
262 cc -c -DFT_FLAT_COMPILE -Ifreetype/include ftbase.c