michael@0: # michael@0: # FreeType 2 library sub-Makefile michael@0: # michael@0: michael@0: michael@0: # Copyright 1996-2006, 2008, 2013, 2014 by michael@0: # David Turner, Robert Wilhelm, and Werner Lemberg. michael@0: # michael@0: # This file is part of the FreeType project, and may only be used, modified, michael@0: # and distributed under the terms of the FreeType project license, michael@0: # LICENSE.TXT. By continuing to use, modify, or distribute this file you michael@0: # indicate that you have read the license and understand and accept it michael@0: # fully. michael@0: michael@0: michael@0: # DO NOT INVOKE THIS MAKEFILE DIRECTLY! IT IS MEANT TO BE INCLUDED BY michael@0: # OTHER MAKEFILES. michael@0: michael@0: michael@0: # The following variables (set by other Makefile components, in the michael@0: # environment, or on the command line) are used: michael@0: # michael@0: # BUILD_DIR The architecture dependent directory, michael@0: # e.g. `$(TOP_DIR)/builds/unix'. Added to INCLUDES also. michael@0: # michael@0: # OBJ_DIR The directory in which object files are created. michael@0: # michael@0: # LIB_DIR The directory in which the library is created. michael@0: # michael@0: # DOC_DIR The directory in which the API reference is created. michael@0: # michael@0: # INCLUDES A list of directories to be included additionally. michael@0: # michael@0: # DEVEL_DIR Development directory which is added to the INCLUDES michael@0: # variable before the standard include directories. michael@0: # michael@0: # CFLAGS Compilation flags. This overrides the default settings michael@0: # in the platform-specific configuration files. michael@0: # michael@0: # FTSYS_SRC If set, its value is used as the name of a replacement michael@0: # file for `src/base/ftsystem.c'. michael@0: # michael@0: # FTDEBUG_SRC If set, its value is used as the name of a replacement michael@0: # file for `src/base/ftdebug.c'. [For a normal build, this michael@0: # file does nothing.] michael@0: # michael@0: # FTMODULE_H The file which contains the list of module classes for michael@0: # the current build. Usually, this is automatically michael@0: # created by `modules.mk'. michael@0: # michael@0: # BASE_OBJ_S michael@0: # BASE_OBJ_M A list of base objects (for single object and multiple michael@0: # object builds, respectively). Set up in michael@0: # `src/base/rules.mk'. michael@0: # michael@0: # BASE_EXT_OBJ A list of base extension objects. Set up in michael@0: # `src/base/rules.mk'. michael@0: # michael@0: # DRV_OBJ_S michael@0: # DRV_OBJ_M A list of driver objects (for single object and multiple michael@0: # object builds, respectively). Set up cumulatively in michael@0: # `src//rules.mk'. michael@0: # michael@0: # CLEAN michael@0: # DISTCLEAN The sub-makefiles can append additional stuff to these two michael@0: # variables which is to be removed for the `clean' resp. michael@0: # `distclean' target. michael@0: # michael@0: # TOP_DIR, SEP, michael@0: # COMPILER_SEP, michael@0: # LIBRARY, CC, michael@0: # A, I, O, T Check `config.mk' for details. michael@0: michael@0: michael@0: # The targets `objects' and `library' are defined at the end of this michael@0: # Makefile after all other rules have been included. michael@0: # michael@0: .PHONY: single multi objects library refdoc michael@0: michael@0: # default target -- build single objects and library michael@0: # michael@0: single: objects library michael@0: michael@0: # `multi' target -- build multiple objects and library michael@0: # michael@0: multi: objects library michael@0: michael@0: michael@0: # The FreeType source directory, usually `./src'. michael@0: # michael@0: SRC_DIR := $(TOP_DIR)/src michael@0: michael@0: # The directory where the base layer components are placed, usually michael@0: # `./src/base'. michael@0: # michael@0: BASE_DIR := $(SRC_DIR)/base michael@0: michael@0: # Other derived directories. michael@0: # michael@0: PUBLIC_DIR := $(TOP_DIR)/include michael@0: INTERNAL_DIR := $(PUBLIC_DIR)/internal michael@0: SERVICES_DIR := $(INTERNAL_DIR)/services michael@0: CONFIG_DIR := $(PUBLIC_DIR)/config michael@0: michael@0: # The documentation directory. michael@0: # michael@0: DOC_DIR ?= $(TOP_DIR)/docs/reference michael@0: michael@0: # The final name of the library file. michael@0: # michael@0: PROJECT_LIBRARY := $(LIB_DIR)/$(LIBRARY).$A michael@0: michael@0: michael@0: # include paths michael@0: # michael@0: # IMPORTANT NOTE: The architecture-dependent directory must ALWAYS be placed michael@0: # before the standard include list. Porters are then able to michael@0: # put their own version of some of the FreeType components michael@0: # in the `builds/' directory, as these files will michael@0: # override the default sources. michael@0: # michael@0: INCLUDES := $(subst /,$(COMPILER_SEP),$(OBJ_DIR) \ michael@0: $(DEVEL_DIR) \ michael@0: $(BUILD_DIR) \ michael@0: $(TOP_DIR)/include) michael@0: michael@0: INCLUDE_FLAGS := $(INCLUDES:%=$I%) michael@0: michael@0: ifdef DEVEL_DIR michael@0: # We assume that all library dependencies for FreeType are fulfilled for a michael@0: # development build, so we directly access the necessary include directory michael@0: # information using `pkg-config'. michael@0: INCLUDE_FLAGS += $(shell pkg-config --cflags libpng \ michael@0: harfbuzz ) michael@0: endif michael@0: michael@0: michael@0: # C flags used for the compilation of an object file. This must include at michael@0: # least the paths for the `base' and `builds/' directories; michael@0: # debug/optimization/warning flags + ansi compliance if needed. michael@0: # michael@0: # $(INCLUDE_FLAGS) should come before $(CFLAGS) to avoid problems with michael@0: # old FreeType versions. michael@0: # michael@0: # Note what we also define the macro FT2_BUILD_LIBRARY when building michael@0: # FreeType. This is required to let our sources include the internal michael@0: # headers (something forbidden by clients). michael@0: # michael@0: # Finally, we define FT_CONFIG_MODULES_H so that the compiler uses the michael@0: # generated version of `ftmodule.h' in $(OBJ_DIR). If there is an michael@0: # `ftoption.h' files in $(OBJ_DIR), define FT_CONFIG_OPTIONS_H too. michael@0: # michael@0: ifneq ($(wildcard $(OBJ_DIR)/ftoption.h),) michael@0: FTOPTION_H := $(OBJ_DIR)/ftoption.h michael@0: FTOPTION_FLAG := $DFT_CONFIG_OPTIONS_H="" michael@0: endif michael@0: michael@0: # Note that a build with the `configure' script uses $(CFLAGS) only. michael@0: # michael@0: FT_CFLAGS = $(CPPFLAGS) \ michael@0: $(INCLUDE_FLAGS) \ michael@0: $(CFLAGS) \ michael@0: $DFT2_BUILD_LIBRARY \ michael@0: $DFT_CONFIG_MODULES_H="" \ michael@0: $(FTOPTION_FLAG) michael@0: FT_COMPILE = $(CC) $(ANSIFLAGS) $(FT_CFLAGS) michael@0: michael@0: michael@0: # Include the `exports' rules file. michael@0: # michael@0: include $(TOP_DIR)/builds/exports.mk michael@0: michael@0: michael@0: # Initialize the list of objects. michael@0: # michael@0: OBJECTS_LIST := michael@0: michael@0: michael@0: # Define $(PUBLIC_H) as the list of all public header files located in michael@0: # `$(TOP_DIR)/include/freetype'. $(INTERNAL_H), and $(CONFIG_H) are defined michael@0: # similarly. michael@0: # michael@0: # This is used to simplify the dependency rules -- if one of these files michael@0: # changes, the whole library is recompiled. michael@0: # michael@0: PUBLIC_H := $(wildcard $(PUBLIC_DIR)/*.h) michael@0: INTERNAL_H := $(wildcard $(INTERNAL_DIR)/*.h) \ michael@0: $(wildcard $(SERVICES_DIR)/*.h) michael@0: CONFIG_H := $(wildcard $(CONFIG_DIR)/*.h) \ michael@0: $(wildcard $(BUILD_DIR)/config/*.h) \ michael@0: $(FTMODULE_H) \ michael@0: $(FTOPTION_H) michael@0: DEVEL_H := $(wildcard $(TOP_DIR)/devel/*.h) michael@0: michael@0: FREETYPE_H := $(PUBLIC_H) $(INTERNAL_H) $(CONFIG_H) $(DEVEL_H) michael@0: michael@0: michael@0: # ftsystem component michael@0: # michael@0: FTSYS_SRC ?= $(BASE_DIR)/ftsystem.c michael@0: michael@0: FTSYS_OBJ := $(OBJ_DIR)/ftsystem.$O michael@0: michael@0: OBJECTS_LIST += $(FTSYS_OBJ) michael@0: michael@0: $(FTSYS_OBJ): $(FTSYS_SRC) $(FREETYPE_H) michael@0: $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) michael@0: michael@0: michael@0: # ftdebug component michael@0: # michael@0: FTDEBUG_SRC ?= $(BASE_DIR)/ftdebug.c michael@0: michael@0: FTDEBUG_OBJ := $(OBJ_DIR)/ftdebug.$O michael@0: michael@0: OBJECTS_LIST += $(FTDEBUG_OBJ) michael@0: michael@0: $(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(FREETYPE_H) michael@0: $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) michael@0: michael@0: michael@0: # Include all rule files from FreeType components. michael@0: # michael@0: include $(SRC_DIR)/base/rules.mk michael@0: include $(patsubst %,$(SRC_DIR)/%/rules.mk,$(MODULES)) michael@0: michael@0: michael@0: # ftinit component michael@0: # michael@0: # The C source `ftinit.c' contains the FreeType initialization routines. michael@0: # It is able to automatically register one or more drivers when the API michael@0: # function FT_Init_FreeType() is called. michael@0: # michael@0: # The set of initial drivers is determined by the driver Makefiles michael@0: # includes above. Each driver Makefile updates the FTINIT_xxx lists michael@0: # which contain additional include paths and macros used to compile the michael@0: # single `ftinit.c' source. michael@0: # michael@0: FTINIT_SRC := $(BASE_DIR)/ftinit.c michael@0: FTINIT_OBJ := $(OBJ_DIR)/ftinit.$O michael@0: michael@0: OBJECTS_LIST += $(FTINIT_OBJ) michael@0: michael@0: $(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H) michael@0: $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) michael@0: michael@0: michael@0: # All FreeType library objects. michael@0: # michael@0: OBJ_M := $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M) michael@0: OBJ_S := $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S) michael@0: michael@0: michael@0: # The target `multi' on the Make command line indicates that we want to michael@0: # compile each source file independently. michael@0: # michael@0: # Otherwise, each module/driver is compiled in a single object file through michael@0: # source file inclusion (see `src/base/ftbase.c' or michael@0: # `src/truetype/truetype.c' for examples). michael@0: # michael@0: BASE_OBJECTS := $(OBJECTS_LIST) michael@0: michael@0: ifneq ($(findstring multi,$(MAKECMDGOALS)),) michael@0: OBJECTS_LIST += $(OBJ_M) michael@0: else michael@0: OBJECTS_LIST += $(OBJ_S) michael@0: endif michael@0: michael@0: objects: $(OBJECTS_LIST) michael@0: michael@0: library: $(PROJECT_LIBRARY) michael@0: michael@0: .c.$O: michael@0: $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) michael@0: michael@0: michael@0: ifneq ($(findstring refdoc,$(MAKECMDGOALS)),) michael@0: # poor man's `sed' emulation with make's built-in string functions michael@0: work := $(strip $(shell $(CAT) $(PUBLIC_DIR)/freetype.h)) michael@0: work := $(subst |,x,$(work)) michael@0: work := $(subst $(space),|,$(work)) michael@0: work := $(subst \#define|FREETYPE_MAJOR|,$(space),$(work)) michael@0: work := $(word 2,$(work)) michael@0: major := $(subst |,$(space),$(work)) michael@0: major := $(firstword $(major)) michael@0: michael@0: work := $(subst \#define|FREETYPE_MINOR|,$(space),$(work)) michael@0: work := $(word 2,$(work)) michael@0: minor := $(subst |,$(space),$(work)) michael@0: minor := $(firstword $(minor)) michael@0: michael@0: work := $(subst \#define|FREETYPE_PATCH|,$(space),$(work)) michael@0: work := $(word 2,$(work)) michael@0: patch := $(subst |,$(space),$(work)) michael@0: patch := $(firstword $(patch)) michael@0: michael@0: version := $(major).$(minor).$(patch) michael@0: endif michael@0: michael@0: # We write-protect the docmaker directory to suppress generation michael@0: # of .pyc files. michael@0: # michael@0: refdoc: michael@0: -chmod -w $(SRC_DIR)/tools/docmaker michael@0: python $(SRC_DIR)/tools/docmaker/docmaker.py \ michael@0: --prefix=ft2 \ michael@0: --title=FreeType-$(version) \ michael@0: --output=$(DOC_DIR) \ michael@0: $(PUBLIC_DIR)/*.h \ michael@0: $(PUBLIC_DIR)/config/*.h \ michael@0: $(PUBLIC_DIR)/cache/*.h michael@0: -chmod +w $(SRC_DIR)/tools/docmaker michael@0: michael@0: michael@0: .PHONY: clean_project_std distclean_project_std michael@0: michael@0: # Standard cleaning and distclean rules. These are not accepted michael@0: # on all systems though. michael@0: # michael@0: clean_project_std: michael@0: -$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S) $(CLEAN) michael@0: michael@0: distclean_project_std: clean_project_std michael@0: -$(DELETE) $(PROJECT_LIBRARY) michael@0: -$(DELETE) *.orig *~ core *.core $(DISTCLEAN) michael@0: michael@0: michael@0: .PHONY: clean_project_dos distclean_project_dos michael@0: michael@0: # The Dos command shell does not support very long list of arguments, so michael@0: # we are stuck with wildcards. michael@0: # michael@0: # Don't break the command lines with \; this prevents the "del" command from michael@0: # working correctly on Win9x. michael@0: # michael@0: clean_project_dos: michael@0: -$(DELETE) $(subst /,$(SEP),$(OBJ_DIR)/*.$O $(CLEAN) $(NO_OUTPUT)) michael@0: michael@0: distclean_project_dos: clean_project_dos michael@0: -$(DELETE) $(subst /,$(SEP),$(PROJECT_LIBRARY) $(DISTCLEAN) $(NO_OUTPUT)) michael@0: michael@0: michael@0: .PHONY: remove_config_mk remove_ftmodule_h michael@0: michael@0: # Remove configuration file (used for distclean). michael@0: # michael@0: remove_config_mk: michael@0: -$(DELETE) $(subst /,$(SEP),$(CONFIG_MK) $(NO_OUTPUT)) michael@0: michael@0: # Remove module list (used for distclean). michael@0: # michael@0: remove_ftmodule_h: michael@0: -$(DELETE) $(subst /,$(SEP),$(FTMODULE_H) $(NO_OUTPUT)) michael@0: michael@0: michael@0: .PHONY: clean distclean michael@0: michael@0: # The `config.mk' file must define `clean_freetype' and michael@0: # `distclean_freetype'. Implementations may use to relay these to either michael@0: # the `std' or `dos' versions from above, or simply provide their own michael@0: # implementation. michael@0: # michael@0: clean: clean_project michael@0: distclean: distclean_project remove_config_mk remove_ftmodule_h michael@0: -$(DELETE) $(subst /,$(SEP),$(DOC_DIR)/*.html $(NO_OUTPUT)) michael@0: michael@0: michael@0: # EOF