Home | History | Annotate | Download | only in builds
      1 #
      2 # FreeType 2 library sub-Makefile
      3 #
      4 
      5 
      6 # Copyright 1996-2018 by
      7 # 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 #
     23 #   BUILD_DIR      The architecture dependent directory,
     24 #                  e.g. `$(TOP_DIR)/builds/unix'.  Added to INCLUDES also.
     25 #
     26 #   OBJ_DIR        The directory in which object files are created.
     27 #
     28 #   LIB_DIR        The directory in which the library is created.
     29 #
     30 #   DOC_DIR        The directory in which the API reference is created.
     31 #
     32 #   INCLUDES       A list of directories to be included additionally.
     33 #
     34 #   DEVEL_DIR      Development directory which is added to the INCLUDES
     35 #                  variable before the standard include directories.
     36 #
     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 #
     47 #   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'.
     50 #
     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 #
     64 #   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 #
     69 #   TOP_DIR, SEP,
     70 #   COMPILER_SEP,
     71 #   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 #
     78 .PHONY: single multi objects library refdoc
     79 
     80 # default target -- build single objects and library
     81 #
     82 single: objects library
     83 
     84 # `multi' target -- build multiple objects and library
     85 #
     86 multi: objects library
     87 
     88 
     89 # The FreeType source directory, usually `./src'.
     90 #
     91 SRC_DIR := $(TOP_DIR)/src
     92 
     93 # The directory where the base layer components are placed, usually
     94 # `./src/base'.
     95 #
     96 BASE_DIR := $(SRC_DIR)/base
     97 
     98 # Other derived directories.
     99 #
    100 PUBLIC_DIR   := $(TOP_DIR)/include/freetype
    101 INTERNAL_DIR := $(PUBLIC_DIR)/internal
    102 SERVICES_DIR := $(INTERNAL_DIR)/services
    103 CONFIG_DIR   := $(PUBLIC_DIR)/config
    104 
    105 # The documentation directory.
    106 #
    107 DOC_DIR ?= $(TOP_DIR)/docs/reference
    108 
    109 # The final name of the library file.
    110 #
    111 PROJECT_LIBRARY := $(LIB_DIR)/$(LIBRARY).$A
    112 
    113 
    114 # include paths
    115 #
    116 # IMPORTANT NOTE: The architecture-dependent directory must ALWAYS be placed
    117 #                 before the standard include list.  Porters are then able to
    118 #                 put their own version of some of the FreeType components
    119 #                 in the `builds/<system>' directory, as these files will
    120 #                 override the default sources.
    121 #
    122 INCLUDES := $(subst /,$(COMPILER_SEP),$(OBJ_DIR) \
    123                                       $(DEVEL_DIR) \
    124                                       $(BUILD_DIR) \
    125                                       $(TOP_DIR)/include)
    126 
    127 INCLUDE_FLAGS := $(INCLUDES:%=$I%)
    128 
    129 ifdef DEVEL_DIR
    130   # We assume that all library dependencies for FreeType are fulfilled for a
    131   # development build, so we directly access the necessary include directory
    132   # information using `pkg-config'.
    133   INCLUDE_FLAGS += $(shell pkg-config --cflags libpng \
    134                                                harfbuzz )
    135 endif
    136 
    137 
    138 # C flags used for the compilation of an object file.  This must include at
    139 # least the paths for the `base' and `builds/<system>' directories;
    140 # debug/optimization/warning flags + ansi compliance if needed.
    141 #
    142 # $(INCLUDE_FLAGS) should come before $(CFLAGS) to avoid problems with
    143 # old FreeType versions.
    144 #
    145 # Note what we also define the macro FT2_BUILD_LIBRARY when building
    146 # FreeType.  This is required to let our sources include the internal
    147 # headers (something forbidden by clients).
    148 #
    149 # Finally, we define FT_CONFIG_MODULES_H so that the compiler uses the
    150 # generated version of `ftmodule.h' in $(OBJ_DIR).  If there is an
    151 # `ftoption.h' files in $(OBJ_DIR), define FT_CONFIG_OPTIONS_H too.
    152 #
    153 ifneq ($(wildcard $(OBJ_DIR)/ftoption.h),)
    154   FTOPTION_H    := $(OBJ_DIR)/ftoption.h
    155   FTOPTION_FLAG := $DFT_CONFIG_OPTIONS_H="<ftoption.h>"
    156 else ifneq ($(wildcard $(BUILD_DIR)/ftoption.h),)
    157   FTOPTION_H    := $(BUILD_DIR)/ftoption.h
    158   FTOPTION_FLAG := $DFT_CONFIG_OPTIONS_H="<ftoption.h>"
    159 endif
    160 
    161 # `CPPFLAGS' might be specified by the user in the environment.
    162 #
    163 FT_CFLAGS  = $(CPPFLAGS) \
    164              $(CFLAGS) \
    165              $DFT2_BUILD_LIBRARY \
    166              $DFT_CONFIG_MODULES_H="<ftmodule.h>" \
    167              $(FTOPTION_FLAG)
    168 
    169 
    170 # Include the `exports' rules file.
    171 #
    172 include $(TOP_DIR)/builds/exports.mk
    173 
    174 
    175 # Initialize the list of objects.
    176 #
    177 OBJECTS_LIST :=
    178 
    179 
    180 # Define $(PUBLIC_H) as the list of all public header files located in
    181 # `$(TOP_DIR)/include/freetype'.  $(INTERNAL_H), and $(CONFIG_H) are defined
    182 # similarly.
    183 #
    184 # This is used to simplify the dependency rules -- if one of these files
    185 # changes, the whole library is recompiled.
    186 #
    187 PUBLIC_H   := $(wildcard $(PUBLIC_DIR)/*.h)
    188 INTERNAL_H := $(wildcard $(INTERNAL_DIR)/*.h) \
    189               $(wildcard $(SERVICES_DIR)/*.h)
    190 CONFIG_H   := $(wildcard $(CONFIG_DIR)/*.h) \
    191               $(wildcard $(BUILD_DIR)/config/*.h) \
    192               $(FTMODULE_H) \
    193               $(FTOPTION_H)
    194 DEVEL_H    := $(wildcard $(TOP_DIR)/devel/*.h)
    195 
    196 FREETYPE_H := $(PUBLIC_H) $(INTERNAL_H) $(CONFIG_H) $(DEVEL_H)
    197 
    198 
    199 FT_COMPILE := $(CC) $(ANSIFLAGS) $(INCLUDE_FLAGS) $(FT_CFLAGS)
    200 
    201 # ftsystem component
    202 #
    203 FTSYS_SRC ?= $(BASE_DIR)/ftsystem.c
    204 
    205 FTSYS_OBJ := $(OBJ_DIR)/ftsystem.$O
    206 
    207 OBJECTS_LIST += $(FTSYS_OBJ)
    208 
    209 $(FTSYS_OBJ): $(FTSYS_SRC) $(FREETYPE_H)
    210 	$(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
    211 
    212 
    213 # ftdebug component
    214 #
    215 FTDEBUG_SRC ?= $(BASE_DIR)/ftdebug.c
    216 
    217 FTDEBUG_OBJ := $(OBJ_DIR)/ftdebug.$O
    218 
    219 OBJECTS_LIST += $(FTDEBUG_OBJ)
    220 
    221 $(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(FREETYPE_H)
    222 	$(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
    223 
    224 
    225 # Include all rule files from FreeType components.
    226 #
    227 include $(SRC_DIR)/base/rules.mk
    228 include $(patsubst %,$(SRC_DIR)/%/rules.mk,$(MODULES))
    229 
    230 
    231 # ftinit component
    232 #
    233 #   The C source `ftinit.c' contains the FreeType initialization routines.
    234 #   It is able to automatically register one or more drivers when the API
    235 #   function FT_Init_FreeType() is called.
    236 #
    237 #   The set of initial drivers is determined by the driver Makefiles
    238 #   includes above.  Each driver Makefile updates the FTINIT_xxx lists
    239 #   which contain additional include paths and macros used to compile the
    240 #   single `ftinit.c' source.
    241 #
    242 FTINIT_SRC := $(BASE_DIR)/ftinit.c
    243 FTINIT_OBJ := $(OBJ_DIR)/ftinit.$O
    244 
    245 OBJECTS_LIST += $(FTINIT_OBJ)
    246 
    247 $(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H)
    248 	$(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
    249 
    250 
    251 # ftver component
    252 #
    253 #  The VERSIONINFO resource `ftver.rc' contains version and copyright
    254 #  to be compiled by windres and tagged into DLL usually.
    255 #
    256 ifneq ($(RC),)
    257   FTVER_SRC := $(BASE_DIR)/ftver.rc
    258   FTVER_OBJ := $(OBJ_DIR)/ftver.$O
    259 
    260   OBJECTS_LIST += $(FTVER_OBJ)
    261 
    262   $(FTVER_OBJ): $(FTVER_SRC)
    263 	$(RC) -o $@ $<
    264 endif
    265 
    266 
    267 # All FreeType library objects.
    268 #
    269 OBJ_M := $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M)
    270 OBJ_S := $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S)
    271 
    272 
    273 # The target `multi' on the Make command line indicates that we want to
    274 # compile each source file independently.
    275 #
    276 # Otherwise, each module/driver is compiled in a single object file through
    277 # source file inclusion (see `src/base/ftbase.c' or
    278 # `src/truetype/truetype.c' for examples).
    279 #
    280 BASE_OBJECTS := $(OBJECTS_LIST)
    281 
    282 ifneq ($(findstring multi,$(MAKECMDGOALS)),)
    283   OBJECTS_LIST += $(OBJ_M)
    284 else
    285   OBJECTS_LIST += $(OBJ_S)
    286 endif
    287 
    288 objects: $(OBJECTS_LIST)
    289 
    290 library: $(PROJECT_LIBRARY)
    291 
    292 
    293 # Option `-B' disables generation of .pyc files (available since python 2.6)
    294 #
    295 refdoc:
    296 	python -B $(SRC_DIR)/tools/docmaker/docmaker.py \
    297                   --prefix=ft2                          \
    298                   --title=FreeType-$(version)           \
    299                   --output=$(DOC_DIR)                   \
    300                   $(PUBLIC_DIR)/*.h                     \
    301                   $(PUBLIC_DIR)/config/*.h              \
    302                   $(PUBLIC_DIR)/cache/*.h
    303 
    304 
    305 .PHONY: clean_project_std distclean_project_std
    306 
    307 # Standard cleaning and distclean rules.  These are not accepted
    308 # on all systems though.
    309 #
    310 clean_project_std:
    311 	-$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S) $(CLEAN)
    312 
    313 distclean_project_std: clean_project_std
    314 	-$(DELETE) $(PROJECT_LIBRARY)
    315 	-$(DELETE) *.orig *~ core *.core $(DISTCLEAN)
    316 
    317 
    318 .PHONY: clean_project_dos distclean_project_dos
    319 
    320 # The Dos command shell does not support very long list of arguments, so
    321 # we are stuck with wildcards.
    322 #
    323 # Don't break the command lines with \; this prevents the "del" command from
    324 # working correctly on Win9x.
    325 #
    326 clean_project_dos:
    327 	-$(DELETE) $(subst /,$(SEP),$(OBJ_DIR)/*.$O $(CLEAN) $(NO_OUTPUT))
    328 
    329 distclean_project_dos: clean_project_dos
    330 	-$(DELETE) $(subst /,$(SEP),$(PROJECT_LIBRARY) $(DISTCLEAN) $(NO_OUTPUT))
    331 
    332 
    333 .PHONY: remove_config_mk remove_ftmodule_h
    334 
    335 # Remove configuration file (used for distclean).
    336 #
    337 remove_config_mk:
    338 	-$(DELETE) $(subst /,$(SEP),$(CONFIG_MK) $(NO_OUTPUT))
    339 
    340 # Remove module list (used for distclean).
    341 #
    342 remove_ftmodule_h:
    343 	-$(DELETE) $(subst /,$(SEP),$(FTMODULE_H) $(NO_OUTPUT))
    344 
    345 
    346 .PHONY: clean distclean
    347 
    348 # The `config.mk' file must define `clean_project' and `distclean_project'.
    349 # Implementations may use to relay these to either the `std' or `dos'
    350 # versions from above, or simply provide their own implementation.
    351 #
    352 clean: clean_project
    353 distclean: distclean_project remove_config_mk remove_ftmodule_h
    354 	-$(DELETE) $(subst /,$(SEP),$(DOC_DIR)/*.html $(NO_OUTPUT))
    355 
    356 
    357 # EOF
    358