freetype.mk (11639B)
1 # 2 # FreeType 2 library sub-Makefile 3 # 4 5 6 # Copyright (C) 1996-2025 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 # PLATFORM_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 refdoc-venv 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 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 $(PLATFORM_DIR) \ 125 $(TOP_DIR)/include) 126 127 INCLUDE_FLAGS := $(INCLUDES:%=$I%) 128 129 # For a development build, we assume that the external library dependencies 130 # defined in `ftoption.h' are fulfilled, so we directly access the necessary 131 # include directory information using `pkg-config'. 132 # 133 ifdef DEVEL_DIR 134 INCLUDE_FLAGS += $(shell pkg-config --cflags libpng) 135 INCLUDE_FLAGS += $(shell pkg-config --cflags harfbuzz) 136 INCLUDE_FLAGS += $(shell pkg-config --cflags libbrotlidec) 137 endif 138 139 140 # C flags used for the compilation of an object file. This must include at 141 # least the paths for the `base' and `builds/<system>' directories; 142 # debug/optimization/warning flags + ansi compliance if needed. 143 # 144 # $(INCLUDE_FLAGS) should come before $(CFLAGS) to avoid problems with 145 # old FreeType versions. 146 # 147 # Note what we also define the macro FT2_BUILD_LIBRARY when building 148 # FreeType. This is required to let our sources include the internal 149 # headers (something forbidden by clients). 150 # 151 # `CPPFLAGS' might be specified by the user in the environment. 152 # 153 FT_CFLAGS = $(CPPFLAGS) \ 154 $(CFLAGS) \ 155 $DFT2_BUILD_LIBRARY 156 157 FT_COMPILE := $(CC) $(ANSIFLAGS) $(INCLUDE_FLAGS) $(FT_CFLAGS) 158 159 160 # Include the `exports' rules file. 161 # 162 include $(TOP_DIR)/builds/exports.mk 163 164 165 # Initialize the list of objects. 166 # 167 OBJECTS_LIST := 168 169 170 # Define $(PUBLIC_H) as the list of all public header files located in 171 # `$(TOP_DIR)/include/freetype'. $(INTERNAL_H), and $(CONFIG_H) are defined 172 # similarly. $(FTOPTION_H) is the option file used in the compilation. 173 # 174 # This is used to simplify the dependency rules -- if one of these files 175 # changes, the whole library is recompiled. 176 # 177 ifneq ($(wildcard $(OBJ_DIR)/ftoption.h),) 178 FTOPTION_H := $(OBJ_DIR)/ftoption.h 179 else ifneq ($(wildcard $(PLATFORM_DIR)/ftoption.h),) 180 FTOPTION_H := $(PLATFORM_DIR)/ftoption.h 181 endif 182 183 PUBLIC_H := $(wildcard $(PUBLIC_DIR)/*.h) 184 INTERNAL_H := $(wildcard $(INTERNAL_DIR)/*.h) \ 185 $(wildcard $(SERVICES_DIR)/*.h) 186 CONFIG_H := $(wildcard $(CONFIG_DIR)/*.h) \ 187 $(wildcard $(PLATFORM_DIR)/config/*.h) \ 188 $(FTMODULE_H) \ 189 $(FTOPTION_H) 190 DEVEL_H := $(wildcard $(TOP_DIR)/devel/*.h) 191 192 FREETYPE_H := $(PUBLIC_H) $(INTERNAL_H) $(CONFIG_H) $(DEVEL_H) 193 194 195 # ftsystem component 196 # 197 FTSYS_SRC ?= $(BASE_DIR)/ftsystem.c 198 199 FTSYS_OBJ := $(OBJ_DIR)/ftsystem.$O 200 201 OBJECTS_LIST += $(FTSYS_OBJ) 202 203 $(FTSYS_OBJ): $(FTSYS_SRC) $(FREETYPE_H) 204 $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) 205 206 207 # ftdebug component 208 # 209 FTDEBUG_SRC ?= $(BASE_DIR)/ftdebug.c 210 211 FTDEBUG_OBJ := $(OBJ_DIR)/ftdebug.$O 212 213 OBJECTS_LIST += $(FTDEBUG_OBJ) 214 215 $(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(FREETYPE_H) 216 $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) 217 218 219 # Include all rule files from FreeType components. 220 # 221 include $(SRC_DIR)/base/rules.mk 222 include $(patsubst %,$(SRC_DIR)/%/rules.mk,$(MODULES)) 223 include $(SRC_DIR)/dlg/rules.mk 224 225 226 # ftinit component 227 # 228 # The C source `ftinit.c' contains the FreeType initialization routines. 229 # It is able to automatically register one or more drivers when the API 230 # function FT_Init_FreeType() is called. 231 # 232 # The set of initial drivers is determined by the driver Makefiles 233 # includes above. Each driver Makefile updates the FTINIT_xxx lists 234 # which contain additional include paths and macros used to compile the 235 # single `ftinit.c' source. 236 # 237 FTINIT_SRC := $(BASE_DIR)/ftinit.c 238 FTINIT_OBJ := $(OBJ_DIR)/ftinit.$O 239 240 OBJECTS_LIST += $(FTINIT_OBJ) 241 242 $(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H) 243 $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) 244 245 246 # ftver component 247 # 248 # The VERSIONINFO resource `ftver.rc' contains version and copyright 249 # to be compiled by windres and tagged into DLL usually. 250 # 251 ifneq ($(RC),) 252 FTVER_SRC := $(BASE_DIR)/ftver.rc 253 FTVER_OBJ := $(OBJ_DIR)/ftver.$O 254 255 OBJECTS_LIST += $(FTVER_OBJ) 256 257 $(FTVER_OBJ): $(FTVER_SRC) 258 $(RC) -o $@ $< 259 endif 260 261 262 # All FreeType library objects. 263 # 264 OBJ_M := $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M) $(DLG_OBJS_M) 265 OBJ_S := $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S) $(DLG_OBJS_S) 266 267 268 # The target `multi' on the Make command line indicates that we want to 269 # compile each source file independently. 270 # 271 # Otherwise, each module/driver is compiled in a single object file through 272 # source file inclusion (see `src/base/ftbase.c' or 273 # `src/truetype/truetype.c' for examples). 274 # 275 BASE_OBJECTS := $(OBJECTS_LIST) 276 277 ifneq ($(findstring multi,$(MAKECMDGOALS)),) 278 OBJECTS_LIST += $(OBJ_M) 279 else 280 OBJECTS_LIST += $(OBJ_S) 281 endif 282 283 objects: $(OBJECTS_LIST) 284 285 library: $(PROJECT_LIBRARY) 286 287 # Run `docwriter' in the current Python environment. 288 # 289 PYTHON ?= python 290 291 refdoc: 292 @echo Running docwriter... 293 $(PYTHON) -m docwriter \ 294 --prefix=ft2 \ 295 --title=FreeType-$(version) \ 296 --site=reference \ 297 --output=$(DOC_DIR) \ 298 $(PUBLIC_DIR)/*.h \ 299 $(PUBLIC_DIR)/config/*.h \ 300 $(PUBLIC_DIR)/cache/*.h 301 @echo Building static site... 302 cd $(DOC_DIR) && $(PYTHON) -m mkdocs build 303 @echo Done. 304 305 # Variables for running `refdoc' with Python's `virtualenv'. The 306 # environment is created in `DOC_DIR/env' and is gitignored. 307 # 308 # We still need to cd into `DOC_DIR' to build `mkdocs' because paths in 309 # `mkdocs.yml' are relative to the current working directory. 310 # 311 VENV_NAME := env 312 VENV_DIR := $(DOC_DIR)$(SEP)$(VENV_NAME) 313 ENV_PYTHON := $(VENV_DIR)$(SEP)$(BIN)$(SEP)$(PYTHON) 314 315 refdoc-venv: 316 @echo Setting up virtualenv for Python... 317 virtualenv --python=$(PYTHON) $(VENV_DIR) 318 @echo Installing docwriter... 319 $(ENV_PYTHON) -m pip install docwriter 320 @echo Running docwriter... 321 $(ENV_PYTHON) -m docwriter \ 322 --prefix=ft2 \ 323 --title=FreeType-$(version) \ 324 --site=reference \ 325 --output=$(DOC_DIR) \ 326 $(PUBLIC_DIR)/*.h \ 327 $(PUBLIC_DIR)/config/*.h \ 328 $(PUBLIC_DIR)/cache/*.h 329 @echo Building static site... 330 cd $(DOC_DIR) && $(VENV_NAME)$(SEP)$(BIN)$(SEP)python -m mkdocs build 331 @echo Done. 332 333 .PHONY: clean_project_std distclean_project_std 334 335 # Standard cleaning and distclean rules. These are not accepted 336 # on all systems though. 337 # 338 clean_project_std: 339 -$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S) $(CLEAN) 340 341 distclean_project_std: clean_project_std 342 -$(DELETE) $(PROJECT_LIBRARY) 343 -$(DELETE) *.orig *~ core *.core $(DISTCLEAN) 344 345 346 .PHONY: clean_project_dos distclean_project_dos 347 348 # The Dos command shell does not support very long list of arguments, so 349 # we are stuck with wildcards. 350 # 351 # Don't break the command lines with \; this prevents the "del" command from 352 # working correctly on Win9x. 353 # 354 clean_project_dos: 355 -$(DELETE) $(subst /,$(SEP),$(OBJ_DIR)/*.$O $(CLEAN) $(NO_OUTPUT)) 356 357 distclean_project_dos: clean_project_dos 358 -$(DELETE) $(subst /,$(SEP),$(PROJECT_LIBRARY) $(DISTCLEAN) $(NO_OUTPUT)) 359 360 361 .PHONY: remove_config_mk remove_ftmodule_h 362 363 # Remove configuration file (used for distclean). 364 # 365 remove_config_mk: 366 -$(DELETE) $(subst /,$(SEP),$(CONFIG_MK) $(NO_OUTPUT)) 367 368 # Remove module list (used for distclean). 369 # 370 remove_ftmodule_h: 371 -$(DELETE) $(subst /,$(SEP),$(FTMODULE_H) $(NO_OUTPUT)) 372 373 374 .PHONY: clean distclean 375 376 # The `config.mk' file must define `clean_project' and `distclean_project'. 377 # Implementations may use to relay these to either the `std' or `dos' 378 # versions from above, or simply provide their own implementation. 379 # 380 clean: clean_project 381 distclean: distclean_project remove_config_mk remove_ftmodule_h 382 -$(DELETE) $(subst /,$(SEP),$(DOC_DIR)/*.html $(NO_OUTPUT)) 383 384 385 # EOF