David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 1 | # |
| 2 | # FreeType build system -- top-level sub-Makefile |
| 3 | # |
| 4 | |
Werner Lemberg | 47a5f41 | 2000-10-17 03:38:43 +0000 | [diff] [blame] | 5 | |
Werner Lemberg | c6a66b4 | 2012-12-20 08:31:56 +0100 | [diff] [blame] | 6 | # Copyright 1996-2001, 2003, 2006, 2008-2010, 2012 by |
Werner Lemberg | 47a5f41 | 2000-10-17 03:38:43 +0000 | [diff] [blame] | 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. |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 14 | |
| 15 | |
| 16 | # This file is designed for GNU Make, do not use it with another Make tool! |
| 17 | # |
| 18 | # It works as follows: |
| 19 | # |
Werner Lemberg | 1639c79 | 2006-05-06 16:44:58 +0000 | [diff] [blame] | 20 | # - When invoked for the first time, this Makefile includes the rules found |
| 21 | # in `PROJECT/builds/detect.mk'. They are in charge of detecting the |
| 22 | # current platform. |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 23 | # |
Werner Lemberg | 1639c79 | 2006-05-06 16:44:58 +0000 | [diff] [blame] | 24 | # A summary of the detection is displayed, and the file `config.mk' is |
| 25 | # created in the current directory. |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 26 | # |
Werner Lemberg | 1639c79 | 2006-05-06 16:44:58 +0000 | [diff] [blame] | 27 | # - When invoked later, this Makefile includes the rules found in |
| 28 | # `config.mk'. This sub-Makefile defines some system-specific variables |
| 29 | # (like compiler, compilation flags, object suffix, etc.), then includes |
| 30 | # the rules found in `PROJECT/builds/PROJECT.mk', used to build the |
| 31 | # library. |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 32 | # |
| 33 | # See the comments in `builds/detect.mk' and `builds/PROJECT.mk' for more |
| 34 | # details on host platform detection and library builds. |
| 35 | |
| 36 | |
Werner Lemberg | 4e33f9e | 2008-07-05 06:35:28 +0000 | [diff] [blame] | 37 | # First of all, check whether we have `$(value ...)'. We do this by testing |
| 38 | # for `$(eval ...)' which has been introduced in the same GNU make version. |
| 39 | |
| 40 | eval_available := |
| 41 | $(eval eval_available := T) |
| 42 | ifneq ($(eval_available),T) |
| 43 | $(error FreeType's build system needs a Make program which supports $$(value)) |
| 44 | endif |
| 45 | |
| 46 | |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 47 | .PHONY: all dist distclean modules setup |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 48 | |
Werner Lemberg | 5993924 | 2006-01-31 20:17:42 +0000 | [diff] [blame] | 49 | |
Werner Lemberg | 91481f8 | 2000-11-04 23:41:02 +0000 | [diff] [blame] | 50 | # The `space' variable is used to avoid trailing spaces in defining the |
| 51 | # `T' variable later. |
| 52 | # |
| 53 | empty := |
| 54 | space := $(empty) $(empty) |
| 55 | |
| 56 | |
Werner Lemberg | 5993924 | 2006-01-31 20:17:42 +0000 | [diff] [blame] | 57 | # The main configuration file, defining the `XXX_MODULES' variables. We |
| 58 | # prefer a `modules.cfg' file in OBJ_DIR over TOP_DIR. |
| 59 | # |
| 60 | ifndef MODULES_CFG |
| 61 | MODULES_CFG := $(TOP_DIR)/modules.cfg |
| 62 | ifneq ($(wildcard $(OBJ_DIR)/modules.cfg),) |
| 63 | MODULES_CFG := $(OBJ_DIR)/modules.cfg |
| 64 | endif |
| 65 | endif |
| 66 | |
| 67 | |
| 68 | # FTMODULE_H, as its name suggests, indicates where the FreeType module |
Werner Lemberg | 1639c79 | 2006-05-06 16:44:58 +0000 | [diff] [blame] | 69 | # class file resides. |
Werner Lemberg | 5993924 | 2006-01-31 20:17:42 +0000 | [diff] [blame] | 70 | # |
Werner Lemberg | 8a4de0d | 2006-02-01 07:52:11 +0000 | [diff] [blame] | 71 | FTMODULE_H ?= $(OBJ_DIR)/ftmodule.h |
Werner Lemberg | 5993924 | 2006-01-31 20:17:42 +0000 | [diff] [blame] | 72 | |
| 73 | |
| 74 | include $(MODULES_CFG) |
| 75 | |
| 76 | |
| 77 | # The list of modules we are using. |
| 78 | # |
| 79 | MODULES := $(FONT_MODULES) \ |
| 80 | $(HINTING_MODULES) \ |
| 81 | $(RASTER_MODULES) \ |
| 82 | $(AUX_MODULES) |
| 83 | |
| 84 | |
Werner Lemberg | 8a4de0d | 2006-02-01 07:52:11 +0000 | [diff] [blame] | 85 | CONFIG_MK ?= config.mk |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 86 | |
| 87 | # If no configuration sub-makefile is present, or if `setup' is the target |
| 88 | # to be built, run the auto-detection rules to figure out which |
| 89 | # configuration rules file to use. |
| 90 | # |
| 91 | # Note that the configuration file is put in the current directory, which is |
Werner Lemberg | 89df58f | 2002-06-14 08:09:25 +0000 | [diff] [blame] | 92 | # not necessarily $(TOP_DIR). |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 93 | |
| 94 | # If `config.mk' is not present, set `check_platform'. |
| 95 | # |
| 96 | ifeq ($(wildcard $(CONFIG_MK)),) |
| 97 | check_platform := 1 |
| 98 | endif |
| 99 | |
| 100 | # If `setup' is one of the targets requested, set `check_platform'. |
| 101 | # |
| 102 | ifneq ($(findstring setup,$(MAKECMDGOALS)),) |
| 103 | check_platform := 1 |
| 104 | endif |
| 105 | |
| 106 | # Include the automatic host platform detection rules when we need to |
| 107 | # check the platform. |
| 108 | # |
| 109 | ifdef check_platform |
| 110 | |
Werner Lemberg | 5993924 | 2006-01-31 20:17:42 +0000 | [diff] [blame] | 111 | all modules: setup |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 112 | |
Werner Lemberg | 89df58f | 2002-06-14 08:09:25 +0000 | [diff] [blame] | 113 | include $(TOP_DIR)/builds/detect.mk |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 114 | |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 115 | # This rule makes sense for Unix only to remove files created by a run |
| 116 | # of the configure script which hasn't been successful (so that no |
| 117 | # `config.mk' has been created). It uses the built-in $(RM) command of |
Werner Lemberg | 594f0c9 | 2000-12-20 22:09:41 +0000 | [diff] [blame] | 118 | # GNU make. Similarly, `nul' is created if e.g. `make setup win32' has |
| 119 | # been erroneously used. |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 120 | # |
Werner Lemberg | 5993924 | 2006-01-31 20:17:42 +0000 | [diff] [blame] | 121 | # Note: This test is duplicated in `builds/unix/detect.mk'. |
Werner Lemberg | a64c55b | 2001-05-12 06:40:50 +0000 | [diff] [blame] | 122 | # |
Werner Lemberg | 858f310 | 2003-06-09 04:46:30 +0000 | [diff] [blame] | 123 | is_unix := $(strip $(wildcard /sbin/init) \ |
| 124 | $(wildcard /usr/sbin/init) \ |
suzuki toshiya | 2968bd6 | 2011-11-30 23:25:38 +0900 | [diff] [blame] | 125 | $(wildcard /dev/null) \ |
Werner Lemberg | 858f310 | 2003-06-09 04:46:30 +0000 | [diff] [blame] | 126 | $(wildcard /hurd/auth)) |
David Turner | ebe85f5 | 2001-05-11 14:25:57 +0000 | [diff] [blame] | 127 | ifneq ($(is_unix),) |
| 128 | |
David Turner | ebe85f5 | 2001-05-11 14:25:57 +0000 | [diff] [blame] | 129 | distclean: |
Werner Lemberg | bd547dc | 2000-09-22 21:23:29 +0000 | [diff] [blame] | 130 | $(RM) builds/unix/config.cache |
| 131 | $(RM) builds/unix/config.log |
| 132 | $(RM) builds/unix/config.status |
| 133 | $(RM) builds/unix/unix-def.mk |
| 134 | $(RM) builds/unix/unix-cc.mk |
Werner Lemberg | 5e3614f | 2003-09-12 19:38:13 +0000 | [diff] [blame] | 135 | $(RM) builds/unix/freetype2.pc |
Werner Lemberg | 594f0c9 | 2000-12-20 22:09:41 +0000 | [diff] [blame] | 136 | $(RM) nul |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 137 | |
David Turner | ebe85f5 | 2001-05-11 14:25:57 +0000 | [diff] [blame] | 138 | endif # test is_unix |
| 139 | |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 140 | # IMPORTANT: |
| 141 | # |
| 142 | # `setup' must be defined by the host platform detection rules to create |
| 143 | # the `config.mk' file in the current directory. |
| 144 | |
| 145 | else |
| 146 | |
| 147 | # A configuration sub-Makefile is present -- simply run it. |
| 148 | # |
| 149 | all: single |
| 150 | |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 151 | BUILD_PROJECT := yes |
| 152 | include $(CONFIG_MK) |
| 153 | |
| 154 | endif # test check_platform |
| 155 | |
Werner Lemberg | 858f310 | 2003-06-09 04:46:30 +0000 | [diff] [blame] | 156 | |
Werner Lemberg | 5993924 | 2006-01-31 20:17:42 +0000 | [diff] [blame] | 157 | # We always need the list of modules in ftmodule.h. |
| 158 | # |
| 159 | all setup: $(FTMODULE_H) |
| 160 | |
| 161 | |
| 162 | # The `modules' target unconditionally rebuilds the module list. |
| 163 | # |
| 164 | modules: |
| 165 | $(FTMODULE_H_INIT) |
| 166 | $(FTMODULE_H_CREATE) |
| 167 | $(FTMODULE_H_DONE) |
| 168 | |
| 169 | include $(TOP_DIR)/builds/modules.mk |
| 170 | |
| 171 | |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 172 | # This target builds the tarballs. |
| 173 | # |
| 174 | # Not to be run by a normal user -- there are no attempts to make it |
| 175 | # generic. |
| 176 | |
Werner Lemberg | ec5b450 | 2006-12-10 07:51:38 +0000 | [diff] [blame] | 177 | # we check for `dist', not `distclean' |
| 178 | ifneq ($(findstring distx,$(MAKECMDGOALS)x),) |
Werner Lemberg | 4e1d6c0 | 2006-12-09 08:20:37 +0000 | [diff] [blame] | 179 | FT_H := include/freetype/freetype.h |
| 180 | |
Werner Lemberg | 19dfcbd | 2009-10-06 12:00:43 +0200 | [diff] [blame] | 181 | major := $(shell sed -n 's/.*FREETYPE_MAJOR[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H)) |
| 182 | minor := $(shell sed -n 's/.*FREETYPE_MINOR[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H)) |
| 183 | patch := $(shell sed -n 's/.*FREETYPE_PATCH[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H)) |
Werner Lemberg | 4e1d6c0 | 2006-12-09 08:20:37 +0000 | [diff] [blame] | 184 | |
| 185 | version := $(major).$(minor).$(patch) |
| 186 | winversion := $(major)$(minor)$(patch) |
| 187 | endif |
| 188 | |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 189 | dist: |
| 190 | -rm -rf tmp |
Werner Lemberg | 4e1d6c0 | 2006-12-09 08:20:37 +0000 | [diff] [blame] | 191 | rm -f freetype-$(version).tar.gz |
| 192 | rm -f freetype-$(version).tar.bz2 |
| 193 | rm -f ft$(winversion).zip |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 194 | |
Werner Lemberg | 19dfcbd | 2009-10-06 12:00:43 +0200 | [diff] [blame] | 195 | for d in `find . -wholename '*/.git' -prune \ |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 196 | -o -type f \ |
| 197 | -o -print` ; do \ |
| 198 | mkdir -p tmp/$$d ; \ |
| 199 | done ; |
| 200 | |
| 201 | currdir=`pwd` ; \ |
Werner Lemberg | 19dfcbd | 2009-10-06 12:00:43 +0200 | [diff] [blame] | 202 | for f in `find . -wholename '*/.git' -prune \ |
Werner Lemberg | ee5d3b5 | 2011-06-30 15:08:15 +0200 | [diff] [blame] | 203 | -o -name .gitignore \ |
Werner Lemberg | c6a66b4 | 2012-12-20 08:31:56 +0100 | [diff] [blame] | 204 | -o -name .mailmap \ |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 205 | -o -type d \ |
| 206 | -o -print` ; do \ |
| 207 | ln -s $$currdir/$$f tmp/$$f ; \ |
| 208 | done |
| 209 | |
| 210 | @# Prevent generation of .pyc files. Python follows (soft) links if |
| 211 | @# the link's directory is write protected, so we have temporarily |
| 212 | @# disable write access here too. |
| 213 | chmod -w src/tools/docmaker |
| 214 | |
| 215 | cd tmp ; \ |
| 216 | $(MAKE) devel ; \ |
| 217 | $(MAKE) do-dist |
| 218 | |
| 219 | chmod +w src/tools/docmaker |
| 220 | |
Werner Lemberg | 4e1d6c0 | 2006-12-09 08:20:37 +0000 | [diff] [blame] | 221 | mv tmp freetype-$(version) |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 222 | |
Werner Lemberg | 4e1d6c0 | 2006-12-09 08:20:37 +0000 | [diff] [blame] | 223 | tar cfh - freetype-$(version) \ |
Werner Lemberg | fb4ddb2 | 2009-01-14 05:30:56 +0000 | [diff] [blame] | 224 | | gzip -9 -c > freetype-$(version).tar.gz |
Werner Lemberg | 4e1d6c0 | 2006-12-09 08:20:37 +0000 | [diff] [blame] | 225 | tar cfh - freetype-$(version) \ |
| 226 | | bzip2 -c > freetype-$(version).tar.bz2 |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 227 | |
| 228 | @# Use CR/LF for zip files. |
Werner Lemberg | fb4ddb2 | 2009-01-14 05:30:56 +0000 | [diff] [blame] | 229 | zip -lr9 ft$(winversion).zip freetype-$(version) |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 230 | |
Werner Lemberg | 4e1d6c0 | 2006-12-09 08:20:37 +0000 | [diff] [blame] | 231 | rm -fr freetype-$(version) |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 232 | |
| 233 | |
| 234 | # The locations of the latest `config.guess' and `config.sub' versions (from |
Werner Lemberg | 7fa49ce | 2010-07-12 00:33:36 +0200 | [diff] [blame] | 235 | # GNU `config' git repository), relative to the `tmp' directory used during |
| 236 | # `make dist'. |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 237 | # |
Werner Lemberg | bcfcc71 | 2008-05-15 09:14:39 +0000 | [diff] [blame] | 238 | CONFIG_GUESS = ~/git/config/config.guess |
| 239 | CONFIG_SUB = ~/git/config/config.sub |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 240 | |
| 241 | |
| 242 | # Don't say `make do-dist'. Always use `make dist' instead. |
| 243 | # |
| 244 | .PHONY: do-dist |
| 245 | |
| 246 | do-dist: distclean refdoc |
| 247 | @# Without removing the files, `autoconf' and friends follow links. |
| 248 | rm -f builds/unix/aclocal.m4 |
Werner Lemberg | 3d69a19 | 2006-05-10 13:47:22 +0000 | [diff] [blame] | 249 | rm -f builds/unix/configure.ac |
| 250 | rm -f builds/unix/configure |
Werner Lemberg | e0d1559 | 2006-05-10 13:44:47 +0000 | [diff] [blame] | 251 | |
| 252 | sh autogen.sh |
| 253 | rm -rf builds/unix/autom4te.cache |
| 254 | |
| 255 | cp $(CONFIG_GUESS) builds/unix |
| 256 | cp $(CONFIG_SUB) builds/unix |
| 257 | |
David Turner | 046f7a0 | 2000-09-15 22:42:06 +0000 | [diff] [blame] | 258 | # EOF |