blob: d552a4a179b25e938b2df9fcc62c0990d46e5c36 [file] [log] [blame]
David Turner046f7a02000-09-15 22:42:06 +00001#
2# FreeType build system -- top-level sub-Makefile
3#
4
Werner Lemberg47a5f412000-10-17 03:38:43 +00005
Werner Lemberg7fa49ce2010-07-12 00:33:36 +02006# Copyright 1996-2000, 2001, 2003, 2006, 2008, 2009, 2010 by
Werner Lemberg47a5f412000-10-17 03:38:43 +00007# 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 Turner046f7a02000-09-15 22:42:06 +000014
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 Lemberg1639c792006-05-06 16:44:58 +000020# - 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 Turner046f7a02000-09-15 22:42:06 +000023#
Werner Lemberg1639c792006-05-06 16:44:58 +000024# A summary of the detection is displayed, and the file `config.mk' is
25# created in the current directory.
David Turner046f7a02000-09-15 22:42:06 +000026#
Werner Lemberg1639c792006-05-06 16:44:58 +000027# - 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 Turner046f7a02000-09-15 22:42:06 +000032#
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 Lemberg4e33f9e2008-07-05 06:35:28 +000037# 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
Werner Lemberge0d15592006-05-10 13:44:47 +000047.PHONY: all dist distclean modules setup
David Turner046f7a02000-09-15 22:42:06 +000048
Werner Lemberg59939242006-01-31 20:17:42 +000049
Werner Lemberg91481f82000-11-04 23:41:02 +000050# The `space' variable is used to avoid trailing spaces in defining the
51# `T' variable later.
52#
53empty :=
54space := $(empty) $(empty)
55
56
Werner Lemberg59939242006-01-31 20:17:42 +000057# 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
Werner Lemberg1639c792006-05-06 16:44:58 +000069# class file resides.
Werner Lemberg59939242006-01-31 20:17:42 +000070#
Werner Lemberg8a4de0d2006-02-01 07:52:11 +000071FTMODULE_H ?= $(OBJ_DIR)/ftmodule.h
Werner Lemberg59939242006-01-31 20:17:42 +000072
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
Werner Lemberg8a4de0d2006-02-01 07:52:11 +000085CONFIG_MK ?= config.mk
David Turner046f7a02000-09-15 22:42:06 +000086
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 Lemberg89df58f2002-06-14 08:09:25 +000092# not necessarily $(TOP_DIR).
David Turner046f7a02000-09-15 22:42:06 +000093
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# Include the automatic host platform detection rules when we need to
107# check the platform.
108#
109ifdef check_platform
110
Werner Lemberg59939242006-01-31 20:17:42 +0000111 all modules: setup
David Turner046f7a02000-09-15 22:42:06 +0000112
Werner Lemberg89df58f2002-06-14 08:09:25 +0000113 include $(TOP_DIR)/builds/detect.mk
David Turner046f7a02000-09-15 22:42:06 +0000114
David Turner046f7a02000-09-15 22:42:06 +0000115 # 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 Lemberg594f0c92000-12-20 22:09:41 +0000118 # GNU make. Similarly, `nul' is created if e.g. `make setup win32' has
119 # been erroneously used.
David Turner046f7a02000-09-15 22:42:06 +0000120 #
Werner Lemberg59939242006-01-31 20:17:42 +0000121 # Note: This test is duplicated in `builds/unix/detect.mk'.
Werner Lemberga64c55b2001-05-12 06:40:50 +0000122 #
Werner Lemberg858f3102003-06-09 04:46:30 +0000123 is_unix := $(strip $(wildcard /sbin/init) \
124 $(wildcard /usr/sbin/init) \
125 $(wildcard /hurd/auth))
David Turnerebe85f52001-05-11 14:25:57 +0000126 ifneq ($(is_unix),)
127
David Turnerebe85f52001-05-11 14:25:57 +0000128 distclean:
Werner Lembergbd547dc2000-09-22 21:23:29 +0000129 $(RM) builds/unix/config.cache
130 $(RM) builds/unix/config.log
131 $(RM) builds/unix/config.status
132 $(RM) builds/unix/unix-def.mk
133 $(RM) builds/unix/unix-cc.mk
Werner Lemberg5e3614f2003-09-12 19:38:13 +0000134 $(RM) builds/unix/freetype2.pc
Werner Lemberg594f0c92000-12-20 22:09:41 +0000135 $(RM) nul
David Turner046f7a02000-09-15 22:42:06 +0000136
David Turnerebe85f52001-05-11 14:25:57 +0000137 endif # test is_unix
138
David Turner046f7a02000-09-15 22:42:06 +0000139 # IMPORTANT:
140 #
141 # `setup' must be defined by the host platform detection rules to create
142 # the `config.mk' file in the current directory.
143
144else
145
146 # A configuration sub-Makefile is present -- simply run it.
147 #
148 all: single
149
David Turner046f7a02000-09-15 22:42:06 +0000150 BUILD_PROJECT := yes
151 include $(CONFIG_MK)
152
153endif # test check_platform
154
Werner Lemberg858f3102003-06-09 04:46:30 +0000155
Werner Lemberg59939242006-01-31 20:17:42 +0000156# We always need the list of modules in ftmodule.h.
157#
158all setup: $(FTMODULE_H)
159
160
161# The `modules' target unconditionally rebuilds the module list.
162#
163modules:
164 $(FTMODULE_H_INIT)
165 $(FTMODULE_H_CREATE)
166 $(FTMODULE_H_DONE)
167
168include $(TOP_DIR)/builds/modules.mk
169
170
Werner Lemberge0d15592006-05-10 13:44:47 +0000171# This target builds the tarballs.
172#
173# Not to be run by a normal user -- there are no attempts to make it
174# generic.
175
Werner Lembergec5b4502006-12-10 07:51:38 +0000176# we check for `dist', not `distclean'
177ifneq ($(findstring distx,$(MAKECMDGOALS)x),)
Werner Lemberg4e1d6c02006-12-09 08:20:37 +0000178 FT_H := include/freetype/freetype.h
179
Werner Lemberg19dfcbd2009-10-06 12:00:43 +0200180 major := $(shell sed -n 's/.*FREETYPE_MAJOR[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H))
181 minor := $(shell sed -n 's/.*FREETYPE_MINOR[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H))
182 patch := $(shell sed -n 's/.*FREETYPE_PATCH[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H))
Werner Lemberg4e1d6c02006-12-09 08:20:37 +0000183
184 version := $(major).$(minor).$(patch)
185 winversion := $(major)$(minor)$(patch)
186endif
187
Werner Lemberge0d15592006-05-10 13:44:47 +0000188dist:
189 -rm -rf tmp
Werner Lemberg4e1d6c02006-12-09 08:20:37 +0000190 rm -f freetype-$(version).tar.gz
191 rm -f freetype-$(version).tar.bz2
192 rm -f ft$(winversion).zip
Werner Lemberge0d15592006-05-10 13:44:47 +0000193
Werner Lemberg19dfcbd2009-10-06 12:00:43 +0200194 for d in `find . -wholename '*/.git' -prune \
Werner Lemberge0d15592006-05-10 13:44:47 +0000195 -o -type f \
196 -o -print` ; do \
197 mkdir -p tmp/$$d ; \
198 done ;
199
200 currdir=`pwd` ; \
Werner Lemberg19dfcbd2009-10-06 12:00:43 +0200201 for f in `find . -wholename '*/.git' -prune \
Werner Lembergee5d3b52011-06-30 15:08:15 +0200202 -o -name .gitignore \
Werner Lemberge0d15592006-05-10 13:44:47 +0000203 -o -type d \
204 -o -print` ; do \
205 ln -s $$currdir/$$f tmp/$$f ; \
206 done
207
208 @# Prevent generation of .pyc files. Python follows (soft) links if
209 @# the link's directory is write protected, so we have temporarily
210 @# disable write access here too.
211 chmod -w src/tools/docmaker
212
213 cd tmp ; \
214 $(MAKE) devel ; \
215 $(MAKE) do-dist
216
217 chmod +w src/tools/docmaker
218
Werner Lemberg4e1d6c02006-12-09 08:20:37 +0000219 mv tmp freetype-$(version)
Werner Lemberge0d15592006-05-10 13:44:47 +0000220
Werner Lemberg4e1d6c02006-12-09 08:20:37 +0000221 tar cfh - freetype-$(version) \
Werner Lembergfb4ddb22009-01-14 05:30:56 +0000222 | gzip -9 -c > freetype-$(version).tar.gz
Werner Lemberg4e1d6c02006-12-09 08:20:37 +0000223 tar cfh - freetype-$(version) \
224 | bzip2 -c > freetype-$(version).tar.bz2
Werner Lemberge0d15592006-05-10 13:44:47 +0000225
226 @# Use CR/LF for zip files.
Werner Lembergfb4ddb22009-01-14 05:30:56 +0000227 zip -lr9 ft$(winversion).zip freetype-$(version)
Werner Lemberge0d15592006-05-10 13:44:47 +0000228
Werner Lemberg4e1d6c02006-12-09 08:20:37 +0000229 rm -fr freetype-$(version)
Werner Lemberge0d15592006-05-10 13:44:47 +0000230
231
232# The locations of the latest `config.guess' and `config.sub' versions (from
Werner Lemberg7fa49ce2010-07-12 00:33:36 +0200233# GNU `config' git repository), relative to the `tmp' directory used during
234# `make dist'.
Werner Lemberge0d15592006-05-10 13:44:47 +0000235#
Werner Lembergbcfcc712008-05-15 09:14:39 +0000236CONFIG_GUESS = ~/git/config/config.guess
237CONFIG_SUB = ~/git/config/config.sub
Werner Lemberge0d15592006-05-10 13:44:47 +0000238
239
240# Don't say `make do-dist'. Always use `make dist' instead.
241#
242.PHONY: do-dist
243
244do-dist: distclean refdoc
245 @# Without removing the files, `autoconf' and friends follow links.
246 rm -f builds/unix/aclocal.m4
Werner Lemberg3d69a192006-05-10 13:47:22 +0000247 rm -f builds/unix/configure.ac
248 rm -f builds/unix/configure
Werner Lemberge0d15592006-05-10 13:44:47 +0000249
250 sh autogen.sh
251 rm -rf builds/unix/autom4te.cache
252
253 cp $(CONFIG_GUESS) builds/unix
254 cp $(CONFIG_SUB) builds/unix
255
David Turner046f7a02000-09-15 22:42:06 +0000256# EOF