4 ####################################################################
6 # The `space' variable is used to avoid trailing spaces in defining
7 # the `T' variable later.
10 space
:= $(empty
) $(empty
)
13 ####################################################################
15 # TOP_DIR is the directory where the main FreeType source is found,
16 # as well as the `config.mk' file.
18 # TOP_DIR_2 is the directory is the top of the demonstration
21 # OBJ_DIR gives the objects directory of the FreeType library.
23 TOP_DIR ?
= ..
/freetype2
25 OBJ_DIR ?
= $(TOP_DIR
)/objs
28 ######################################################################
30 # CONFIG_MK points to the current `config.mk' to use. It is defined
31 # by default as $(TOP_DIR)/config.mk.
35 CONFIG_MK
:= $(TOP_DIR
)/config.mk
39 ######################################################################
41 # MODULES_CFG points to the current `modules.cfg' to use. It is defined
42 # by default as $(TOP_DIR)/modules.cfg.
44 MODULES_CFG ?
= $(TOP_DIR
)/modules.cfg
46 ifeq ($(wildcard $(MODULES_CFG
)),)
51 ####################################################################
53 # Check that we have a working `config.mk' in the above directory.
54 # If not, issue a warning message, then stop there.
56 ifeq ($(wildcard $(CONFIG_MK
)),)
63 $(info Please compile the library before the demo programs
!)
65 $(info I need a path to FreeType
2's `config.mk' to do that
!)
66 $(info Set the
`TOP_DIR' variable to the correct value.)
70 ####################################################################
72 # Good, now include `config.mk
' in order to know how to build
73 # object files from sources, as well as other things (compiler
79 include $(MODULES_CFG)
82 have_makefile := $(strip $(wildcard Makefile))
84 ifeq ($(PLATFORM),unix)
91 ####################################################################
93 # Define a few important variables now.
95 ifeq ($(PLATFORM),unix)
96 # without absolute paths libtool fails
97 TOP_DIR := $(shell cd $(TOP_DIR); pwd)
98 TOP_DIR_2 := $(shell cd $(TOP_DIR_2); pwd)
99 ifneq ($(have_makefile),)
100 BIN_DIR_2 ?= $(TOP_DIR_2)/bin
101 OBJ_DIR_2 ?= $(TOP_DIR_2)/objs
107 ifneq ($(have_makefile),)
116 GRAPH_DIR := $(TOP_DIR_2)/graph
121 SRC_DIR := $(TOP_DIR_2)/src
124 FT_INCLUDES := $(OBJ_BUILD) \
130 COMPILE = $(CC) $(CPPFLAGS) \
134 $DFT_CONFIG_MODULES_H="<ftmodule.h>"
136 # Enable C99 for gcc to avoid warnings.
137 # Note that clang++ aborts with an error if we use `-std=C99',
138 # so check for `++' in $(CC) also.
139 ifneq ($(findstring -pedantic
,$(COMPILE
)),)
140 ifeq ($(findstring ++,$(CC
)),)
145 FTLIB
:= $(LIB_DIR
)/$(LIBRARY
).
$A
147 # `-lm' is required to compile on some Unix systems.
149 ifeq ($(PLATFORM
),unix
)
153 ifeq ($(PLATFORM
),unixdev
)
157 # The default variables used to link the executables. These can
158 # be redefined for platform-specific stuff.
160 # The first token of LINK_ITEMS must be the executable.
162 LINK_ITEMS
= $T$(subst /,$(COMPILER_SEP
),$@
$<)
164 ifeq ($(PLATFORM
),unix
)
166 LINK_CMD
= $(subst /,$(SEP
),$(OBJ_BUILD
)/libtool
) \
168 $(subst /,$(COMPILER_SEP
),$(LDFLAGS
))
169 LINK_LIBS
= $(subst /,$(COMPILER_SEP
),$(FTLIB
) $(EFENCE
)) $(LIB_CLOCK_GETTIME
)
171 LINK_CMD
= $(CC
) $(subst /,$(COMPILER_SEP
),$(LDFLAGS
))
172 ifeq ($(PLATFORM
),unixdev
)
173 LINK_LIBS
= $(subst /,$(COMPILER_SEP
),$(FTLIB
) $(EFENCE
)) -lm
-lrt
-lz
-lbz2
174 LINK_LIBS
+= $(shell pkg-config
--libs libpng
)
175 LINK_LIBS
+= $(shell pkg-config
--libs harfbuzz
)
177 LINK_LIBS
= $(subst /,$(COMPILER_SEP
),$(FTLIB
) $(EFENCE
))
184 LINK_COMMON
= $(LINK_CMD
) \
185 $(LINK_ITEMS
) $(subst /,$(COMPILER_SEP
),$(COMMON_OBJ
)) \
187 LINK_GRAPH
= $(LINK_COMMON
) $(subst /,$(COMPILER_SEP
),$(GRAPH_LIB
)) \
188 $(GRAPH_LINK
) $(MATH
)
189 LINK_NEW
= $(LINK_CMD
) \
190 $(LINK_ITEMS
) $(subst /,$(COMPILER_SEP
),$(COMMON_OBJ
) \
192 $(LINK_LIBS
) $(subst /,$(COMPILER_SEP
),$(GRAPH_LIB
)) \
193 $(GRAPH_LINK
) $(MATH
)
195 .PHONY
: exes
clean distclean
198 ###################################################################
200 # Include the rules needed to compile the graphics sub-system.
201 # This will also select which graphics driver to compile to the
204 include $(GRAPH_DIR
)/rules.mk
207 ####################################################################
209 # Detect DOS-like platforms, currently DOS, Win 3.1, Win32 & OS/2.
211 ifneq ($(findstring $(PLATFORM
),os2 win16 win32 dos
),)
216 ###################################################################
218 # Clean-up rules. Because the `del' command on DOS-like platforms
219 # cannot take a long list of arguments, we simply erase the directory
225 -del objs\
*.
$(SO
) 2> nul
226 -del
$(subst /,\
,$(TOP_DIR_2
)/src
/*.bak
) 2> nul
228 distclean_demo
: clean_demo
229 -del objs\
*.lib
2> nul
230 -del bin\
*.exe
2> nul
235 -$(DELETE
) $(subst /,$(SEP
),$(OBJ_DIR_2
)/*.
$(SO
) $(OBJ_DIR_2
)/*.
$(O
))
236 -$(DELETE
) $(subst /,$(SEP
),$(OBJ_DIR_2
)/*.
$(SA
) $(OBJ_DIR_2
)/*.
$(A
))
237 -$(DELETE
) $(subst /,$(SEP
),$(OBJ_DIR_2
)/.libs
/*)
238 -$(DELETE
) $(subst /,$(SEP
),$(SRC_DIR
)/*.bak graph
/*.bak
)
239 -$(DELETE
) $(subst /,$(SEP
),$(SRC_DIR
)/*~ graph
/*~
)
241 distclean_demo
: clean_demo
242 -$(DELETE
) $(subst /,$(SEP
),$(EXES
:%=$(BIN_DIR_2
)/%$E))
243 -$(DELETE
) $(subst /,$(SEP
),$(GRAPH_LIB
))
244 ifeq ($(PLATFORM
),unix
)
245 -$(DELETE
) $(BIN_DIR_2
)/.libs
/*
246 -$(DELDIR
) $(BIN_DIR_2
)/.libs
252 distclean: distclean_demo
255 ####################################################################
257 # Compute the executable suffix to use, and put it in `E'.
258 # It is ".exe" on DOS-ish platforms, and nothing otherwise.
267 ####################################################################
269 # POSIX TERMIOS: Do not define if you use OLD U*ix like 4.2BSD.
271 ifeq ($(PLATFORM
),unix
)
272 EXTRAFLAGS
= $DUNIX $DHAVE_POSIX_TERMIOS
275 ifeq ($(PLATFORM
),unixdev
)
276 EXTRAFLAGS
= $DUNIX $DHAVE_POSIX_TERMIOS
280 ###################################################################
282 # The list of demonstration programs to build.
284 # Note that ttdebug only works if the FreeType's `truetype' driver has
285 # been compiled with TT_CONFIG_OPTION_BYTECODE_INTERPRETER defined.
292 # Comment out the next line if you don't have a graphics subsystem.
300 # ftvalid requires ftgxval.c and ftotval.c
302 ifneq ($(findstring ftgxval.c
,$(BASE_EXTENSIONS
)),)
303 ifneq ($(findstring ftotval.c
,$(BASE_EXTENSIONS
)),)
308 # The following programs are not compiled automatically; either comment
309 # out the affected line or use the program name as a Makefile target.
317 exes
: $(EXES
:%=$(BIN_DIR_2
)/%$E)
320 INCLUDES
:= $(subst /,$(COMPILER_SEP
),$(FT_INCLUDES
))
324 $(OBJ_DIR_2
)/%.
$(SO
): $(SRC_DIR
)/%.c
$(FTLIB
)
325 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<)
328 ####################################################################
330 # Rules for compiling object files for text-only demos.
332 $(OBJ_DIR_2
)/common.
$(SO
): $(SRC_DIR
)/common.c
333 $(OBJ_DIR_2
)/output.
$(SO
): $(SRC_DIR
)/output.c
334 $(OBJ_DIR_2
)/mlgetopt.
$(SO
): $(SRC_DIR
)/mlgetopt.c
335 COMMON_OBJ
:= $(OBJ_DIR_2
)/common.
$(SO
) \
336 $(OBJ_DIR_2
)/output.
$(SO
) \
337 $(OBJ_DIR_2
)/mlgetopt.
$(SO
)
340 FTCOMMON_OBJ
:= $(OBJ_DIR_2
)/ftcommon.
$(SO
)
341 $(FTCOMMON_OBJ
): $(SRC_DIR
)/ftcommon.c
$(SRC_DIR
)/ftcommon.h
342 $(COMPILE
) $(GRAPH_INCLUDES
:%=$I%) \
343 $T$(subst /,$(COMPILER_SEP
),$@
$<)
346 $(OBJ_DIR_2
)/ftlint.
$(SO
): $(SRC_DIR
)/ftlint.c
347 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<)
349 $(OBJ_DIR_2
)/ftbench.
$(SO
): $(SRC_DIR
)/ftbench.c
350 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<) $(EXTRAFLAGS
)
352 $(OBJ_DIR_2
)/ftpatchk.
$(SO
): $(SRC_DIR
)/ftpatchk.c
353 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<) $(EXTRAFLAGS
)
355 $(OBJ_DIR_2
)/ftchkwd.
$(SO
): $(SRC_DIR
)/ftchkwd.c
356 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<) $(EXTRAFLAGS
)
358 $(OBJ_DIR_2
)/compos.
$(SO
): $(SRC_DIR
)/compos.c
359 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<)
361 $(OBJ_DIR_2
)/ftmemchk.
$(SO
): $(SRC_DIR
)/ftmemchk.c
362 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<)
364 $(OBJ_DIR_2
)/fttimer.
$(SO
): $(SRC_DIR
)/fttimer.c
365 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<)
367 $(OBJ_DIR_2
)/fttry.
$(SO
): $(SRC_DIR
)/fttry.c
368 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<)
370 $(OBJ_DIR_2
)/testname.
$(SO
): $(SRC_DIR
)/testname.c
371 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<)
373 # $(OBJ_DIR_2)/ftsbit.$(SO): $(SRC_DIR)/ftsbit.c
374 # $(COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
377 # We simplify the dependencies on the graphics library by using
378 # $(GRAPH_LIB) directly.
380 $(OBJ_DIR_2
)/ftgamma.
$(SO
): $(SRC_DIR
)/ftgamma.c \
381 $(SRC_DIR
)/ftcommon.h \
383 $(COMPILE
) $(GRAPH_INCLUDES
:%=$I%) \
384 $T$(subst /,$(COMPILER_SEP
),$@
$<)
386 $(OBJ_DIR_2
)/ftmulti.
$(SO
): $(SRC_DIR
)/ftmulti.c \
388 $(COMPILE
) $(GRAPH_INCLUDES
:%=$I%) \
389 $T$(subst /,$(COMPILER_SEP
),$@
$<)
391 $(OBJ_DIR_2
)/ftstring.
$(SO
): $(SRC_DIR
)/ftstring.c \
392 $(SRC_DIR
)/ftcommon.h \
394 $(COMPILE
) $(GRAPH_INCLUDES
:%=$I%) \
395 $T$(subst /,$(COMPILER_SEP
),$@
$<)
398 ####################################################################
400 # Special rule to compile the `ftdump' program as it includes
401 # internal header files.
403 $(OBJ_DIR_2
)/ftdump.
$(SO
): $(SRC_DIR
)/ftdump.c
404 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<) $DFT2_BUILD_LIBRARY
407 ####################################################################
409 # Special rule to compile the `t1dump' program as it includes
410 # the Type1 source path.
412 $(OBJ_DIR_2
)/t1dump.
$(SO
): $(SRC_DIR
)/t1dump.c
413 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<)
416 ####################################################################
418 # Special rule to compile the `ftvalid' program as it includes
419 # internal header files.
421 $(OBJ_DIR_2
)/ftvalid.
$(SO
): $(SRC_DIR
)/ftvalid.c
422 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<) $DFT2_BUILD_LIBRARY
425 ####################################################################
427 # Special rule to compile the `ftview' program as it includes
428 # internal header files.
430 $(OBJ_DIR_2
)/ftview.
$(SO
): $(SRC_DIR
)/ftview.c \
431 $(SRC_DIR
)/ftcommon.h \
433 $(COMPILE
) $(GRAPH_INCLUDES
:%=$I%) \
434 $T$(subst /,$(COMPILER_SEP
),$@
$<) $DFT2_BUILD_LIBRARY
437 ####################################################################
439 # Special rule to compile the `ftdiff' program as it includes
440 # internal header files.
442 $(OBJ_DIR_2
)/ftdiff.
$(SO
): $(SRC_DIR
)/ftdiff.c \
443 $(SRC_DIR
)/ftcommon.h \
445 $(COMPILE
) $(GRAPH_INCLUDES
:%=$I%) \
446 $T$(subst /,$(COMPILER_SEP
),$@
$<) $DFT2_BUILD_LIBRARY
449 ####################################################################
451 # Special rule to compile the `ftgrid' program as it includes
452 # internal header files.
454 $(OBJ_DIR_2
)/ftgrid.
$(SO
): $(SRC_DIR
)/ftgrid.c \
455 $(SRC_DIR
)/ftcommon.h \
457 $(COMPILE
) $(GRAPH_INCLUDES
:%=$I%) \
458 $T$(subst /,$(COMPILER_SEP
),$@
$<) $DFT2_BUILD_LIBRARY
461 ####################################################################
463 # Special rule to compile the `ttdebug' program as it includes
464 # the TrueType source path and needs extra flags for correct keyboard
467 $(OBJ_DIR_2
)/ttdebug.
$(SO
): $(SRC_DIR
)/ttdebug.c
468 $(COMPILE
) $T$(subst /,$(COMPILER_SEP
),$@
$<) \
469 $I$(subst /,$(COMPILER_SEP
),$(TOP_DIR
)/src
/truetype
) \
470 $(EXTRAFLAGS
) $DFT2_BUILD_LIBRARY
473 ####################################################################
475 # Rules used to link the executables. Note that they could be
476 # overridden by system-specific things.
478 $(BIN_DIR_2
)/ftlint
$E: $(OBJ_DIR_2
)/ftlint.
$(SO
) $(FTLIB
) $(COMMON_OBJ
)
481 $(BIN_DIR_2
)/ftbench
$E: $(OBJ_DIR_2
)/ftbench.
$(SO
) $(FTLIB
) $(COMMON_OBJ
)
484 $(BIN_DIR_2
)/ftpatchk
$E: $(OBJ_DIR_2
)/ftpatchk.
$(SO
) $(FTLIB
) $(COMMON_OBJ
)
487 $(BIN_DIR_2
)/ftchkwd
$E: $(OBJ_DIR_2
)/ftchkwd.
$(SO
) $(FTLIB
) $(COMMON_OBJ
)
490 $(BIN_DIR_2
)/ftmemchk
$E: $(OBJ_DIR_2
)/ftmemchk.
$(SO
) $(FTLIB
) $(COMMON_OBJ
)
493 $(BIN_DIR_2
)/compos
$E: $(OBJ_DIR_2
)/compos.
$(SO
) $(FTLIB
) $(COMMON_OBJ
)
496 $(BIN_DIR_2
)/ftvalid
$E: $(OBJ_DIR_2
)/ftvalid.
$(SO
) $(FTLIB
) $(COMMON_OBJ
)
499 $(BIN_DIR_2
)/ftdump
$E: $(OBJ_DIR_2
)/ftdump.
$(SO
) $(FTLIB
) $(COMMON_OBJ
)
502 $(BIN_DIR_2
)/fttimer
$E: $(OBJ_DIR_2
)/fttimer.
$(SO
) $(FTLIB
) $(COMMON_OBJ
)
505 $(BIN_DIR_2
)/fttry
$E: $(OBJ_DIR_2
)/fttry.
$(SO
) $(FTLIB
)
508 # $(BIN_DIR_2)/ftsbit$E: $(OBJ_DIR_2)/ftsbit.$(SO) $(FTLIB)
511 $(BIN_DIR_2
)/t1dump
$E: $(OBJ_DIR_2
)/t1dump.
$(SO
) $(FTLIB
)
514 $(BIN_DIR_2
)/ttdebug
$E: $(OBJ_DIR_2
)/ttdebug.
$(SO
) $(FTLIB
) $(COMMON_OBJ
)
517 $(BIN_DIR_2
)/testname
$E: $(OBJ_DIR_2
)/testname.
$(SO
) $(FTLIB
)
521 $(BIN_DIR_2
)/ftview
$E: $(OBJ_DIR_2
)/ftview.
$(SO
) $(FTLIB
) \
522 $(GRAPH_LIB
) $(COMMON_OBJ
) $(FTCOMMON_OBJ
)
525 $(BIN_DIR_2
)/ftgrid
$E: $(OBJ_DIR_2
)/ftgrid.
$(SO
) $(FTLIB
) \
526 $(GRAPH_LIB
) $(COMMON_OBJ
) $(FTCOMMON_OBJ
)
529 $(BIN_DIR_2
)/ftgamma
$E: $(OBJ_DIR_2
)/ftgamma.
$(SO
) $(FTLIB
) \
530 $(GRAPH_LIB
) $(COMMON_OBJ
) $(FTCOMMON_OBJ
)
533 $(BIN_DIR_2
)/ftdiff
$E: $(OBJ_DIR_2
)/ftdiff.
$(SO
) $(FTLIB
) \
534 $(GRAPH_LIB
) $(COMMON_OBJ
) $(FTCOMMON_OBJ
)
537 $(BIN_DIR_2
)/ftmulti
$E: $(OBJ_DIR_2
)/ftmulti.
$(SO
) $(FTLIB
) \
538 $(GRAPH_LIB
) $(COMMON_OBJ
) $(FTCOMMON_OBJ
)
541 $(BIN_DIR_2
)/ftstring
$E: $(OBJ_DIR_2
)/ftstring.
$(SO
) $(FTLIB
) \
542 $(GRAPH_LIB
) $(COMMON_OBJ
) $(FTCOMMON_OBJ
)
549 # This target builds the tarballs.
551 # Not to be run by a normal user -- there are no attempts to make it
554 # we check for `dist', not `distclean'
555 ifneq ($(findstring distx
,$(MAKECMDGOALS
)x
),)
556 FT_H
:= ..
/freetype2
/include/freetype
/freetype.h
558 major
:= $(shell sed
-n
's/.*FREETYPE_MAJOR[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H
))
559 minor
:= $(shell sed
-n
's/.*FREETYPE_MINOR[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H
))
560 patch
:= $(shell sed
-n
's/.*FREETYPE_PATCH[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H
))
562 # ifneq ($(findstring x0x,x$(patch)x),)
563 # version := $(major).$(minor)
564 # winversion := $(major)$(minor)
566 version
:= $(major
).
$(minor
).
$(patch
)
567 winversion
:= $(major
)$(minor
)$(patch
)
573 rm -f ft2demos-
$(version
).
tar.gz
574 rm -f ft2demos-
$(version
).
tar.bz2
575 rm -f ftdmo
$(winversion
).zip
577 for d in
`find . -wholename '*/.git' -prune \
584 for f in
`find . -wholename '*/.git' -prune \
585 -o -name .gitignore \
589 ln
-s
$$currdir/$$f tmp
/$$f ; \
595 mv tmp ft2demos-
$(version
)
597 tar -H ustar
-chf
- ft2demos-
$(version
) \
598 | gzip
-c
> ft2demos-
$(version
).
tar.gz
599 tar -H ustar
-chf
- ft2demos-
$(version
) \
600 | bzip2
-c
> ft2demos-
$(version
).
tar.bz2
602 @
# Use CR/LF for zip files.
603 zip
-lr ftdmo
$(winversion
).zip ft2demos-
$(version
)
605 rm -fr ft2demos-
$(version
)