blob: 2afd8c898d43d6674a1a6c5c74f6ff845e48f1b1 [file] [log] [blame]
David Turner74043012000-07-08 00:22:20 +00001#
2# FreeType 2 library sub-Makefile
3#
4
5
Werner Lembergbe3c9812006-01-27 14:16:16 +00006# Copyright 1996-2000, 2001, 2002, 2003, 2004, 2005, 2006 by
David Turner74043012000-07-08 00:22:20 +00007# David Turner, Robert Wilhelm, and Werner Lemberg.
8#
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
13# fully.
14
15
16# DO NOT INVOKE THIS MAKEFILE DIRECTLY! IT IS MEANT TO BE INCLUDED BY
17# OTHER MAKEFILES.
18
19
20# The following variables (set by other Makefile components, in the
21# environment, or on the command line) are used:
22#
Werner Lemberg858f3102003-06-09 04:46:30 +000023# BUILD_DIR The architecture dependent directory,
Werner Lemberg59939242006-01-31 20:17:42 +000024# e.g. `$(TOP_DIR)/builds/unix'. Added to INCLUDES also.
David Turner74043012000-07-08 00:22:20 +000025#
26# OBJ_DIR The directory in which object files are created.
27#
28# LIB_DIR The directory in which the library is created.
29#
Werner Lemberg6aa35cd2003-07-09 15:20:32 +000030# DOC_DIR The directory in which the API reference is created.
31#
David Turner74043012000-07-08 00:22:20 +000032# INCLUDES A list of directories to be included additionally.
Werner Lemberg59939242006-01-31 20:17:42 +000033#
34# DEVEL_DIR Development directory which is added to the INCLUDES
35# variable before the standard include directories.
David Turner74043012000-07-08 00:22:20 +000036#
37# CFLAGS Compilation flags. This overrides the default settings
38# in the platform-specific configuration files.
39#
40# FTSYS_SRC If set, its value is used as the name of a replacement
41# file for `src/base/ftsystem.c'.
42#
43# FTDEBUG_SRC If set, its value is used as the name of a replacement
44# file for `src/base/ftdebug.c'. [For a normal build, this
45# file does nothing.]
46#
Werner Lemberg59939242006-01-31 20:17:42 +000047# FTMODULE_H The file which contains the list of module classes for
48# the current build. Usually, this is automatically
49# created by `modules.mk'.
David Turner74043012000-07-08 00:22:20 +000050#
51# BASE_OBJ_S
52# BASE_OBJ_M A list of base objects (for single object and multiple
53# object builds, respectively). Set up in
54# `src/base/rules.mk'.
55#
56# BASE_EXT_OBJ A list of base extension objects. Set up in
57# `src/base/rules.mk'.
58#
59# DRV_OBJ_S
60# DRV_OBJ_M A list of driver objects (for single object and multiple
61# object builds, respectively). Set up cumulatively in
62# `src/<driver>/rules.mk'.
63#
Werner Lembergd060a752000-07-20 06:57:41 +000064# CLEAN
65# DISTCLEAN The sub-makefiles can append additional stuff to these two
66# variables which is to be removed for the `clean' resp.
67# `distclean' target.
68#
Werner Lemberg89df58f2002-06-14 08:09:25 +000069# TOP_DIR, SEP,
Werner Lemberg858f3102003-06-09 04:46:30 +000070# COMPILER_SEP,
David Turner74043012000-07-08 00:22:20 +000071# LIBRARY, CC,
72# A, I, O, T Check `config.mk' for details.
73
74
75# The targets `objects' and `library' are defined at the end of this
76# Makefile after all other rules have been included.
77#
Werner Lemberg6aa35cd2003-07-09 15:20:32 +000078.PHONY: single multi objects library refdoc
David Turner74043012000-07-08 00:22:20 +000079
80# default target -- build single objects and library
81#
82single: objects library
83
84# `multi' target -- build multiple objects and library
85#
86multi: objects library
87
88
89# The FreeType source directory, usually `./src'.
90#
Werner Lemberg858f3102003-06-09 04:46:30 +000091SRC_DIR := $(TOP_DIR)/src
David Turner74043012000-07-08 00:22:20 +000092
93# The directory where the base layer components are placed, usually
94# `./src/base'.
95#
Werner Lemberg858f3102003-06-09 04:46:30 +000096BASE_DIR := $(SRC_DIR)/base
David Turner74043012000-07-08 00:22:20 +000097
Werner Lemberg858f3102003-06-09 04:46:30 +000098# Other derived directories.
David Turnerd3c8e062000-12-04 22:53:55 +000099#
Werner Lemberg858f3102003-06-09 04:46:30 +0000100PUBLIC_DIR := $(TOP_DIR)/include/freetype
101INTERNAL_DIR := $(PUBLIC_DIR)/internal
Werner Lemberg104dd412003-09-16 07:57:25 +0000102SERVICES_DIR := $(INTERNAL_DIR)/services
Werner Lemberg858f3102003-06-09 04:46:30 +0000103CONFIG_DIR := $(PUBLIC_DIR)/config
David Turner74043012000-07-08 00:22:20 +0000104
Werner Lemberg6aa35cd2003-07-09 15:20:32 +0000105# The documentation directory.
106#
Werner Lemberg8a4de0d2006-02-01 07:52:11 +0000107DOC_DIR ?= $(TOP_DIR)/docs/reference
David Turner74043012000-07-08 00:22:20 +0000108
109# The final name of the library file.
110#
Werner Lemberg858f3102003-06-09 04:46:30 +0000111PROJECT_LIBRARY := $(LIB_DIR)/$(LIBRARY).$A
David Turner74043012000-07-08 00:22:20 +0000112
113
114# include paths
115#
116# IMPORTANT NOTE: The architecture-dependent directory must ALWAYS be placed
Werner Lemberg59939242006-01-31 20:17:42 +0000117# before the standard include list. Porters are then able to
David Turner74043012000-07-08 00:22:20 +0000118# put their own version of some of the FreeType components
David Turnera90663f2000-07-08 00:41:13 +0000119# in the `freetype/builds/<system>' directory, as these
David Turner74043012000-07-08 00:22:20 +0000120# files will override the default sources.
121#
Werner Lemberg59939242006-01-31 20:17:42 +0000122INCLUDES := $(subst /,$(COMPILER_SEP),$(OBJ_DIR) \
123 $(DEVEL_DIR) \
124 $(BUILD_DIR) \
Werner Lemberg858f3102003-06-09 04:46:30 +0000125 $(TOP_DIR)/include)
David Turner74043012000-07-08 00:22:20 +0000126
Werner Lemberg59939242006-01-31 20:17:42 +0000127INCLUDE_FLAGS := $(INCLUDES:%=$I%)
David Turner74043012000-07-08 00:22:20 +0000128
129
130# C flags used for the compilation of an object file. This must include at
David Turnera90663f2000-07-08 00:41:13 +0000131# least the paths for the `base' and `builds/<system>' directories;
David Turner74043012000-07-08 00:22:20 +0000132# debug/optimization/warning flags + ansi compliance if needed.
133#
Werner Lembergb5349a92002-02-19 16:30:15 +0000134# $(INCLUDE_FLAGS) should come before $(CFLAGS) to avoid problems with
135# old FreeType versions.
136#
Werner Lembergbe3c9812006-01-27 14:16:16 +0000137# Note what we also define the macro FT2_BUILD_LIBRARY when building
138# FreeType. This is required to let our sources include the internal
139# headers (something forbidden by clients).
David Turnerff0e9e62006-01-27 09:15:53 +0000140#
Werner Lemberg59939242006-01-31 20:17:42 +0000141# Finally, we define FT_CONFIG_MODULES_H so that the compiler uses the
142# generated version of `ftmodule.h' in $(OBJ_DIR). If there is an
143# `ftoption.h' files in $(OBJ_DIR), define FT_CONFIG_OPTIONS_H too.
144#
145ifneq ($(wildcard $(OBJ_DIR)/ftoption.h),)
146 FTOPTION_H := $(OBJ_DIR)/ftoption.h
147 FTOPTION_FLAG := $DFT_CONFIG_OPTIONS_H="<ftoption.h>"
148endif
149
150FT_CFLAGS = $(CPPFLAGS) \
151 $(INCLUDE_FLAGS) \
152 $(CFLAGS) \
153 $DFT2_BUILD_LIBRARY \
154 $DFT_CONFIG_MODULES_H="<ftmodule.h>" \
155 $(FTOPTION_FLAG)
David Turner74043012000-07-08 00:22:20 +0000156FT_CC = $(CC) $(FT_CFLAGS)
157FT_COMPILE = $(CC) $(ANSIFLAGS) $(FT_CFLAGS)
158
159
Werner Lemberg59939242006-01-31 20:17:42 +0000160# Include the `exports' rules file.
David Turner9fbd2ab2005-10-28 16:14:14 +0000161#
162include $(TOP_DIR)/builds/exports.mk
David Turner74043012000-07-08 00:22:20 +0000163
Werner Lemberg59939242006-01-31 20:17:42 +0000164
David Turner74043012000-07-08 00:22:20 +0000165# Initialize the list of objects.
166#
167OBJECTS_LIST :=
168
169
170# Define $(PUBLIC_H) as the list of all public header files located in
Werner Lemberg5a73d8d2006-03-20 16:55:32 +0000171# `$(TOP_DIR)/include/freetype'. $(BASE_H), and $(CONFIG_H) are defined
172# similarly.
David Turner74043012000-07-08 00:22:20 +0000173#
174# This is used to simplify the dependency rules -- if one of these files
175# changes, the whole library is recompiled.
176#
Werner Lemberg858f3102003-06-09 04:46:30 +0000177PUBLIC_H := $(wildcard $(PUBLIC_DIR)/*.h)
Werner Lemberg104dd412003-09-16 07:57:25 +0000178BASE_H := $(wildcard $(INTERNAL_DIR)/*.h) \
179 $(wildcard $(SERVICES_DIR)/*.h)
Werner Lemberg858f3102003-06-09 04:46:30 +0000180CONFIG_H := $(wildcard $(CONFIG_DIR)/*.h) \
Werner Lemberg59939242006-01-31 20:17:42 +0000181 $(wildcard $(BUILD_DIR)/freetype/config/*.h) \
182 $(FTMODULE_H) \
183 $(FTOPTION_H)
Werner Lemberg858f3102003-06-09 04:46:30 +0000184DEVEL_H := $(wildcard $(TOP_DIR)/devel/*.h)
David Turner74043012000-07-08 00:22:20 +0000185
Werner Lemberg5a73d8d2006-03-20 16:55:32 +0000186FREETYPE_H := $(PUBLIC_H) $(BASE_H) $(CONFIG_H) $(DEVEL_H)
David Turner74043012000-07-08 00:22:20 +0000187
188
189# ftsystem component
190#
Werner Lemberg8a4de0d2006-02-01 07:52:11 +0000191FTSYS_SRC ?= $(BASE_DIR)/ftsystem.c
David Turner74043012000-07-08 00:22:20 +0000192
Werner Lemberg59939242006-01-31 20:17:42 +0000193FTSYS_OBJ := $(OBJ_DIR)/ftsystem.$O
David Turner74043012000-07-08 00:22:20 +0000194
195OBJECTS_LIST += $(FTSYS_OBJ)
196
197$(FTSYS_OBJ): $(FTSYS_SRC) $(FREETYPE_H)
Werner Lemberg858f3102003-06-09 04:46:30 +0000198 $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
David Turner74043012000-07-08 00:22:20 +0000199
200
201# ftdebug component
202#
Werner Lemberg8a4de0d2006-02-01 07:52:11 +0000203FTDEBUG_SRC ?= $(BASE_DIR)/ftdebug.c
David Turner74043012000-07-08 00:22:20 +0000204
Werner Lemberg59939242006-01-31 20:17:42 +0000205FTDEBUG_OBJ := $(OBJ_DIR)/ftdebug.$O
David Turner74043012000-07-08 00:22:20 +0000206
207OBJECTS_LIST += $(FTDEBUG_OBJ)
208
209$(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(FREETYPE_H)
Werner Lemberg858f3102003-06-09 04:46:30 +0000210 $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
David Turner74043012000-07-08 00:22:20 +0000211
212
213# Include all rule files from FreeType components.
214#
Werner Lemberg59939242006-01-31 20:17:42 +0000215include $(SRC_DIR)/base/rules.mk
216include $(patsubst %,$(SRC_DIR)/%/rules.mk,$(MODULES))
David Turner74043012000-07-08 00:22:20 +0000217
218
219# ftinit component
220#
221# The C source `ftinit.c' contains the FreeType initialization routines.
222# It is able to automatically register one or more drivers when the API
223# function FT_Init_FreeType() is called.
224#
225# The set of initial drivers is determined by the driver Makefiles
226# includes above. Each driver Makefile updates the FTINIT_xxx lists
227# which contain additional include paths and macros used to compile the
228# single `ftinit.c' source.
229#
Werner Lemberg858f3102003-06-09 04:46:30 +0000230FTINIT_SRC := $(BASE_DIR)/ftinit.c
231FTINIT_OBJ := $(OBJ_DIR)/ftinit.$O
David Turner74043012000-07-08 00:22:20 +0000232
233OBJECTS_LIST += $(FTINIT_OBJ)
234
Werner Lemberg59939242006-01-31 20:17:42 +0000235$(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H)
Werner Lemberg858f3102003-06-09 04:46:30 +0000236 $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
David Turner74043012000-07-08 00:22:20 +0000237
238
Werner Lemberg59939242006-01-31 20:17:42 +0000239# All FreeType library objects.
David Turner74043012000-07-08 00:22:20 +0000240#
Werner Lemberg59939242006-01-31 20:17:42 +0000241OBJ_M := $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M)
242OBJ_S := $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S)
David Turner74043012000-07-08 00:22:20 +0000243
244
245# The target `multi' on the Make command line indicates that we want to
246# compile each source file independently.
247#
248# Otherwise, each module/driver is compiled in a single object file through
249# source file inclusion (see `src/base/ftbase.c' or
250# `src/truetype/truetype.c' for examples).
251#
252BASE_OBJECTS := $(OBJECTS_LIST)
253
254ifneq ($(findstring multi,$(MAKECMDGOALS)),)
255 OBJECTS_LIST += $(OBJ_M)
256else
257 OBJECTS_LIST += $(OBJ_S)
258endif
259
260objects: $(OBJECTS_LIST)
261
David Turner046f7a02000-09-15 22:42:06 +0000262library: $(PROJECT_LIBRARY)
David Turner74043012000-07-08 00:22:20 +0000263
David Turner9fbd2ab2005-10-28 16:14:14 +0000264dll: $(PROJECT_LIBRARY) exported_symbols
265
David Turner74043012000-07-08 00:22:20 +0000266.c.$O:
Werner Lemberg858f3102003-06-09 04:46:30 +0000267 $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
David Turner74043012000-07-08 00:22:20 +0000268
269
Werner Lemberge0d15592006-05-10 13:44:47 +0000270# We write-protect the docmaker directory to suppress generation
271# of .pyc files.
272#
Werner Lemberg6aa35cd2003-07-09 15:20:32 +0000273refdoc:
Werner Lemberge0d15592006-05-10 13:44:47 +0000274 -chmod -w $(SRC_DIR)/tools/docmaker
Werner Lemberg6aa35cd2003-07-09 15:20:32 +0000275 python $(SRC_DIR)/tools/docmaker/docmaker.py \
276 --prefix=ft2 \
Werner Lemberg1639c792006-05-06 16:44:58 +0000277 --title=FreeType-2.2.1 \
Werner Lemberg6aa35cd2003-07-09 15:20:32 +0000278 --output=$(DOC_DIR) \
279 $(PUBLIC_DIR)/*.h \
280 $(PUBLIC_DIR)/config/*.h \
281 $(PUBLIC_DIR)/cache/*.h
Werner Lemberge0d15592006-05-10 13:44:47 +0000282 -chmod +w $(SRC_DIR)/tools/docmaker
Werner Lemberg6aa35cd2003-07-09 15:20:32 +0000283
284
Werner Lemberg594f0c92000-12-20 22:09:41 +0000285.PHONY: clean_project_std distclean_project_std
286
David Turner74043012000-07-08 00:22:20 +0000287# Standard cleaning and distclean rules. These are not accepted
288# on all systems though.
289#
David Turner046f7a02000-09-15 22:42:06 +0000290clean_project_std:
Werner Lembergd060a752000-07-20 06:57:41 +0000291 -$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S) $(CLEAN)
David Turner74043012000-07-08 00:22:20 +0000292
David Turner046f7a02000-09-15 22:42:06 +0000293distclean_project_std: clean_project_std
294 -$(DELETE) $(PROJECT_LIBRARY)
Werner Lembergd060a752000-07-20 06:57:41 +0000295 -$(DELETE) *.orig *~ core *.core $(DISTCLEAN)
David Turner74043012000-07-08 00:22:20 +0000296
Werner Lemberg594f0c92000-12-20 22:09:41 +0000297
298.PHONY: clean_project_dos distclean_project_dos
299
David Turner74043012000-07-08 00:22:20 +0000300# The Dos command shell does not support very long list of arguments, so
301# we are stuck with wildcards.
302#
Werner Lemberg948ee802002-05-02 06:50:58 +0000303# Don't break the command lines with \; this prevents the "del" command from
Werner Lemberga64c55b2001-05-12 06:40:50 +0000304# working correctly on Win9x.
David Turnerebe85f52001-05-11 14:25:57 +0000305#
David Turner046f7a02000-09-15 22:42:06 +0000306clean_project_dos:
David Turner9fbd2ab2005-10-28 16:14:14 +0000307 -$(DELETE) $(subst /,\,$(OBJ_DIR)/*.$O $(CLEAN) $(NO_OUTPUT))
David Turner74043012000-07-08 00:22:20 +0000308
David Turner046f7a02000-09-15 22:42:06 +0000309distclean_project_dos: clean_project_dos
Werner Lemberg858f3102003-06-09 04:46:30 +0000310 -$(DELETE) $(subst /,\,$(PROJECT_LIBRARY) $(DISTCLEAN) $(NO_OUTPUT))
David Turner74043012000-07-08 00:22:20 +0000311
Werner Lemberg594f0c92000-12-20 22:09:41 +0000312
Werner Lemberg59939242006-01-31 20:17:42 +0000313.PHONY: remove_config_mk remove_ftmodule_h
Werner Lemberg594f0c92000-12-20 22:09:41 +0000314
David Turner74043012000-07-08 00:22:20 +0000315# Remove configuration file (used for distclean).
316#
317remove_config_mk:
Werner Lemberg858f3102003-06-09 04:46:30 +0000318 -$(DELETE) $(subst /,$(SEP),$(CONFIG_MK) $(NO_OUTPUT))
David Turner74043012000-07-08 00:22:20 +0000319
Werner Lemberg59939242006-01-31 20:17:42 +0000320# Remove module list (used for distclean).
321#
322remove_ftmodule_h:
323 -$(DELETE) $(subst /,$(SEP),$(FTMODULE_H) $(NO_OUTPUT))
324
David Turner74043012000-07-08 00:22:20 +0000325
Werner Lemberg594f0c92000-12-20 22:09:41 +0000326.PHONY: clean distclean
327
David Turner74043012000-07-08 00:22:20 +0000328# The `config.mk' file must define `clean_freetype' and
329# `distclean_freetype'. Implementations may use to relay these to either
330# the `std' or `dos' versions from above, or simply provide their own
331# implementation.
332#
David Turner046f7a02000-09-15 22:42:06 +0000333clean: clean_project
Werner Lemberg59939242006-01-31 20:17:42 +0000334distclean: distclean_project remove_config_mk remove_ftmodule_h
Werner Lemberg6aa35cd2003-07-09 15:20:32 +0000335 -$(DELETE) $(subst /,$(SEP),$(DOC_DIR)/*.html $(NO_OUTPUT))
David Turner74043012000-07-08 00:22:20 +0000336
Werner Lemberg858f3102003-06-09 04:46:30 +0000337
David Turner74043012000-07-08 00:22:20 +0000338# EOF