-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
140 lines (122 loc) · 5.47 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# common targets:
# <no target>, build, ttf-dir: create dedicated dir with TTF files
# ttf: create export dir with TTF files, track changes
# 4web: dtto for TTF, WOFF, SVG, and EOT
FONTFORGE = fontforge
PYTHON = python3
FONTLINT = fontlint
# TTF->EOT converters in fallback order
# the first one is canonical choice used in the release process
MKEOT = mkeot
# URLs to be used for root string within EOT file;
# defaults to "libre roots" that allow usage on any common web page
MKEOT_URLS = http:// https:// file://
TTF2EOT = ttf2eot
ifneq ($(strip $(shell which $(MKEOT) 2>/dev/null)),)
make_eot = $(MKEOT) $(1) $(MKEOT_URLS) > $(2)
else
ifneq ($(strip $(shell which $(TTF2EOT) 2>/dev/null)),)
make_eot = $(TTF2EOT) $(1) > $(2)
else
make_eot = $(error No tool for TTF->EOT conversion: $(MKEOT), $(TTF2EOT))
endif
endif
EXPORTSCRIPT = scripts/fontexport.pe
FONTTOOLSCRIPT = scripts/setisFixedPitch-fonttools.py
FONTVERSION_UPDATE_SCRIPT = scripts/fontfile_version_update.py
SCRIPTS = $(EXPORTSCRIPT) scripts/sfd2ttf.pe scripts/ttf2sfd.pe
MISCFILES = AUTHORS ChangeLog LICENSE README.md TODO
SRCDIR = src
EXPORTDIR = export
CHECK_PREFIX = check
VER = 2.1.5
NAME = Liberation
VARIANTS = \
Mono-Regular Mono-Bold Mono-Italic Mono-BoldItalic \
Sans-Regular Sans-Bold Sans-Italic Sans-BoldItalic \
Serif-Regular Serif-Bold Serif-Italic Serif-BoldItalic
DISTPREFIX := liberation-fonts-$(VER)
DISTPREFIX_TTF := liberation-fonts-ttf-$(VER)
SFDFILES := $(addprefix $(SRCDIR)/$(NAME), $(VARIANTS:=.sfd))
TTFFILES := $(addprefix $(EXPORTDIR)/$(NAME), $(VARIANTS:=.ttf))
# keeping backward compatibility for "build"
all build: ttf-dir
versionupdate:
$(PYTHON) $(FONTVERSION_UPDATE_SCRIPT) $(SRCDIR) $(VER)
$(EXPORTDIR):
mkdir -p $@
# TrueType/OpenType Font, general usage
# - ttf cares about source file changes, using shared EXPORTDIR
# - ttf-dir should be a bit more efficient, creating dedicated dir for TTF
FORMATS = ttf
ttf-dir:: $(SFDFILES)
$(FONTFORGE) -script $(EXPORTSCRIPT) -ttf $^
$(PYTHON) $(FONTTOOLSCRIPT) src/LiberationMono-*.ttf
mv src/LiberationMono-Regular-fixed.ttf src/LiberationMono-Regular.ttf
mv src/LiberationMono-Italic-fixed.ttf src/LiberationMono-Italic.ttf
mv src/LiberationMono-Bold-fixed.ttf src/LiberationMono-Bold.ttf
mv src/LiberationMono-BoldItalic-fixed.ttf src/LiberationMono-BoldItalic.ttf
mkdir -p $(DISTPREFIX_TTF)
mv $(addsuffix .ttf,$(basename $^)) $(DISTPREFIX_TTF)
# web sites usage
# Web Open Font Format (WOFF); for all modern browsers (W3C recommendation)
FORMATS += woff
# SVG Font; only for WebKit and Presto based browsers (Firefox "avoids" it)
FORMATS += svg
# Embedded OpenType (EOT); MSIE only [extra recipe, FontForge can't create EOT]
FORMATS += eot
eot:: $(addprefix $(EXPORTDIR)/$(NAME), $(VARIANTS:=.eot))
@echo
$(EXPORTDIR)/%.eot: $(EXPORTDIR)/%.ttf | $(EXPORTDIR)
$(call make_eot,$<,$@)
4web: ttf woff svg eot
# XXX: declare other formats here if needed (TeX, etc.)
# default for formats without extra recipes defined above (e.g., not "eot"):
# summary per-format target + single file export for these declared formats
define FORMAT_template =
$(1):: $$(addprefix $$(EXPORTDIR)/$$(NAME), $$(VARIANTS:=.$(1)))
@echo
$$(EXPORTDIR)/%.$(1):: $$(SRCDIR)/%.sfd | $$(EXPORTDIR)
$$(FONTFORGE) -script $$(EXPORTSCRIPT) -$$(lastword $$(subst ., ,$$@)) $$< 2>/dev/null
mv $$(SRCDIR)/$$(notdir $$@) $$(EXPORTDIR)
endef
$(foreach format,$(FORMATS),$(eval $(call FORMAT_template,$(format))))
dist: clean-dist dist-sfd dist-ttf
dist-src: dist-sfd
dist-sfd:: $(SFDFILES)
tempdir=$$(mktemp -d) \
&& mkdir -p $${tempdir}/$(DISTPREFIX)/{src,scripts} \
&& cp Makefile $(MISCFILES) $${tempdir}/$(DISTPREFIX) \
&& cp $(SFDFILES) $${tempdir}/$(DISTPREFIX)/src \
&& cp $(SCRIPTS) $(FONTTOOLSCRIPT) $(FONTVERSION_UPDATE_SCRIPT) $${tempdir}/$(DISTPREFIX)/scripts \
&& tar Cczvhf $${tempdir} $(DISTPREFIX).tar.gz $(DISTPREFIX) \
|| echo 'Problem encountered ($@)'; rm -rf -- $${tempdir}
dist-ttf: ttf
$(PYTHON) $(FONTTOOLSCRIPT) export/LiberationMono-*.ttf
mv export/LiberationMono-Regular-fixed.ttf export/LiberationMono-Regular.ttf
mv export/LiberationMono-Italic-fixed.ttf export/LiberationMono-Italic.ttf
mv export/LiberationMono-Bold-fixed.ttf export/LiberationMono-Bold.ttf
mv export/LiberationMono-BoldItalic-fixed.ttf export/LiberationMono-BoldItalic.ttf
tempdir=$$(mktemp -d) \
&& mkdir -p $${tempdir}/$(DISTPREFIX_TTF) \
&& cp $(MISCFILES) $(TTFFILES) $${tempdir}/$(DISTPREFIX_TTF) \
&& tar Cczvhf $${tempdir} $(DISTPREFIX_TTF).tar.gz $(DISTPREFIX_TTF) \
|| echo 'Problem encountered ($@)'; rm -rf -- $${tempdir}
# substitute tar line with this if needed:
# && zip -j $(DISTPREFIX_TTF).zip $(MISCFILES) $(TTFFILES) \
check:
log="$(CHECK_PREFIX)_$$(git describe --dirty --always 2>/dev/null||date +%Y%m%d)" \
&& for sfd in $(SFDFILES); do \
$(FONTLINT) $${sfd} 2>/dev/null | tee -a $${log}; echo; \
done
clean: clean-dist
rm -rf -- $(DISTPREFIX)* $(DISTPREFIX_TTF)*
rm -rf -- $(EXPORTDIR)
rm -f -- $(CHECK_PREFIX)_*
rm -f src/*.ttf
clean-dist:
rm -f -- *.tar.gz *.zip
install:
mkdir -p $(DESTDIR)/usr/share/fonts/$(DISTPREFIX_TTF) || true
install $(DISTPREFIX_TTF)/* $(DESTDIR)/usr/share/fonts/$(DISTPREFIX_TTF)
.PHONY: all build ttf-dir ttf dist dist-src dist-sfd dist-ttf 4web $(FORMATS) check clean clean-dist