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