forked from sebschub/MnSymbol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
234 lines (178 loc) · 7.11 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
SHELL := /bin/sh
FONTFORGE := fontforge
MF := mf -interaction nonstopmode -halt-on-error
MFTOPT1 := mf2pt1
GFTODVI := gftodvi
T1TESTPAGE := t1testpage
PSTOPDF := ps2pdf
PYTHON := python2.7
PDFLATEX := pdflatex -interaction nonstopmode -halt-on-error
RM := rm -rf
TAR := tar
ZIP := zip
MKDIR := mkdir -p
INSTALL := install
INSTALLDIR := $(INSTALL) -d
INSTALLDATA := $(INSTALL) -m 644
ifneq (,$(findstring install,$(MAKECMDGOALS)))
TEXMFDIR := $(shell kpsewhich -expand-var='$$TEXMFHOME')
endif
pkg := MnSymbol
font := MnSymbol
names := A B C D E F S
weights := 5 6 7 8 9 10 12 -Bold5 -Bold6 -Bold7 -Bold8 -Bold9 -Bold10 -Bold12
fontdir := fonts
testdir := test
outdirs := $(fontdir) $(testdir)
# $(call lc,text)
lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
depfiles := $(names:%=$(font)%.dep)
encfiles := $(foreach i,$(names),enc/$(pkg)$i.enc)
mapfile := enc/$(pkg).map
fonts := $(foreach i,$(names),$(weights:%=$(font)$(i)%))
tfmfiles := $(fonts:%=$(fontdir)/%.tfm)
pfbfiles := $(fonts:%=$(fontdir)/%.pfb)
otffiles := $(weights:%=$(fontdir)/$(font)%.otf)
gffiles := $(fonts:%=$(testdir)/%.2602gf)
prooffiles := $(fonts:%=$(testdir)/%.dvi)
chartfiles := $(fonts:%=$(testdir)/%.pdf)
srcfiles := $(fonts:%=source/%.mf) $(names:%=source/$(font)%.mf) $(addprefix source/,mdbase.mf mdaccents.mf mdarrows.mf mddelims.mf mdgeometric.mf mdoperators.mf mdrelations.mf mdturnstile.mf)
tempfiles := $(addprefix latex/,$(pkg).aux $(pkg).log $(pkg).out $(pkg).toc $(pkg).hd)
# create output directories
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
create-dirs := $(shell $(MKDIR) $(outdirs))
endif
# macro for generating font-specific rules
# $(call fontrule,weight)
define fontrule
.PHONY: $1
$1: $(fontdir)/$(font)-$1.otf
$(fontdir)/$(font)$1.otf: $(foreach i,$(names),$(fontdir)/$(font)$i$1.pfb)
.PHONY: $1-test
$1-test: $1-proofs $1-charts
.PHONY: $1-proofs
$1-proofs: $(filter %-$1.dvi,$(prooffiles))
.PHONY: $1-charts
$1-carts: $(filter %-$1.dvi,$(chartfiles))
endef
# default rule
.PHONY: all
all: texfonts opentype latex $(mapfile)
# rules for building Makefiles with additional dependencies
$(depfiles): %.dep: source/%.mf scripts/finddeps.py
@echo "$(weights:%=$(fontdir)/$*%.tfm) $(weights:%=$(fontdir)/$*%.pfb) $(weights:%=$(testdir)/$*%.2602gf) $@: $< $$($(PYTHON) scripts/finddeps.py $<)" > $@
@echo "$(weights:%=$(fontdir)/$*%.pfb): enc/$$(echo $* | sed 's/$(font)/$(pkg)/').enc" >> $@
# rules for building Postscript fonts and TeX metrics
.PHONY: texfonts
texfonts: $(pfbfiles) $(tfmfiles)
$(foreach weight,$(weights),$(eval $(call fontrule,$(weight))))
$(pfbfiles): $(fontdir)/%.pfb: source/%.mf scripts/process.pe
cd $(fontdir) && $(MFTOPT1) --rounding 0.25 --encoding=$(abspath $(filter %.enc,$^)) --ffscript=$(abspath scripts/process.pe) $(abspath $<)
$(tfmfiles): $(fontdir)/%.tfm: source/%.mf
cd $(fontdir) && MFINPUTS=$(abspath source) $(MF) '\mode=nullmode; input $*'
ifneq ($(MAKECMDGOALS),clean)
-include $(depfiles)
endif
# rules for building OpenType fonts
.PHONY: opentype
opentype: $(otffiles)
$(otffiles): source/features.fea scripts/makeotf.py
$(PYTHON) scripts/makeotf.py -f $< $(filter %.pfb,$^) $@
# rules for building the mapfile
$(mapfile):
for i in $(names); do \
n=$$(echo $$i | tr [:upper:] [:lower:]); \
for weight in $(weights); do \
echo "$(font)$$i$${weight} $(font)$$i$${weight} <$(font)$$i$${weight}.pfb" >> $@; \
done; \
done
# rules for building the LaTeX package
.PHONY: latex
latex: latex/$(pkg).sty
latex/$(pkg).sty: latex/$(pkg).ins latex/$(pkg).dtx
cd latex && $(PDFLATEX) $(pkg).ins
# rules for rebuilding the documentation
.PHONY: doc
doc: latex/$(pkg).pdf
latex/$(pkg).pdf: latex/$(pkg).dtx
cd latex && $(PDFLATEX) $(pkg).dtx && \
(while grep -s 'Rerun to get' $(pkg).log; do \
$(PDFLATEX) $(pkg).dtx; \
done)
# rules for building a TDS zip file
.PHONY: tds
tds: $(pkg).tds.zip
$(pkg).tds.zip: $(tfmfiles) $(pfbfiles) $(mapfile) $(encfiles) $(srcfiles) $(addprefix latex/,$(pkg).ins $(pkg).dtx $(pkg).sty $(pkg).pdf) FONTLOG.txt OFL.txt
$(MAKE) install TEXMFDIR:=tds.tmp
(cd tds.tmp && $(ZIP) -r - *) > $@
$(RM) tds.tmp
# rules for building a tarball for CTAN
.PHONY: ctan
ctan: $(pkg).tar.gz
$(pkg).tar.gz: $(pkg).tds.zip README.ctan $(tfmfiles) $(pfbfiles) $(mapfile) $(encfiles) $(srcfiles) $(addprefix latex/,$(pkg).ins $(pkg).dtx $(pkg).pdf) FONTLOG.txt OFL.txt
$(TAR) -cz -s '/README\.ctan/README/' -s '/latex.//' $^ > $@
# rules for building proofs and charts
.PHONY: test
test: proofs charts
.PHONY: proofs
proofs: $(prooffiles)
$(gffiles): $(testdir)/%.2602gf: source/%.mf
cd $(testdir) && MFINPUTS=$(abspath source) $(MF) '\mode=proofmofe; nodisplays; input $*'
$(prooffiles): $(testdir)/%.dvi: $(testdir)/%.2602gf
cd $(testdir) && $(GFTODVI) $*
.PHONY: charts
charts: $(chartfiles)
$(chartfiles): $(testdir)/%.pdf: $(fontdir)/%.pfb
$(T1TESTPAGE) $< | $(PSTOPDF) - $@
# rule for validating the generated Postscript fonts
.PHONY: check
check:
@echo "Validating fonts..."
@for file in $(pfbfiles); do \
if [ -e $$file ]; then \
$(FONTFORGE) -script scripts/validate.pe $$file 2> /dev/null; \
fi; \
done
# rules for (un)installing everything
.PHONY: install
install: all
$(INSTALLDIR) $(TEXMFDIR)/fonts/type1/public/$(pkg)
$(INSTALLDATA) $(pfbfiles) $(TEXMFDIR)/fonts/type1/public/$(pkg)
$(INSTALLDIR) $(TEXMFDIR)/fonts/opentype/public/$(pkg)
$(INSTALLDATA) $(otffiles) $(TEXMFDIR)/fonts/opentype/public/$(pkg)
$(INSTALLDIR) $(TEXMFDIR)/fonts/tfm/public/$(pkg)
$(INSTALLDATA) $(tfmfiles) $(TEXMFDIR)/fonts/tfm/public/$(pkg)
$(INSTALLDIR) $(TEXMFDIR)/fonts/source/public/$(pkg)
$(INSTALLDATA) $(srcfiles) $(TEXMFDIR)/fonts/source/public/$(pkg)
$(INSTALLDIR) $(TEXMFDIR)/fonts/map/enc/$(pkg)
$(INSTALLDATA) $(mapfile) $(TEXMFDIR)/fonts/map/enc/$(pkg)
$(INSTALLDIR) $(TEXMFDIR)/fonts/enc/enc/$(pkg)
$(INSTALLDATA) $(encfiles) $(TEXMFDIR)/fonts/enc/enc/$(pkg)
$(INSTALLDIR) $(TEXMFDIR)/tex/latex/$(pkg)
$(INSTALLDATA) latex/$(pkg).sty $(TEXMFDIR)/tex/latex/$(pkg)
$(INSTALLDIR) $(TEXMFDIR)/doc/fonts/$(pkg)
$(INSTALLDATA) FONTLOG.txt OFL.txt $(TEXMFDIR)/doc/fonts/$(pkg)
$(INSTALLDIR) $(TEXMFDIR)/doc/latex/$(pkg)
$(INSTALLDATA) latex/$(pkg).pdf $(TEXMFDIR)/doc/latex/$(pkg)
$(INSTALLDIR) $(TEXMFDIR)/source/latex/$(pkg)
$(INSTALLDATA) latex/$(pkg).ins latex/$(pkg).dtx $(TEXMFDIR)/source/latex/$(pkg)
.PHONY: uninstall
uninstall:
$(RM) $(TEXMFDIR)/fonts/type1/public/$(pkg)
$(RM) $(TEXMFDIR)/fonts/opentype/public/$(pkg)
$(RM) $(TEXMFDIR)/fonts/tfm/public/$(pkg)
$(RM) $(TEXMFDIR)/fonts/map/enc/$(pkg)
$(RM) $(TEXMFDIR)/fonts/enc/enc/$(pkg)
$(RM) $(TEXMFDIR)/tex/latex/$(pkg)
$(RM) $(TEXMFDIR)/doc/latex/$(pkg)
$(RM) $(TEXMFDIR)/doc/fonts/$(pkg)
$(RM) $(TEXMFDIR)/source/latex/$(pkg)
# rule for cleaning the source tree
.PHONY: clean
clean:
$(RM) $(outdirs)
$(RM) $(depfiles)
$(RM) mapfile latex/$(pkg).sty $(pkg).tds.zip $(pkg).tar.gz
$(RM) $(tempfiles)
# delete files on error
.DELETE_ON_ERROR: