2 # FreeType 2 library sub-Makefile
6 # Copyright 1996-2000 by
7 # David Turner, Robert Wilhelm, and Werner Lemberg.
9 # This file is part of the FreeType project, and may only be used, modified,
10 # and distributed under the terms of the FreeType project license,
11 # LICENSE.TXT. By continuing to use, modify, or distribute this file you
12 # indicate that you have read the license and understand and accept it
16 # DO NOT INVOKE THIS MAKEFILE DIRECTLY! IT IS MEANT TO BE INCLUDED BY
20 # The following variables (set by other Makefile components, in the
21 # environment, or on the command line) are used:
23 # BUILD The architecture dependent directory,
24 # e.g. `$(TOP)/builds/unix'.
26 # OBJ_DIR The directory in which object files are created.
28 # LIB_DIR The directory in which the library is created.
30 # INCLUDES A list of directories to be included additionally.
33 # CFLAGS Compilation flags. This overrides the default settings
34 # in the platform-specific configuration files.
36 # FTSYS_SRC If set, its value is used as the name of a replacement
37 # file for `src/base/ftsystem.c'.
39 # FTDEBUG_SRC If set, its value is used as the name of a replacement
40 # file for `src/base/ftdebug.c'. [For a normal build, this
43 # FT_MODULE_LIST The file which contains the list of modules for the
44 # current build. Usually, this is automatically created by
48 # BASE_OBJ_M A list of base objects (for single object and multiple
49 # object builds, respectively). Set up in
50 # `src/base/rules.mk'.
52 # BASE_EXT_OBJ A list of base extension objects. Set up in
53 # `src/base/rules.mk'.
56 # DRV_OBJ_M A list of driver objects (for single object and multiple
57 # object builds, respectively). Set up cumulatively in
58 # `src/<driver>/rules.mk'.
61 # DISTCLEAN The sub-makefiles can append additional stuff to these two
62 # variables which is to be removed for the `clean' resp.
67 # A, I, O, T Check `config.mk' for details.
70 # The targets `objects' and `library' are defined at the end of this
71 # Makefile after all other rules have been included.
73 .PHONY: single objects library
75 # default target -- build single objects and library
77 single: objects library
79 # `multi' target -- build multiple objects and library
81 multi: objects library
84 # The FreeType source directory, usually `./src'.
86 SRC := $(TOP)$(SEP)src
89 # The directory where the base layer components are placed, usually
92 BASE_DIR := $(SRC)$(SEP)base
95 # A few short-cuts in order to avoid typing $(SEP) all the time for the
96 # directory separator.
98 # For example: $(SRC_) equals to `./src/' where `.' is $(TOP).
102 BASE_ := $(BASE_DIR)$(SEP)
103 OBJ_ := $(OBJ_DIR)$(SEP)
104 LIB_ := $(LIB_DIR)$(SEP)
105 PUBLIC_ := $(TOP)$(SEP)include$(SEP)freetype$(SEP)
106 INTERNAL_ := $(PUBLIC_)internal$(SEP)
107 CONFIG_ := $(PUBLIC_)config$(SEP)
110 # The final name of the library file.
112 FT_LIBRARY := $(LIB_)$(LIBRARY).$A
117 # IMPORTANT NOTE: The architecture-dependent directory must ALWAYS be placed
118 # in front of the include list. Porters are then able to
119 # put their own version of some of the FreeType components
120 # in the `freetype/builds/<system>' directory, as these
121 # files will override the default sources.
123 INCLUDES := $(BUILD) $(TOP)$(SEP)include $(SRC)
125 INCLUDE_FLAGS = $(INCLUDES:%=$I%)
128 # C flags used for the compilation of an object file. This must include at
129 # least the paths for the `base' and `builds/<system>' directories;
130 # debug/optimization/warning flags + ansi compliance if needed.
132 FT_CFLAGS = $(CFLAGS) $(INCLUDE_FLAGS)
133 FT_CC = $(CC) $(FT_CFLAGS)
134 FT_COMPILE = $(CC) $(ANSIFLAGS) $(FT_CFLAGS)
137 # Include the `modules' rules file.
139 include $(TOP)/builds/modules.mk
142 # Initialize the list of objects.
147 # Define $(PUBLIC_H) as the list of all public header files located in
148 # `$(TOP)/include/freetype'. $(BASE_H) and $(CONFIG_H) are defined
151 # This is used to simplify the dependency rules -- if one of these files
152 # changes, the whole library is recompiled.
154 PUBLIC_H := $(wildcard $(PUBLIC_)*.h)
155 BASE_H := $(wildcard $(INTERNAL_)*.h)
156 CONFIG_H := $(wildcard $(CONFIG_)*.h)
158 FREETYPE_H := $(PUBLIC_H) $(BASE_H) $(CONFIG_H)
164 FTSYS_SRC = $(BASE_)ftsystem.c
167 FTSYS_OBJ = $(OBJ_)ftsystem.$O
169 OBJECTS_LIST += $(FTSYS_OBJ)
171 $(FTSYS_OBJ): $(FTSYS_SRC) $(FREETYPE_H)
172 $(FT_COMPILE) $T$@ $<
178 FTDEBUG_SRC = $(BASE_)ftdebug.c
181 FTDEBUG_OBJ = $(OBJ_)ftdebug.$O
183 OBJECTS_LIST += $(FTDEBUG_OBJ)
185 $(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(FREETYPE_H)
186 $(FT_COMPILE) $T$@ $<
189 # Include all rule files from FreeType components.
191 include $(wildcard $(SRC)/*/rules.mk)
196 # The C source `ftinit.c' contains the FreeType initialization routines.
197 # It is able to automatically register one or more drivers when the API
198 # function FT_Init_FreeType() is called.
200 # The set of initial drivers is determined by the driver Makefiles
201 # includes above. Each driver Makefile updates the FTINIT_xxx lists
202 # which contain additional include paths and macros used to compile the
203 # single `ftinit.c' source.
205 FTINIT_SRC := $(BASE_)ftinit.c
206 FTINIT_OBJ := $(OBJ_)ftinit.$O
208 OBJECTS_LIST += $(FTINIT_OBJ)
210 $(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H) $(FT_MODULE_LIST)
211 $(FT_COMPILE) $T$@ $<
214 # All FreeType library objects
216 # By default, we include the base layer extensions. These could be
217 # omitted on builds which do not want them.
219 OBJ_M = $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M)
220 OBJ_S = $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S)
223 # The target `multi' on the Make command line indicates that we want to
224 # compile each source file independently.
226 # Otherwise, each module/driver is compiled in a single object file through
227 # source file inclusion (see `src/base/ftbase.c' or
228 # `src/truetype/truetype.c' for examples).
230 BASE_OBJECTS := $(OBJECTS_LIST)
232 ifneq ($(findstring multi,$(MAKECMDGOALS)),)
233 OBJECTS_LIST += $(OBJ_M)
235 OBJECTS_LIST += $(OBJ_S)
238 objects: $(OBJECTS_LIST)
240 library: $(FT_LIBRARY)
243 $(FT_COMPILE) $T$@ $<
246 # Standard cleaning and distclean rules. These are not accepted
247 # on all systems though.
250 -$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S) $(CLEAN)
252 distclean_freetype_std: clean_freetype_std
253 -$(DELETE) $(FT_LIBRARY)
254 -$(DELETE) *.orig *~ core *.core $(DISTCLEAN)
256 # The Dos command shell does not support very long list of arguments, so
257 # we are stuck with wildcards.
260 -$(DELETE) $(subst $(SEP),$(HOSTSEP),$(OBJ_))*.$O $(CLEAN) 2> nul
262 distclean_freetype_dos: clean_freetype_dos
263 -$(DELETE) $(subst $(SEP),$(HOSTSEP),$(FT_LIBRARY)) $(DISTCLEAN) 2> nul
265 # Remove configuration file (used for distclean).
268 -$(DELETE) $(subst $(SEP),$(HOSTSEP),$(CONFIG_MK))
271 # The `config.mk' file must define `clean_freetype' and
272 # `distclean_freetype'. Implementations may use to relay these to either
273 # the `std' or `dos' versions from above, or simply provide their own
276 clean: clean_freetype
277 distclean: distclean_freetype remove_config_mk