Imported Upstream version 2.9.1
[platform/upstream/freetype2.git] / builds / toplevel.mk
1 #
2 # FreeType build system -- top-level sub-Makefile
3 #
4
5
6 # Copyright 1996-2018 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 # This file is designed for GNU Make, do not use it with another Make tool!
17 #
18 # It works as follows:
19 #
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.
23 #
24 #   A summary of the detection is displayed, and the file `config.mk' is
25 #   created in the current directory.
26 #
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.
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
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
47 .PHONY: all dist distclean modules setup
48
49
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
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
69 # class file resides.
70 #
71 FTMODULE_H ?= $(OBJ_DIR)/ftmodule.h
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
85 CONFIG_MK ?= config.mk
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
92 # not necessarily $(TOP_DIR).
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
111   all modules: setup
112
113   include $(TOP_DIR)/builds/detect.mk
114
115   # This rule makes sense for Unix only to remove files created by a run of
116   # 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
118   # GNU make.  Similarly, `nul' is created if e.g. `make setup windows' has
119   # been erroneously used.
120   #
121   # Note: This test is duplicated in `builds/unix/detect.mk'.
122   #
123   is_unix := $(strip $(wildcard /sbin/init) \
124                      $(wildcard /usr/sbin/init) \
125                      $(wildcard /dev/null) \
126                      $(wildcard /hurd/auth))
127   ifneq ($(is_unix),)
128
129     distclean:
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
135           $(RM) builds/unix/freetype2.pc
136           $(RM) nul
137
138   endif # test is_unix
139
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
151   BUILD_PROJECT := yes
152   include $(CONFIG_MK)
153
154 endif # test check_platform
155
156
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
172 # get FreeType version string, using a
173 # poor man's `sed' emulation with make's built-in string functions
174 #
175 work := $(strip $(shell $(CAT) \
176                   $(subst /,$(SEP),$(TOP_DIR)/include/freetype/freetype.h)))
177 work := $(subst |,x,$(work))
178 work := $(subst $(space),|,$(work))
179 work := $(subst \#define|FREETYPE_MAJOR|,$(space),$(work))
180 work := $(word 2,$(work))
181 major := $(subst |,$(space),$(work))
182 major := $(firstword $(major))
183
184 work := $(subst \#define|FREETYPE_MINOR|,$(space),$(work))
185 work := $(word 2,$(work))
186 minor := $(subst |,$(space),$(work))
187 minor := $(firstword $(minor))
188
189 work := $(subst \#define|FREETYPE_PATCH|,$(space),$(work))
190 work := $(word 2,$(work))
191 patch := $(subst |,$(space),$(work))
192 patch := $(firstword $(patch))
193
194 ifneq ($(findstring x0x,x$(patch)x),)
195   version := $(major).$(minor)
196   winversion := $(major)$(minor)
197 else
198   version := $(major).$(minor).$(patch)
199   winversion := $(major)$(minor)$(patch)
200 endif
201
202
203 # This target builds the tarballs.
204 #
205 # Not to be run by a normal user -- there are no attempts to make it
206 # generic.
207
208 dist:
209         -rm -rf tmp
210         rm -f freetype-$(version).tar.gz
211         rm -f freetype-$(version).tar.bz2
212         rm -f ft$(winversion).zip
213
214         for d in `find . -wholename '*/.git' -prune \
215                          -o -type f \
216                          -o -print` ; do \
217           mkdir -p tmp/$$d ; \
218         done ;
219
220         currdir=`pwd` ; \
221         for f in `find . -wholename '*/.git' -prune \
222                          -o -name .gitignore \
223                          -o -name .mailmap \
224                          -o -type d \
225                          -o -print` ; do \
226           ln -s $$currdir/$$f tmp/$$f ; \
227         done
228
229         @# Prevent generation of .pyc files.  Python follows (soft) links if
230         @# the link's directory is write protected, so we have temporarily
231         @# disable write access here too.
232         chmod -w src/tools/docmaker
233
234         cd tmp ; \
235         $(MAKE) devel ; \
236         $(MAKE) do-dist
237
238         chmod +w src/tools/docmaker
239
240         mv tmp freetype-$(version)
241
242         tar -H ustar -chf - freetype-$(version) \
243         | gzip -9 -c > freetype-$(version).tar.gz
244         tar -H ustar -chf - freetype-$(version) \
245         | bzip2 -c > freetype-$(version).tar.bz2
246
247         @# Use CR/LF for zip files.
248         zip -lr9 ft$(winversion).zip freetype-$(version)
249
250         rm -fr freetype-$(version)
251
252
253 # The locations of the latest `config.guess' and `config.sub' versions (from
254 # GNU `config' git repository), relative to the `tmp' directory used during
255 # `make dist'.
256 #
257 CONFIG_GUESS = ~/git/config/config.guess
258 CONFIG_SUB   = ~/git/config/config.sub
259
260
261 # Don't say `make do-dist'.  Always use `make dist' instead.
262 #
263 .PHONY: do-dist
264
265 do-dist: distclean refdoc
266         @# Without removing the files, `autoconf' and friends follow links.
267         rm -f builds/unix/aclocal.m4
268         rm -f builds/unix/configure.ac
269         rm -f builds/unix/configure
270
271         sh autogen.sh
272         rm -rf builds/unix/autom4te.cache
273
274         cp $(CONFIG_GUESS) builds/unix
275         cp $(CONFIG_SUB) builds/unix
276
277 # EOF