/modules/freetype2/builds/freetype.mk

http://github.com/zpao/v8monkey · Makefile · 361 lines · 117 code · 77 blank · 167 comment · 0 complexity · 1bd7d57e9b2d727dc2a1b8c37768e444 MD5 · raw file

  1. #
  2. # FreeType 2 library sub-Makefile
  3. #
  4. # Copyright 1996-2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 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
  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 `freetype/builds/<system>' directory, as these
  102. # files will 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. # C flags used for the compilation of an object file. This must include at
  110. # least the paths for the `base' and `builds/<system>' directories;
  111. # debug/optimization/warning flags + ansi compliance if needed.
  112. #
  113. # $(INCLUDE_FLAGS) should come before $(CFLAGS) to avoid problems with
  114. # old FreeType versions.
  115. #
  116. # Note what we also define the macro FT2_BUILD_LIBRARY when building
  117. # FreeType. This is required to let our sources include the internal
  118. # headers (something forbidden by clients).
  119. #
  120. # Finally, we define FT_CONFIG_MODULES_H so that the compiler uses the
  121. # generated version of `ftmodule.h' in $(OBJ_DIR). If there is an
  122. # `ftoption.h' files in $(OBJ_DIR), define FT_CONFIG_OPTIONS_H too.
  123. #
  124. ifneq ($(wildcard $(OBJ_DIR)/ftoption.h),)
  125. FTOPTION_H := $(OBJ_DIR)/ftoption.h
  126. FTOPTION_FLAG := $DFT_CONFIG_OPTIONS_H="<ftoption.h>"
  127. endif
  128. FT_CFLAGS = $(CPPFLAGS) \
  129. $(INCLUDE_FLAGS) \
  130. $(CFLAGS) \
  131. $DFT2_BUILD_LIBRARY \
  132. $DFT_CONFIG_MODULES_H="<ftmodule.h>" \
  133. $(FTOPTION_FLAG)
  134. FT_CC = $(CC) $(FT_CFLAGS)
  135. FT_COMPILE = $(CC) $(ANSIFLAGS) $(FT_CFLAGS)
  136. # Include the `exports' rules file.
  137. #
  138. include $(TOP_DIR)/builds/exports.mk
  139. # Initialize the list of objects.
  140. #
  141. OBJECTS_LIST :=
  142. # Define $(PUBLIC_H) as the list of all public header files located in
  143. # `$(TOP_DIR)/include/freetype'. $(INTERNAL_H), and $(CONFIG_H) are defined
  144. # similarly.
  145. #
  146. # This is used to simplify the dependency rules -- if one of these files
  147. # changes, the whole library is recompiled.
  148. #
  149. PUBLIC_H := $(wildcard $(PUBLIC_DIR)/*.h)
  150. INTERNAL_H := $(wildcard $(INTERNAL_DIR)/*.h) \
  151. $(wildcard $(SERVICES_DIR)/*.h)
  152. CONFIG_H := $(wildcard $(CONFIG_DIR)/*.h) \
  153. $(wildcard $(BUILD_DIR)/freetype/config/*.h) \
  154. $(FTMODULE_H) \
  155. $(FTOPTION_H)
  156. DEVEL_H := $(wildcard $(TOP_DIR)/devel/*.h)
  157. FREETYPE_H := $(PUBLIC_H) $(INTERNAL_H) $(CONFIG_H) $(DEVEL_H)
  158. # ftsystem component
  159. #
  160. FTSYS_SRC ?= $(BASE_DIR)/ftsystem.c
  161. FTSYS_OBJ := $(OBJ_DIR)/ftsystem.$O
  162. OBJECTS_LIST += $(FTSYS_OBJ)
  163. $(FTSYS_OBJ): $(FTSYS_SRC) $(FREETYPE_H)
  164. $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
  165. # ftdebug component
  166. #
  167. FTDEBUG_SRC ?= $(BASE_DIR)/ftdebug.c
  168. FTDEBUG_OBJ := $(OBJ_DIR)/ftdebug.$O
  169. OBJECTS_LIST += $(FTDEBUG_OBJ)
  170. $(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(FREETYPE_H)
  171. $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
  172. # Include all rule files from FreeType components.
  173. #
  174. include $(SRC_DIR)/base/rules.mk
  175. include $(patsubst %,$(SRC_DIR)/%/rules.mk,$(MODULES))
  176. # ftinit component
  177. #
  178. # The C source `ftinit.c' contains the FreeType initialization routines.
  179. # It is able to automatically register one or more drivers when the API
  180. # function FT_Init_FreeType() is called.
  181. #
  182. # The set of initial drivers is determined by the driver Makefiles
  183. # includes above. Each driver Makefile updates the FTINIT_xxx lists
  184. # which contain additional include paths and macros used to compile the
  185. # single `ftinit.c' source.
  186. #
  187. FTINIT_SRC := $(BASE_DIR)/ftinit.c
  188. FTINIT_OBJ := $(OBJ_DIR)/ftinit.$O
  189. OBJECTS_LIST += $(FTINIT_OBJ)
  190. $(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H)
  191. $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
  192. # All FreeType library objects.
  193. #
  194. OBJ_M := $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M)
  195. OBJ_S := $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S)
  196. # The target `multi' on the Make command line indicates that we want to
  197. # compile each source file independently.
  198. #
  199. # Otherwise, each module/driver is compiled in a single object file through
  200. # source file inclusion (see `src/base/ftbase.c' or
  201. # `src/truetype/truetype.c' for examples).
  202. #
  203. BASE_OBJECTS := $(OBJECTS_LIST)
  204. ifneq ($(findstring multi,$(MAKECMDGOALS)),)
  205. OBJECTS_LIST += $(OBJ_M)
  206. else
  207. OBJECTS_LIST += $(OBJ_S)
  208. endif
  209. objects: $(OBJECTS_LIST)
  210. library: $(PROJECT_LIBRARY)
  211. dll: $(PROJECT_LIBRARY) exported_symbols
  212. .c.$O:
  213. $(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
  214. ifneq ($(findstring refdoc,$(MAKECMDGOALS)),)
  215. # poor man's `sed' emulation with make's built-in string functions
  216. work := $(strip $(shell $(CAT) $(PUBLIC_DIR)/freetype.h))
  217. work := $(subst |,x,$(work))
  218. work := $(subst $(space),|,$(work))
  219. work := $(subst \#define|FREETYPE_MAJOR|,$(space),$(work))
  220. work := $(word 2,$(work))
  221. major := $(subst |,$(space),$(work))
  222. major := $(firstword $(major))
  223. work := $(subst \#define|FREETYPE_MINOR|,$(space),$(work))
  224. work := $(word 2,$(work))
  225. minor := $(subst |,$(space),$(work))
  226. minor := $(firstword $(minor))
  227. work := $(subst \#define|FREETYPE_PATCH|,$(space),$(work))
  228. work := $(word 2,$(work))
  229. patch := $(subst |,$(space),$(work))
  230. patch := $(firstword $(patch))
  231. version := $(major).$(minor).$(patch)
  232. endif
  233. # We write-protect the docmaker directory to suppress generation
  234. # of .pyc files.
  235. #
  236. refdoc:
  237. -chmod -w $(SRC_DIR)/tools/docmaker
  238. python $(SRC_DIR)/tools/docmaker/docmaker.py \
  239. --prefix=ft2 \
  240. --title=FreeType-$(version) \
  241. --output=$(DOC_DIR) \
  242. $(PUBLIC_DIR)/*.h \
  243. $(PUBLIC_DIR)/config/*.h \
  244. $(PUBLIC_DIR)/cache/*.h
  245. -chmod +w $(SRC_DIR)/tools/docmaker
  246. .PHONY: clean_project_std distclean_project_std
  247. # Standard cleaning and distclean rules. These are not accepted
  248. # on all systems though.
  249. #
  250. clean_project_std:
  251. -$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S) $(CLEAN)
  252. distclean_project_std: clean_project_std
  253. -$(DELETE) $(PROJECT_LIBRARY)
  254. -$(DELETE) *.orig *~ core *.core $(DISTCLEAN)
  255. .PHONY: clean_project_dos distclean_project_dos
  256. # The Dos command shell does not support very long list of arguments, so
  257. # we are stuck with wildcards.
  258. #
  259. # Don't break the command lines with \; this prevents the "del" command from
  260. # working correctly on Win9x.
  261. #
  262. clean_project_dos:
  263. -$(DELETE) $(subst /,$(SEP),$(OBJ_DIR)/*.$O $(CLEAN) $(NO_OUTPUT))
  264. distclean_project_dos: clean_project_dos
  265. -$(DELETE) $(subst /,$(SEP),$(PROJECT_LIBRARY) $(DISTCLEAN) $(NO_OUTPUT))
  266. .PHONY: remove_config_mk remove_ftmodule_h
  267. # Remove configuration file (used for distclean).
  268. #
  269. remove_config_mk:
  270. -$(DELETE) $(subst /,$(SEP),$(CONFIG_MK) $(NO_OUTPUT))
  271. # Remove module list (used for distclean).
  272. #
  273. remove_ftmodule_h:
  274. -$(DELETE) $(subst /,$(SEP),$(FTMODULE_H) $(NO_OUTPUT))
  275. .PHONY: clean distclean
  276. # The `config.mk' file must define `clean_freetype' and
  277. # `distclean_freetype'. Implementations may use to relay these to either
  278. # the `std' or `dos' versions from above, or simply provide their own
  279. # implementation.
  280. #
  281. clean: clean_project
  282. distclean: distclean_project remove_config_mk remove_ftmodule_h
  283. -$(DELETE) $(subst /,$(SEP),$(DOC_DIR)/*.html $(NO_OUTPUT))
  284. # EOF