• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# FreeType build system -- top-level sub-Makefile
3#
4
5
6# Copyright (C) 1996-2021 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
40eval_available :=
41$(eval eval_available := T)
42ifneq ($(eval_available),T)
43  $(error FreeType's build system needs a Make program which supports $$(value))
44endif
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#
53empty :=
54space := $(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#
60ifndef 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
65endif
66
67
68# FTMODULE_H, as its name suggests, indicates where the FreeType module
69# class file resides.
70#
71FTMODULE_H ?= $(OBJ_DIR)/ftmodule.h
72
73
74include $(MODULES_CFG)
75
76
77# The list of modules we are using.
78#
79MODULES := $(FONT_MODULES)    \
80           $(HINTING_MODULES) \
81           $(RASTER_MODULES)  \
82           $(AUX_MODULES)
83
84
85CONFIG_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#
96ifeq ($(wildcard $(CONFIG_MK)),)
97  check_platform := 1
98endif
99
100# If `setup' is one of the targets requested, set `check_platform'.
101#
102ifneq ($(findstring setup,$(MAKECMDGOALS)),)
103  check_platform := 1
104endif
105
106
107# Include the automatic host platform detection rules when we need to
108# check the platform.
109#
110ifdef check_platform
111
112  all modules: setup
113
114  include $(TOP_DIR)/builds/detect.mk
115
116  # For builds directly from the git repository we need to copy files
117  # from `subprojects/dlg' to `src/dlg' and `include/dlg'.
118  #
119  ifeq ($(wildcard $(TOP_DIR)/src/dlg/dlg.*),)
120    ifeq ($(wildcard $(TOP_DIR)/subprojects/dlg/*),)
121      copy_submodule: check_out_submodule
122    endif
123
124    setup: copy_submodule
125  endif
126
127  # This rule makes sense for Unix only to remove files created by a run of
128  # the configure script which hasn't been successful (so that no
129  # `config.mk' has been created).  It uses the built-in $(RM) command of
130  # GNU make.  Similarly, `nul' is created if e.g. `make setup windows' has
131  # been erroneously used.
132  #
133  # Note: This test is duplicated in `builds/unix/detect.mk'.
134  #
135  is_unix := $(strip $(wildcard /sbin/init) \
136                     $(wildcard /usr/sbin/init) \
137                     $(wildcard /dev/null) \
138                     $(wildcard /hurd/auth))
139  ifneq ($(is_unix),)
140
141    distclean:
142	  $(RM) builds/unix/config.cache
143	  $(RM) builds/unix/config.log
144	  $(RM) builds/unix/config.status
145	  $(RM) builds/unix/unix-def.mk
146	  $(RM) builds/unix/unix-cc.mk
147	  $(RM) builds/unix/freetype2.pc
148	  $(RM) nul
149
150  endif # test is_unix
151
152  # IMPORTANT:
153  #
154  # `setup' must be defined by the host platform detection rules to create
155  # the `config.mk' file in the current directory.
156
157else
158
159  # A configuration sub-Makefile is present -- simply run it.
160  #
161  all: single
162
163  BUILD_PROJECT := yes
164  include $(CONFIG_MK)
165
166endif # test check_platform
167
168
169.PHONY: check_out_submodule copy_submodule
170
171check_out_submodule:
172	$(info Checking out submodule in `subprojects/dlg')
173	git submodule init
174	git submodule update
175
176copy_submodule:
177	$(info Copying files from `subprojects/dlg' to `src/dlg' and `include/dlg')
178  ifeq ($(wildcard include/dlg),)
179	mkdir $(subst /,$(SEP),include/dlg)
180  endif
181	$(COPY) $(subst /,$(SEP),subprojects/dlg/include/dlg/output.h include/dlg)
182	$(COPY) $(subst /,$(SEP),subprojects/dlg/include/dlg/dlg.h include/dlg)
183	$(COPY) $(subst /,$(SEP),subprojects/dlg/src/dlg/dlg.c src/dlg)
184
185
186# We always need the list of modules in ftmodule.h.
187#
188all setup: $(FTMODULE_H)
189
190
191# The `modules' target unconditionally rebuilds the module list.
192#
193modules:
194	$(FTMODULE_H_INIT)
195	$(FTMODULE_H_CREATE)
196	$(FTMODULE_H_DONE)
197
198include $(TOP_DIR)/builds/modules.mk
199
200
201# get FreeType version string, using a
202# poor man's `sed' emulation with make's built-in string functions
203#
204work := $(strip $(shell $(CAT) \
205                  $(subst /,$(SEP),$(TOP_DIR)/include/freetype/freetype.h)))
206work := $(subst |,x,$(work))
207work := $(subst $(space),|,$(work))
208work := $(subst \#define|FREETYPE_MAJOR|,$(space),$(work))
209work := $(word 2,$(work))
210major := $(subst |,$(space),$(work))
211major := $(firstword $(major))
212
213work := $(subst \#define|FREETYPE_MINOR|,$(space),$(work))
214work := $(word 2,$(work))
215minor := $(subst |,$(space),$(work))
216minor := $(firstword $(minor))
217
218work := $(subst \#define|FREETYPE_PATCH|,$(space),$(work))
219work := $(word 2,$(work))
220patch := $(subst |,$(space),$(work))
221patch := $(firstword $(patch))
222
223# ifneq ($(findstring x0x,x$(patch)x),)
224#   version := $(major).$(minor)
225#   winversion := $(major)$(minor)
226# else
227  version := $(major).$(minor).$(patch)
228  winversion := $(major)$(minor)$(patch)
229  version_tag := VER-$(major)-$(minor)-$(patch)
230# endif
231
232
233# This target builds the tarballs.
234#
235# Not to be run by a normal user -- there are no attempts to make it
236# generic.
237
238dist:
239	-rm -rf tmp
240	rm -f freetype-$(version).tar.gz
241	rm -f freetype-$(version).tar.xz
242	rm -f ft$(winversion).zip
243
244	for d in `find . -wholename '*/.git' -prune \
245	                 -o -type f \
246	                 -o -print` ; do \
247	  mkdir -p tmp/$$d ; \
248	done ;
249
250	currdir=`pwd` ; \
251	for f in `find . -wholename '*/.git' -prune \
252	                 -o -name .gitattributes \
253	                 -o -name .gitignore \
254	                 -o -name .gitlab-ci.yml \
255	                 -o -name .gitmodules \
256	                 -o -name .mailmap \
257	                 -o -type d \
258	                 -o -print` ; do \
259	  ln -s $$currdir/$$f tmp/$$f ; \
260	done
261
262	cd tmp ; \
263	$(MAKE) devel ; \
264	$(MAKE) do-dist
265
266	mv tmp freetype-$(version)
267
268	tar -H ustar -chf - freetype-$(version) \
269	| gzip -9 -c > freetype-$(version).tar.gz
270	tar -H ustar -chf - freetype-$(version) \
271	| xz -c > freetype-$(version).tar.xz
272
273	@# Use CR/LF for zip files.
274	zip -lr9 ft$(winversion).zip freetype-$(version)
275
276	rm -fr freetype-$(version)
277
278
279# The locations of the latest `config.guess' and `config.sub' versions (from
280# GNU `config' git repository), relative to the `tmp' directory used during
281# `make dist'.
282#
283CONFIG_GUESS = ~/git/config/config.guess
284CONFIG_SUB   = ~/git/config/config.sub
285
286# We also use this repository to access the gnulib script that converts git
287# commit messages to a ChangeLog file.
288CHANGELOG_SCRIPT = ~/git/config/gitlog-to-changelog
289
290
291# Don't say `make do-dist'.  Always use `make dist' instead.
292#
293.PHONY: do-dist
294
295do-dist: distclean refdoc
296	@# Without removing the files, `autoconf' and friends follow links.
297	rm -f builds/unix/aclocal.m4
298	rm -f builds/unix/configure.ac
299	rm -f builds/unix/configure
300
301	sh autogen.sh
302	rm -rf builds/unix/autom4te.cache
303
304	cp $(CONFIG_GUESS) builds/unix
305	cp $(CONFIG_SUB) builds/unix
306
307	@# Generate `ChangeLog' file with commits since previous release.
308	$(CHANGELOG_SCRIPT) \
309	  --format='%B%n' \
310	  --no-cluster \
311	  -- `git describe --tags \
312	                   --abbrev=0 \
313	                   $(version_tag)^`..$(version_tag) \
314	> ChangeLog
315
316	@# Remove intermediate files created by the `refdoc' target.
317	rm -rf docs/markdown
318	rm -f docs/mkdocs.yml
319
320	@# Remove more stuff related to git.
321	rm -rf subprojects
322
323# EOF
324