freetype.mk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. #
  2. # FreeType 2 library sub-Makefile
  3. #
  4. # Copyright (C) 1996-2019 by
  5. # David Turner, Robert Wilhelm, and Werner Lemberg.
  6. #
  7. # This file is part of the FreeType project, and may only be used, modified,
  8. # and distributed under the terms of the FreeType project license,
  9. # LICENSE.TXT. By continuing to use, modify, or distribute this file you
  10. # indicate that you have read the license and understand and accept it
  11. # fully.
  12. # DO NOT INVOKE THIS MAKEFILE DIRECTLY! IT IS MEANT TO BE INCLUDED BY
  13. # OTHER MAKEFILES.
  14. # The following variables (set by other Makefile components, in the
  15. # environment, or on the command line) are used:
  16. #
  17. # BUILD_DIR The architecture dependent directory,
  18. # e.g. `$(TOP_DIR)/builds/unix'. Added to INCLUDES also.
  19. #
  20. # OBJ_DIR The directory in which object files are created.
  21. #
  22. # LIB_DIR The directory in which the library is created.
  23. #
  24. # DOC_DIR The directory in which the API reference is created.
  25. #
  26. # INCLUDES A list of directories to be included additionally.
  27. #
  28. # DEVEL_DIR Development directory which is added to the INCLUDES
  29. # variable before the standard include directories.
  30. #
  31. # CFLAGS Compilation flags. This overrides the default settings
  32. # in the platform-specific configuration files.
  33. #
  34. # FTSYS_SRC If set, its value is used as the name of a replacement
  35. # file for `src/base/ftsystem.c'.
  36. #
  37. # FTDEBUG_SRC If set, its value is used as the name of a replacement
  38. # file for `src/base/ftdebug.c'. [For a normal build, this
  39. # file does nothing.]
  40. #
  41. # FTMODULE_H The file which contains the list of module classes for
  42. # the current build. Usually, this is automatically
  43. # created by `modules.mk'.
  44. #
  45. # BASE_OBJ_S
  46. # BASE_OBJ_M A list of base objects (for single object and multiple
  47. # object builds, respectively). Set up in
  48. # `src/base/rules.mk'.
  49. #
  50. # BASE_EXT_OBJ A list of base extension objects. Set up in
  51. # `src/base/rules.mk'.
  52. #
  53. # DRV_OBJ_S
  54. # DRV_OBJ_M A list of driver objects (for single object and multiple
  55. # object builds, respectively). Set up cumulatively in
  56. # `src/<driver>/rules.mk'.
  57. #
  58. # CLEAN
  59. # DISTCLEAN The sub-makefiles can append additional stuff to these two
  60. # variables which is to be removed for the `clean' resp.
  61. # `distclean' target.
  62. #
  63. # TOP_DIR, SEP,
  64. # COMPILER_SEP,
  65. # LIBRARY, CC,
  66. # A, I, O, T Check `config.mk' for details.
  67. # The targets `objects' and `library' are defined at the end of this
  68. # Makefile after all other rules have been included.
  69. #
  70. .PHONY: single multi objects library refdoc refdoc-venv
  71. # default target -- build single objects and library
  72. #
  73. single: objects library
  74. # `multi' target -- build multiple objects and library
  75. #
  76. multi: objects library
  77. # The FreeType source directory, usually `./src'.
  78. #
  79. SRC_DIR := $(TOP_DIR)/src
  80. # The directory where the base layer components are placed, usually
  81. # `./src/base'.
  82. #
  83. BASE_DIR := $(SRC_DIR)/base
  84. # Other derived directories.
  85. #
  86. PUBLIC_DIR := $(TOP_DIR)/include/freetype
  87. INTERNAL_DIR := $(PUBLIC_DIR)/internal
  88. SERVICES_DIR := $(INTERNAL_DIR)/services
  89. CONFIG_DIR := $(PUBLIC_DIR)/config
  90. # The documentation directory.
  91. #
  92. DOC_DIR ?= $(TOP_DIR)/docs/reference
  93. # The final name of the library file.
  94. #
  95. PROJECT_LIBRARY := $(LIB_DIR)/$(LIBRARY).$A
  96. # include paths
  97. #
  98. # IMPORTANT NOTE: The architecture-dependent directory must ALWAYS be placed
  99. # before the standard include list. Porters are then able to
  100. # put their own version of some of the FreeType components
  101. # in the `builds/<system>' directory, as these files will
  102. # override the default sources.
  103. #
  104. INCLUDES := $(subst /,$(COMPILER_SEP),$(OBJ_DIR) \
  105. $(DEVEL_DIR) \
  106. $(BUILD_DIR) \
  107. $(TOP_DIR)/include)
  108. INCLUDE_FLAGS := $(INCLUDES:%=$I%)
  109. ifdef DEVEL_DIR
  110. # We assume that all library dependencies for FreeType are fulfilled for a
  111. # development build, so we directly access the necessary include directory
  112. # information using `pkg-config'.
  113. INCLUDE_FLAGS += $(shell pkg-config --cflags libpng \
  114. harfbuzz )
  115. endif
  116. # C flags used for the compilation of an object file. This must include at
  117. # least the paths for the `base' and `builds/<system>' directories;
  118. # debug/optimization/warning flags + ansi compliance if needed.
  119. #
  120. # $(INCLUDE_FLAGS) should come before $(CFLAGS) to avoid problems with
  121. # old FreeType versions.
  122. #
  123. # Note what we also define the macro FT2_BUILD_LIBRARY when building
  124. # FreeType. This is required to let our sources include the internal
  125. # headers (something forbidden by clients).
  126. #
  127. # Finally, we define FT_CONFIG_MODULES_H so that the compiler uses the
  128. # generated version of `ftmodule.h' in $(OBJ_DIR). If there is an
  129. # `ftoption.h' files in $(OBJ_DIR), define FT_CONFIG_OPTIONS_H too.
  130. #
  131. ifneq ($(wildcard $(OBJ_DIR)/ftoption.h),)
  132. FTOPTION_H := $(OBJ_DIR)/ftoption.h
  133. FTOPTION_FLAG := $DFT_CONFIG_OPTIONS_H="<ftoption.h>"
  134. else ifneq ($(wildcard $(BUILD_DIR)/ftoption.h),)
  135. FTOPTION_H := $(BUILD_DIR)/ftoption.h
  136. FTOPTION_FLAG := $DFT_CONFIG_OPTIONS_H="<ftoption.h>"
  137. endif
  138. # `CPPFLAGS' might be specified by the user in the environment.
  139. #
  140. FT_CFLAGS = $(CPPFLAGS) \
  141. $(CFLAGS) \
  142. $DFT2_BUILD_LIBRARY \
  143. $DFT_CONFIG_MODULES_H="<ftmodule.h>" \
  144. $(FTOPTION_FLAG)
  145. # Include the `exports' rules file.
  146. #
  147. include $(TOP_DIR)/builds/exports.mk
  148. # Initialize the list of objects.
  149. #
  150. OBJECTS_LIST :=
  151. # Define $(PUBLIC_H) as the list of all public header files located in
  152. # `$(TOP_DIR)/include/freetype'. $(INTERNAL_H), and $(CONFIG_H) are defined
  153. # similarly.
  154. #
  155. # This is used to simplify the dependency rules -- if one of these files
  156. # changes, the whole library is recompiled.
  157. #
  158. PUBLIC_H := $(wildcard $(PUBLIC_DIR)/*.h)
  159. INTERNAL_H := $(wildcard $(INTERNAL_DIR)/*.h) \
  160. $(wildcard $(SERVICES_DIR)/*.h)
  161. CONFIG_H := $(wildcard $(CONFIG_DIR)/*.h) \
  162. $(wildcard $(BUILD_DIR)/config/*.h) \
  163. $(FTMODULE_H) \
  164. $(FTOPTION_H)
  165. DEVEL_H := $(wildcard $(TOP_DIR)/devel/*.h)
  166. FREETYPE_H := $(PUBLIC_H) $(INTERNAL_H) $(CONFIG_H) $(DEVEL_H)
  167. FT_COMPILE := $(CC) $(ANSIFLAGS) $(INCLUDE_FLAGS) $(FT_CFLAGS)
  168. # ftsystem component
  169. #
  170. FTSYS_SRC ?= $(BASE_DIR)/ftsystem.c
  171. FTSYS_OBJ := $(OBJ_DIR)/ftsystem.$O
  172. OBJECTS_LIST += $(FTSYS_OBJ)
  173. $(FTSYS_OBJ): $(FTSYS_SRC) $(FREETYPE_H)
  174. $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
  175. # ftdebug component
  176. #
  177. FTDEBUG_SRC ?= $(BASE_DIR)/ftdebug.c
  178. FTDEBUG_OBJ := $(OBJ_DIR)/ftdebug.$O
  179. OBJECTS_LIST += $(FTDEBUG_OBJ)
  180. $(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(FREETYPE_H)
  181. $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
  182. # Include all rule files from FreeType components.
  183. #
  184. include $(SRC_DIR)/base/rules.mk
  185. include $(patsubst %,$(SRC_DIR)/%/rules.mk,$(MODULES))
  186. # ftinit component
  187. #
  188. # The C source `ftinit.c' contains the FreeType initialization routines.
  189. # It is able to automatically register one or more drivers when the API
  190. # function FT_Init_FreeType() is called.
  191. #
  192. # The set of initial drivers is determined by the driver Makefiles
  193. # includes above. Each driver Makefile updates the FTINIT_xxx lists
  194. # which contain additional include paths and macros used to compile the
  195. # single `ftinit.c' source.
  196. #
  197. FTINIT_SRC := $(BASE_DIR)/ftinit.c
  198. FTINIT_OBJ := $(OBJ_DIR)/ftinit.$O
  199. OBJECTS_LIST += $(FTINIT_OBJ)
  200. $(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H)
  201. $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
  202. # ftver component
  203. #
  204. # The VERSIONINFO resource `ftver.rc' contains version and copyright
  205. # to be compiled by windres and tagged into DLL usually.
  206. #
  207. ifneq ($(RC),)
  208. FTVER_SRC := $(BASE_DIR)/ftver.rc
  209. FTVER_OBJ := $(OBJ_DIR)/ftver.$O
  210. OBJECTS_LIST += $(FTVER_OBJ)
  211. $(FTVER_OBJ): $(FTVER_SRC)
  212. $(RC) -o $@ $<
  213. endif
  214. # All FreeType library objects.
  215. #
  216. OBJ_M := $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M)
  217. OBJ_S := $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S)
  218. # The target `multi' on the Make command line indicates that we want to
  219. # compile each source file independently.
  220. #
  221. # Otherwise, each module/driver is compiled in a single object file through
  222. # source file inclusion (see `src/base/ftbase.c' or
  223. # `src/truetype/truetype.c' for examples).
  224. #
  225. BASE_OBJECTS := $(OBJECTS_LIST)
  226. ifneq ($(findstring multi,$(MAKECMDGOALS)),)
  227. OBJECTS_LIST += $(OBJ_M)
  228. else
  229. OBJECTS_LIST += $(OBJ_S)
  230. endif
  231. objects: $(OBJECTS_LIST)
  232. library: $(PROJECT_LIBRARY)
  233. # Run `docwriter' in the current Python environment.
  234. # Option `-B' disables generation of .pyc files (available since python 2.6)
  235. #
  236. PYTHON ?= python
  237. PIP ?= pip
  238. refdoc:
  239. @echo Running docwriter...
  240. $(PYTHON) -m docwriter \
  241. --prefix=ft2 \
  242. --title=FreeType-$(version) \
  243. --output=$(DOC_DIR) \
  244. $(PUBLIC_DIR)/*.h \
  245. $(PUBLIC_DIR)/config/*.h \
  246. $(PUBLIC_DIR)/cache/*.h
  247. @echo Building static site...
  248. cd $(DOC_DIR) && mkdocs build
  249. @echo Done.
  250. # Variables for running `refdoc' with Python's `virtualenv'. The
  251. # environment is created in `DOC_DIR/env' and is gitignored.
  252. #
  253. # We still need to cd into `DOC_DIR' to build `mkdocs' because paths in
  254. # `mkdocs.yml' are relative to the current working directory.
  255. #
  256. VENV_NAME := env
  257. VENV_DIR := $(DOC_DIR)$(SEP)$(VENV_NAME)
  258. ENV_PYTHON := $(VENV_DIR)$(SEP)$(BIN)$(SEP)$(PYTHON)
  259. ENV_PIP := $(VENV_DIR)$(SEP)$(BIN)$(SEP)$(PIP)
  260. refdoc-venv:
  261. @echo Setting up virtualenv for Python...
  262. virtualenv --python=$(PYTHON) $(VENV_DIR)
  263. @echo Installing docwriter...
  264. $(ENV_PIP) install docwriter
  265. @echo Running docwriter...
  266. $(ENV_PYTHON) -m docwriter \
  267. --prefix=ft2 \
  268. --title=FreeType-$(version) \
  269. --output=$(DOC_DIR) \
  270. $(PUBLIC_DIR)/*.h \
  271. $(PUBLIC_DIR)/config/*.h \
  272. $(PUBLIC_DIR)/cache/*.h
  273. @echo Building static site...
  274. cd $(DOC_DIR) && $(VENV_NAME)$(SEP)$(BIN)$(SEP)python -m mkdocs build
  275. @echo Done.
  276. .PHONY: clean_project_std distclean_project_std
  277. # Standard cleaning and distclean rules. These are not accepted
  278. # on all systems though.
  279. #
  280. clean_project_std:
  281. -$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S) $(CLEAN)
  282. distclean_project_std: clean_project_std
  283. -$(DELETE) $(PROJECT_LIBRARY)
  284. -$(DELETE) *.orig *~ core *.core $(DISTCLEAN)
  285. .PHONY: clean_project_dos distclean_project_dos
  286. # The Dos command shell does not support very long list of arguments, so
  287. # we are stuck with wildcards.
  288. #
  289. # Don't break the command lines with \; this prevents the "del" command from
  290. # working correctly on Win9x.
  291. #
  292. clean_project_dos:
  293. -$(DELETE) $(subst /,$(SEP),$(OBJ_DIR)/*.$O $(CLEAN) $(NO_OUTPUT))
  294. distclean_project_dos: clean_project_dos
  295. -$(DELETE) $(subst /,$(SEP),$(PROJECT_LIBRARY) $(DISTCLEAN) $(NO_OUTPUT))
  296. .PHONY: remove_config_mk remove_ftmodule_h
  297. # Remove configuration file (used for distclean).
  298. #
  299. remove_config_mk:
  300. -$(DELETE) $(subst /,$(SEP),$(CONFIG_MK) $(NO_OUTPUT))
  301. # Remove module list (used for distclean).
  302. #
  303. remove_ftmodule_h:
  304. -$(DELETE) $(subst /,$(SEP),$(FTMODULE_H) $(NO_OUTPUT))
  305. .PHONY: clean distclean
  306. # The `config.mk' file must define `clean_project' and `distclean_project'.
  307. # Implementations may use to relay these to either the `std' or `dos'
  308. # versions from above, or simply provide their own implementation.
  309. #
  310. clean: clean_project
  311. distclean: distclean_project remove_config_mk remove_ftmodule_h
  312. -$(DELETE) $(subst /,$(SEP),$(DOC_DIR)/*.html $(NO_OUTPUT))
  313. # EOF