toplevel.mk (9166B)
1 # 2 # FreeType build system -- top-level sub-Makefile 3 # 4 5 6 # Copyright (C) 1996-2025 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 107 # Include the automatic host platform detection rules when we need to 108 # check the platform. 109 # 110 ifdef 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) $(TOP_DIR)/builds/unix/config.cache 143 $(RM) $(TOP_DIR)/builds/unix/config.log 144 $(RM) $(TOP_DIR)/builds/unix/config.status 145 $(RM) $(TOP_DIR)/builds/unix/unix-def.mk 146 $(RM) $(TOP_DIR)/builds/unix/unix-cc.mk 147 $(RM) $(TOP_DIR)/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 157 else 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 166 endif # test check_platform 167 168 169 .PHONY: check_out_submodule copy_submodule 170 171 check_out_submodule: 172 $(info Checking out submodule in `subprojects/dlg') 173 git -C $(TOP_DIR) submodule update --init 174 175 copy_submodule: 176 $(info Copying files from `subprojects/dlg' to `src/dlg' and `include/dlg') 177 ifeq ($(wildcard $(TOP_DIR)/include/dlg),) 178 mkdir $(subst /,$(SEP),$(TOP_DIR)/include/dlg) 179 endif 180 $(COPY) $(subst /,$(SEP),$(TOP_DIR)/subprojects/dlg/include/dlg/output.h $(TOP_DIR)/include/dlg) 181 $(COPY) $(subst /,$(SEP),$(TOP_DIR)/subprojects/dlg/include/dlg/dlg.h $(TOP_DIR)/include/dlg) 182 $(COPY) $(subst /,$(SEP),$(TOP_DIR)/subprojects/dlg/src/dlg/dlg.c $(TOP_DIR)/src/dlg) 183 184 185 # We always need the list of modules in ftmodule.h. 186 # 187 all setup: $(FTMODULE_H) 188 189 190 # The `modules' target unconditionally rebuilds the module list. 191 # 192 modules: 193 $(FTMODULE_H_INIT) 194 $(FTMODULE_H_CREATE) 195 $(FTMODULE_H_DONE) 196 197 include $(TOP_DIR)/builds/modules.mk 198 199 200 # get FreeType version string using built-in string functions 201 # 202 hash := \# 203 204 work := $(strip $(shell $(CAT) \ 205 $(subst /,$(SEP),$(TOP_DIR)/include/freetype/freetype.h))) 206 207 work := $(subst $(hash)define$(space)FREETYPE_MAJOR$(space),MAjOR=,$(work)) 208 work := $(subst $(hash)define$(space)FREETYPE_MINOR$(space),MInOR=,$(work)) 209 work := $(subst $(hash)define$(space)FREETYPE_PATCH$(space),PAtCH=,$(work)) 210 211 major := $(subst MAjOR=,,$(filter MAjOR=%,$(work))) 212 minor := $(subst MInOR=,,$(filter MInOR=%,$(work))) 213 patch := $(subst PAtCH=,,$(filter PAtCH=%,$(work))) 214 215 work := 216 217 # ifneq ($(findstring x0x,x$(patch)x),) 218 # version := $(major).$(minor) 219 # winversion := $(major)$(minor) 220 # else 221 version := $(major).$(minor).$(patch) 222 winversion := $(major)$(minor)$(patch) 223 version_tag := VER-$(major)-$(minor)-$(patch) 224 # endif 225 226 227 # This target builds the tarballs. 228 # 229 # Not to be run by a normal user -- there are no attempts to make it 230 # generic. 231 232 dist: 233 -rm -rf tmp 234 rm -f freetype-$(version).tar.gz 235 rm -f freetype-$(version).tar.xz 236 rm -f ft$(winversion).zip 237 238 for d in `find . -wholename '*/.git' -prune \ 239 -o -type f \ 240 -o -print` ; do \ 241 mkdir -p tmp/$$d ; \ 242 done ; 243 244 currdir=`pwd` ; \ 245 for f in `find . -wholename '*/.git' -prune \ 246 -o -name .gitattributes \ 247 -o -name .gitignore \ 248 -o -name .gitlab-ci.yml \ 249 -o -name .gitmodules \ 250 -o -name .mailmap \ 251 -o -type d \ 252 -o -print` ; do \ 253 ln -s $$currdir/$$f tmp/$$f ; \ 254 done 255 256 cd tmp ; \ 257 $(MAKE) devel ; \ 258 $(MAKE) do-dist 259 260 mv tmp freetype-$(version) 261 262 tar -H ustar -chf - freetype-$(version) \ 263 | gzip -9 -c > freetype-$(version).tar.gz 264 tar -H ustar -chf - freetype-$(version) \ 265 | xz -c > freetype-$(version).tar.xz 266 267 @# Use CR/LF for zip files. 268 zip -lr9 ft$(winversion).zip freetype-$(version) 269 270 rm -fr freetype-$(version) 271 272 273 # The locations of the latest `config.guess' and `config.sub' versions (from 274 # GNU `config' git repository), relative to the `tmp' directory used during 275 # `make dist'. 276 # 277 # GNU_CONFIG_GIT_URL = git://git.savannah.gnu.org/config.git 278 GNU_CONFIG_GIT_URL = https://git.savannah.gnu.org/git/config.git 279 GNU_CONFIG_DESTDIR = $(TOP_DIR)/subprojects/gnu-config 280 281 CONFIG_GUESS = $(GNU_CONFIG_DESTDIR)/config.guess 282 CONFIG_SUB = $(GNU_CONFIG_DESTDIR)/config.sub 283 284 # We also use this repository to access the gnulib script that converts git 285 # commit messages to a ChangeLog file. 286 CHANGELOG_SCRIPT = $(GNU_CONFIG_DESTDIR)/gitlog-to-changelog 287 288 289 # Don't say `make do-dist'. Always use `make dist' instead. 290 # 291 .PHONY: do-dist 292 293 do-dist: distclean refdoc 294 @# Without removing the files, `autoconf' and friends follow links. 295 rm -f $(TOP_DIR)/builds/unix/aclocal.m4 296 rm -f $(TOP_DIR)/builds/unix/configure.ac 297 rm -f $(TOP_DIR)/builds/unix/configure 298 299 sh autogen.sh 300 rm -rf $(TOP_DIR)/builds/unix/autom4te.cache 301 302 rm -rf $(GNU_CONFIG_DESTDIR) 303 git clone --depth=1 $(GNU_CONFIG_GIT_URL) $(GNU_CONFIG_DESTDIR) 304 cp $(CONFIG_GUESS) $(TOP_DIR)/builds/unix 305 cp $(CONFIG_SUB) $(TOP_DIR)/builds/unix 306 307 @# Generate `ChangeLog' file with commits since release 2.11.0 308 @# (when we stopped creating this file manually). 309 $(CHANGELOG_SCRIPT) \ 310 --format='%B%n' \ 311 --no-cluster \ 312 -- VER-2-11-0..$(version_tag) \ 313 > ChangeLog 314 315 @# Remove intermediate files created by the `refdoc' target. 316 rm -rf $(TOP_DIR)/docs/markdown 317 rm -f $(TOP_DIR)/docs/mkdocs.yml 318 319 @# Remove more stuff related to git. 320 rm -rf $(TOP_DIR)/subprojects/dlg 321 rm -rf $(TOP_DIR)/subprojects/gnu-config 322 323 # EOF