-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
387 lines (336 loc) · 12.8 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# microtype makefile
SHELL = /bin/sh
.SUFFIXES:
# path
# (adapt to your needs)
ARCH := x86_64-darwinlegacy
COMPAT := $(shell which tlmgr | sed 's/.*\/\(.*\)\/bin\/.*/\1/')
ifeq ($(shell expr $(COMPAT) \< 2021 ),1)
ARCH := x86_64-darwin
endif
ifeq ($(shell expr $(COMPAT) \< 2014 ),1)
ARCH := universal-darwin
endif
TLPATH := ~/Library/texlive/$(COMPAT)/bin/$(ARCH)
ifdef DEV
override DEV=-dev
endif
TESTDIR = ./testsuite
WORDCOUNT = ~/texmf/scripts/wordcount/wordcount.sh
# Redefine to print output:
REDIRECT = > /dev/null
help:
@echo 'microtype makefile targets:'
@echo ' '
@echo ' help - (this message)'
@echo ' unpack - extract all files'
@echo ' doc - compile user and code documentation'
@echo ' userdoc - compile user documentation'
@echo ' ctan - generate archive for CTAN'
@echo ' all - unpack & doc'
@echo ' world - all & ctan'
@echo ' mostlyclean - remove all intermediary files'
@echo ' clean - remove all generated and built files'
@echo ' tag - edit tags (v=VERSION d=DATE, both optional)'
@echo ' manifest - print file list'
@echo ' '
@echo ' install - install the complete package into your home texmf tree'
@echo ' sty-install - install the package code only'
@echo ' install TEXMFROOT=<texmf> - install the package into the path <texmf>'
@echo ' '
@echo ' test - run the test suite'
@echo ' testerrors - ... or a'
@echo ' testunknown - ... part'
@echo ' testoutput - ... of it'
@echo ' test... COMPAT=<TeX Live> - test with other TeX Live release'
@echo ' test... DEV=1 - test with development version'
NAME = microtype
NAMEC = $(NAME)-code
NAMEU = $(NAME)-utf
DOC = $(NAME).pdf
CODEDOC = $(NAMEC).pdf
UTFDOC = $(NAMEU).pdf
INS = $(NAME).ins
DTX = $(NAME).dtx
UTFDTX = $(NAMEU).dtx
ALLDTX = $(DTX) $(UTFDTX)
README = README.md
DEPENDS = DEPENDS.txt
# Files grouped by generation mode
COMPILED = $(DOC) $(CODEDOC)
UNPACKED = microtype.sty letterspace.sty microtype.lua microtype.cfg \
microtype-pdftex.def microtype-luatex.def microtype-xetex.def \
mt-bch.cfg mt-blg.cfg mt-cmr.cfg mt-euf.cfg mt-eur.cfg mt-eus.cfg \
mt-msa.cfg mt-msb.cfg mt-EBGaramond.cfg mt-ppl.cfg mt-pmn.cfg mt-ptm.cfg \
mt-ugm.cfg mt-mvs.cfg mt-zpeu.cfg \
mt-CharisSIL.cfg mt-LatinModernRoman.cfg mt-NewComputerModern.cfg mt-Palatino.cfg \
mt-TU-basic.cfg mt-TU-empty.cfg \
microtype-show.sty test-microtype.tex
SOURCE = $(ALLDTX) $(INS) $(README) $(DEPENDS)
GENERATED = $(UNPACKED) $(COMPILED)
CTAN_FILES = $(SOURCE) $(COMPILED)
# Files grouped by installation location
UNPACKED_DOC = test-microtype.tex
RUNFILES = $(filter-out $(UNPACKED_DOC), $(UNPACKED))
DOCFILES = $(COMPILED) $(UNPACKED_DOC) $(README) $(DEPENDS)
SRCFILES = $(ALLDTX) $(INS)
ALL_FILES = $(RUNFILES) $(DOCFILES) $(SRCFILES)
# Installation locations
FORMAT = latex
RUNDIR = $(TEXMFROOT)/tex/$(FORMAT)/$(NAME)
DOCDIR = $(TEXMFROOT)/doc/$(FORMAT)/$(NAME)
SRCDIR = $(TEXMFROOT)/source/$(FORMAT)/$(NAME)
TEXMFROOT = $(shell kpsewhich --var-value TEXMFHOME)
CTAN_ZIP = $(NAME).zip
TDS_ZIP = $(NAME).tds.zip
ZIPS = $(CTAN_ZIP) $(TDS_ZIP)
DO_PDFLATEX_DOC = pdflatex$(DEV) --interaction=nonstopmode $(DTX) $(REDIRECT)
DO_PDFLATEX_CODE = pdflatex$(DEV) --jobname=$(NAMEC) --interaction=nonstopmode $(DTX) $(REDIRECT) || \
if ! grep -i '* Checksum passed *' $(NAMEC).log > /dev/null ; then \
if grep 'has no checksum\|Checksum not passed' $(NAMEC).log ; then \
false ; \
fi ; \
fi
DO_LUALATEX = lualatex$(DEV) --interaction=nonstopmode $(UTFDTX) $(REDIRECT)
DO_MAKEINDEX_DOC = \
makeindex -s microtype-gind.ist -t $(NAME).ilg -o $(NAME).ind $(NAME).idx $(REDIRECT) 2>&1 && \
echo "Creating user index"
DO_MAKEINDEX_CODE = \
makeindex -r -s microtype-gind.ist -t $(NAMEC).ilg -o $(NAMEC).ind \
$(NAME).idx $(NAMEC).idx $(NAMEU).idx $(NAME).cdx $(REDIRECT) 2>&1 && \
makeindex -s gglo.ist -t $(NAMEC).glg -o $(NAMEC).gls \
$(NAME).glo $(NAMEC).glo $(NAMEU).glo $(REDIRECT) 2>&1 && \
echo "Creating code index"
all: $(GENERATED)
doc: $(COMPILED)
userdoc: $(DOC)
unpack: $(UNPACKED)
ctan: $(CTAN_ZIP)
tds: $(TDS_ZIP)
world: all ctan
.PHONY: help install sty-install manifest mostlyclean clean \
test testerrors testunknown testoutput
# for the documentation we need the debug version of microtype.sty
# as well as microtype-doc.sty and microtype-gind.ist
make-doc-sty: $(INS) $(DTX) docstrip.cfg
@echo "Creating doc sty"
@sed -i '' '/\\def\\DEBUG/s/^%//' $<
@sed -i '' '/microtype-gind/s/^%//' $<
@sed -i '' '/microtype-doc/s/^%//' $<
@pdflatex --interaction=nonstopmode $< $(REDIRECT)
@touch make-doc-sty
@rm -f make-normal-sty
# undo
make-normal-sty: $(INS) $(DTX) docstrip.cfg
@echo "Creating normal sty"
@sed -i '' '/\\def\\DEBUG/s/^\\/%\\/' $<
@sed -i '' '/microtype-doc/s/^\\/%\\/' $<
@sed -i '' '/microtype-gind/s/^\\/%\\/' $<
@pdflatex --interaction=nonstopmode $< $(REDIRECT)
@touch make-normal-sty
@rm -f make-doc-sty
RERUN_STR = 'Rerun to get \|pdfTeX warning (dest)'
define rerun-check
@while `grep $(RERUN_STR) $(NAMEU).log > /dev/null` ; do \
echo "Re-compiling Unicode documentation" ; \
$(DO_LUALATEX) ; \
done
@while `grep $(RERUN_STR) $(NAMEC).log > /dev/null` ; do \
shasum $(NAME).glo $(NAMEC).glo $(NAMEU).glo $(NAME).idx $(NAMEC).idx $(NAMEU).idx $(NAME).cdx > $(NAMEC)-stamp2 ; \
if cmp -s $(NAMEC)-stamp2 $(NAMEC)-stamp; then rm $(NAMEC)-stamp2; \
else mv -f $(NAMEC)-stamp2 $(NAMEC)-stamp; $(DO_MAKEINDEX_CODE); fi ; \
echo "Re-compiling code documentation" ; \
$(DO_PDFLATEX_CODE) ; \
shasum $(NAME).idx > $(NAME)-stamp2 ; \
if cmp -s $(NAME)-stamp2 $(NAME)-stamp; then rm $(NAME)-stamp2; \
else mv -f $(NAME)-stamp2 $(NAME)-stamp; $(DO_MAKEINDEX_DOC); fi ; \
echo "Re-compiling user documentation" ; \
$(DO_PDFLATEX_DOC) ; \
done
@while `grep $(RERUN_STR) $(NAME).log > /dev/null` ; do \
shasum $(NAME).idx > $(NAME)-stamp2 ; \
if cmp -s $(NAME)-stamp2 $(NAME)-stamp; then rm $(NAME)-stamp2; \
else mv -f $(NAME)-stamp2 $(NAME)-stamp; $(DO_MAKEINDEX_DOC); fi ; \
echo "Re-compiling user documentation" ; \
$(DO_PDFLATEX_DOC) ; \
done
endef
$(DOC): make-doc-sty $(DTX) $(NAME).ind
@if `grep $(RERUN_STR) $(NAME).log > /dev/null` ; then \
echo "Re-compiling user documentation" ; \
$(DO_PDFLATEX_DOC) ; \
fi
$(CODEDOC): make-doc-sty $(DTX) $(UTFDOC) $(NAMEC).gls $(NAMEC).ind
@echo "Compiling code documentation (including Unicode part)"
@$(DO_PDFLATEX_CODE)
$(rerun-check)
$(UTFDOC): make-doc-sty $(UTFDTX) $(NAMEC).tmp
@echo "Compiling Unicode documentation"
@$(DO_LUALATEX)
@if `grep $(RERUN_STR) $(NAMEU).log > /dev/null` ; then \
echo "Re-compiling Unicode documentation" ; \
$(DO_LUALATEX) ; \
fi
$(NAME).idx: $(DTX)
@echo "Compiling user documentation (idx)"
@$(DO_PDFLATEX_DOC)
$(NAME).ind: $(NAME)-stamp
@$(DO_MAKEINDEX_DOC)
$(NAME)-stamp: $(NAME).idx
@shasum $^ > $@2
@if cmp -s $@2 $@; then rm $@2; else mv -f $@2 $@; fi
$(NAMEC).idx $(NAMEC).glo: $(DTX)
@echo "Compiling code documentation (idx,glo)"
@$(DO_PDFLATEX_CODE)
$(NAMEC).ind $(NAMEC).gls: $(NAMEC)-stamp
@$(DO_MAKEINDEX_CODE)
$(NAMEC)-stamp: $(NAME).glo $(NAMEC).glo $(NAMEU).glo $(NAME).idx $(NAMEC).idx $(NAMEU).idx $(NAME).cdx
@shasum $^ > $@2
@if cmp -s $@2 $@; then rm $@2; else mv -f $@2 $@; fi
# microtype-code.tmp is used to communicate counters
# from microtype.dtx (code) to microtype-utf.dtx
$(NAMEC).tmp:
@echo "Compiling code documentation (for Unicode part)"
@$(DO_PDFLATEX_CODE)
@if `grep $(RERUN_STR) $(NAMEC).log > /dev/null` ; then \
$(DO_MAKEINDEX_CODE) ; \
echo "Re-compiling code documentation (for Unicode part)" ; \
$(DO_PDFLATEX_CODE) ; \
fi
$(UNPACKED): $(INS) $(DTX) $(UTFDTX) docstrip.cfg
@echo "Extracting package"
@pdflatex $< $(REDIRECT)
@if test ! -f $@ ; then \
echo "!! $@ not created!" ; \
false ; \
fi
docstrip.cfg:
@echo "\\\\askforoverwritefalse" > docstrip.cfg
$(CTAN_ZIP): manifest doc $(CTAN_FILES) $(TDS_ZIP)
@echo "Making $@ for CTAN upload."
@$(RM) -- $@
@mkdir -p ./$(NAME)
@cp $(CTAN_FILES) ./$(NAME)
@zip -9 -r $@ ./$(NAME) $(TDS_ZIP) $(REDIRECT)
@$(RM) -r ./$(NAME)
@unzip -l $@
define run-install
@mkdir -p $(RUNDIR) && cp $(RUNFILES) $(RUNDIR)
@mkdir -p $(DOCDIR) && cp $(DOCFILES) $(DOCDIR)
@mkdir -p $(SRCDIR) && cp $(SRCFILES) $(SRCDIR)
endef
define run-sty-install
@mkdir -p $(RUNDIR) && cp $(RUNFILES) $(RUNDIR)
endef
$(TDS_ZIP): TEXMFROOT=./tmp-texmf
$(TDS_ZIP): make-normal-sty $(ALL_FILES)
@echo "Making TDS-ready archive $@."
@$(RM) -- $@
$(run-install)
@cd $(TEXMFROOT) && zip -9 ../$@ -r . $(REDIRECT)
@$(RM) -r -- $(TEXMFROOT)
install: doc $(ALL_FILES)
@if test ! -n "$(TEXMFROOT)" ; then \
echo "Cannot locate your home texmf tree. Specify manually with\n\n make install TEXMFROOT=/path/to/texmf\n" ; \
false ; \
fi ;
@echo "Installing in '$(TEXMFROOT)'."
$(run-install)
sty-install: $(RUNFILES)
@if test ! -n "$(TEXMFROOT)" ; then \
echo "Cannot locate your home texmf tree. Specify manually with\n\n make install TEXMFROOT=/path/to/texmf\n" ; \
false ; \
fi ;
@echo "Installing in '$(TEXMFROOT)'."
$(run-sty-install)
tag: $(ALLDTX) $(README)
@if test ! -n "$(v)" ; then \
v="$(shell LANG=C && \
sed -n '/%<\*package|letterspace|m-t|pdf-|lua-|xe-|show>$$/{N;s/.*\[.* v\(.*\)$$/\1/p;}' $(DTX))" ; \
echo "Version not set .. using current one ($$v)" ; \
fi ; \
if test ! -n "$(d)" ; then \
d="$(shell date '+%Y/%m/%d')" ; \
echo "Date not set .. using today ($$d)" ; \
fi ; \
echo "Tagging: $$v -- $$d" ; \
LANG=C && \
sed -i '' -e "/^%<\*package|letterspace|m-t|pdf-|lua-|xe-|show>$$/{N;s:\( *\[\).* .*$$:\1$$d v$$v:;}" \
-e "s:\(%<luafile> *version *= \)\".*\":\1\"$$v\":" \
-e "s:\(%<luafile> *date *= \)\".*\":\1\"$$d\":" $(DTX) && \
sed -i '' -e "/^%<\*driver>$$/{N;s:\[.* v.*\]$$:\[$$d v$$v\]:;}" $(UTFDTX) && \
sed -i '' -e "s:^ (v.* -- .*)$$: (v$$v -- $$d):" $(README) ;
manifest: $(SOURCE)
@echo "=== Source files ==="
@LANG=C && sed -n '/%<\*package|letterspace|m-t|pdf-|lua-|xe-|show>$$/{N;s/.*\[\(.*\)$$/-- \1 ($(DTX))/p;}' $(DTX)
@LANG=C && sed -n '/ *version *= *.*$$/{N;s/^.*= *"\(.*\)",.*date *= *"\(.*\)",/ (\2 v\1 (microtype.lua))/p;}' $(DTX)
@sed -n '/%<\*driver>$$/{N;/{\\jobname\.dtx}/ s/^.*\[\(.*\)\]$$/-- \1 ($(UTFDTX))/p;}' $(UTFDTX)
@sed -n 's/^ *(\(v[^ ]*\) *-- *\([^ ]*\))$$/-- \2 \1 ($(README))/p' $(README)
@echo ""
@echo "=== Derived files ==="
@for f in $(UNPACKED); do echo "$$f"; done
@echo "----------------------------"
@if grep '\-\-'`date -v-1y +%Y` $(SOURCE); then echo "!!!! Copyright strings not up to date !!!!" ; fi
mostlyclean:
@$(RM) -- *.log *.aux *.toc *.idx *.cdx *.ind *.ilg *.glo *.gls *.glg *.lof *.lot *.out *.synctex* *.tmp *.pl *.mtx \
docstrip.cfg $(UTFDOC) microtype-doc.sty microtype-gind.ist make-*-sty *-stamp
clean: mostlyclean
@$(RM) -- $(GENERATED) $(ZIPS)
# testing the package
test: testerrors testunknown testoutput
@$(RM) $(TESTDIR)/*.log
@$(RM) $(TESTDIR)/*.aux
@$(RM) $(TESTDIR)/*.pdf
@$(RM) $(TESTDIR)/*.tmp
@$(RM) $(TESTDIR)/*.out
@$(RM) $(TESTDIR)/*.4ct
@$(RM) $(TESTDIR)/*.4tc
@$(RM) $(TESTDIR)/*.dvi
@$(RM) $(TESTDIR)/*.xref
# @$(RM) $(TESTDIR)/*.1
# @$(RM) $(TESTDIR)/*.1R
@$(RM) $(TESTDIR)/*.pgf
@$(RM) $(TESTDIR)/*.toc
@$(RM) $(TESTDIR)/*.nav
@$(RM) $(TESTDIR)/*.snm
@$(RM) $(TESTDIR)/*.hd
@$(RM) $(TESTDIR)/*.bcf
@$(RM) $(TESTDIR)/*.run.xml
testerrors: $(wildcard $(TESTDIR)/error-*.tex)
@echo "* Errors:"
@cd $(TESTDIR) && \
$(foreach file,$^,$(call run-test-file,error,$(notdir $(basename $(file)))))
@echo " - wordcount"
@cd $(TESTDIR) && \
if ! `$(WORDCOUNT) errorx-wordcount > /dev/null` ; \
then $(not-ok) ; \
fi
testunknown: $(wildcard $(TESTDIR)/unknown-*.tex)
@echo "* Unknown slots:"
@cd $(TESTDIR) && \
$(foreach file,$^,$(call run-unknown-file,$(notdir $(basename $(file)))))
testoutput: $(wildcard $(TESTDIR)/output-*.tex)
@echo "* Output:"
@cd $(TESTDIR) && \
$(foreach file,$^,$(call run-output-file,$(notdir $(basename $(file)))))
# parts of the filename after `_' signify an engine other than pdflatex
run-test-file = \
echo " - $(subst $1-,,$2)" | sed 's/\(.*\)_\(.*\)/\1 (\2)/' ; \
if ! `$(if $(shell echo $2 | grep _),\
$(TLPATH)/$(shell echo $2 | sed -n 's/.*_\(.*\)/\1/p' | sed -e '/latex/s/$$/$(DEV)/'),\
$(TLPATH)/pdflatex$(DEV)) --interaction=batchmode $2 > /dev/null` ; \
then $(not-ok) ; \
fi ;
# there mustn't be unknown slots
run-unknown-file = \
$(call run-test-file,unknown,$1) \
if `grep 'Unknown slot number' $1.log > /dev/null` ; \
then $(not-ok) ; \
fi ;
# the test files themselves contain the relevant grep command
run-output-file = \
$(call run-test-file,output,$1) \
if ! $$(eval $$(grep grep $1.tex) $1.log > /dev/null) ; \
then $(not-ok) ; \
fi ;
not-ok = echo " ... NOT OK !!! <-------"