Debian Codegraph @

texmf-dist/source/latex/typog/Makefile

raw
1 ### name: Makefile
2 ### synopsis: Build `typog' style file, tools, and documentation
3 ### author: Dr. Christoph L. Spiel
4 ### GNU make version: 4.3
5
6
7 SHELL := /bin/sh
8
9
10 LATEX_PROPER := pdflatex
11 LATEX := /usr/bin/env max_print_line=2147483647 $(LATEX_PROPER)
12 LATEX_FLAGS := -file-line-error -halt-on-error -interaction=nonstopmode -output-directory=.
13 LATEX_RERUN_TRIGGER := '^Package rerunfilecheck Warning: File [^ ]* has changed'
14 LATEX_WARNING := '^LaTeX (|[A-Za-z0-9_]* )Warning:'
15
16 MAKEINDEX := makeindex
17 MAKEINDEX_FLAGS := -q
18
19
20 MAKEINFO := makeinfo
21 MAKEINFO_FLAGS := --no-split
22
23
24 METAPOST := mpost
25 METAPOST_FLAGS := -file-line-error -interaction=nonstopmode -tex=latex
26
27
28 PODCHECKER := podchecker
29 PODCHECKER_FLAGS := -warnings
30
31
32 define SED_VERSION_REGEXP
33 ^\( *\|\\ProvidesPackage{[^}]*} *\)\[\([0-9][0-9]*/[0-9][0-9]*/[0-9][0-9]*\) *v\([^ ]*\) *\([^]]*\)].*$$
34 endef
35
36 POD2MAN := pod2man
37 POD2MAN_FLAGS := $$(sed -ne 's,$(SED_VERSION_REGEXP),--date=\2 --release=\3,p' < typog.sty)
38
39
40 POD2TEXI := pod2texi
41 POD2TEXI_FLAGS :=
42
43
44 GROFF := groff
45 ## Codes of fonts that work for PDF output as by the contents
46 ## of "/usr/share/groff/current/font/devpdf".
47 ##
48 ## Serif
49 ## BM: URW Bookman L
50 ## N: URW Century Schoolbook L
51 ## P: URW Palladio L
52 ## T: URW Nimbus Roman No9 L
53 ##
54 ## Sans Serif
55 ## A: Avantgarde
56 ## H: Helvetica
57 ##
58 ## Monospace
59 ## C: Courier
60 GROFF_FLAGS := -Tpdf -dpaper=a4 -fP -man -wall
61
62
63 PROJECT_NAME := typog
64 SOURCE_FILES := LICENSE Makefile README.md typog.dtx typog.ins
65 DOCUMENTATION_FILES := typog-example.pdf typog-grep.1.pdf typog.pdf
66
67
68
69 .PHONY: all
70 all: sty pdf bin man
71
72
73 .PHONY: sty
74 sty: typog.sty
75
76
77 .PHONY: pdf
78 pdf: doc ex test
79
80
81 .PHONY: doc
82 doc: typog.pdf
83
84
85 .PHONY: ex
86 ex: typog-example.pdf
87
88
89 .PHONY: test
90 test: typog-minimal-test.pdf typog-without-microtype-test.pdf
91
92
93 .PHONY: bin
94 bin: typog-grep
95
96
97 .PHONY: man
98 man: typog-grep.1
99
100
101 export TEMPORARY_DIRECTORY
102
103
104 .PHONY: dist
105 dist:
106 $(eval TEMPORARY_DIRECTORY := $(shell mktemp -d))
107 trap '$(RM) -r $(TEMPORARY_DIRECTORY); exit 1' HUP INT QUIT TERM; $(MAKE) __dist
108 $(RM) -r $(TEMPORARY_DIRECTORY)
109
110
111 .PHONY: __dist
112 __dist: LATEX_FLAGS += -interaction=batchmode
113 __dist: $(DOCUMENTATION_FILES)
114 test -d '$(TEMPORARY_DIRECTORY)'
115 test -w '$(TEMPORARY_DIRECTORY)'
116 mkdir $(TEMPORARY_DIRECTORY)/$(PROJECT_NAME)
117 cp $(SOURCE_FILES) $(TEMPORARY_DIRECTORY)/$(PROJECT_NAME)
118 mkdir $(TEMPORARY_DIRECTORY)/$(PROJECT_NAME)/docs
119 cp $(DOCUMENTATION_FILES) $(TEMPORARY_DIRECTORY)/$(PROJECT_NAME)/docs
120 tar czf $(PROJECT_NAME).tar.gz -C $(TEMPORARY_DIRECTORY) $(PROJECT_NAME)
121
122
123 .PHONY: distcheck
124 distcheck: LATEX_FLAGS += -interaction=batchmode
125 distcheck: dist
126 $(eval TEMPORARY_DIRECTORY := $(shell mktemp -d))
127 test -d '$(TEMPORARY_DIRECTORY)'
128 test -w '$(TEMPORARY_DIRECTORY)'
129 tar xzf $(PROJECT_NAME).tar.gz -C $(TEMPORARY_DIRECTORY)
130 $(MAKE) --directory=$(TEMPORARY_DIRECTORY)/$(PROJECT_NAME) LATEX_FLAGS='$(LATEX_FLAGS)' all
131 $(RM) -r $(TEMPORARY_DIRECTORY)
132 @printf '\n\ndistcheck passed.\n'
133
134
135 .PHONY: clean
136 clean:
137 $(RM) ./*.1 ./*.aux ./*.brf ./*.dvi ./*.glg ./*.glo ./*.gls
138 $(RM) ./*.hd ./*.idx ./*.ilg ./*.ind ./*.info ./*.loe ./*.lof ./*.log ./*.lot
139 $(RM) ./*.mps ./*.mpx ./*.out ./*.pdf ./*.pl.in ./*.toc
140 $(RM) mptextmp.* mpxerr.tex
141 $(RM) README README.html RELEASE-HOWTO RELEASE-HOWTO.html
142 $(RM) typog-grep typog-grep.version.sed
143 $(RM) $(PROJECT_NAME).tar.gz
144
145
146 .PHONY: mostlyclean
147 mostlyclean: clean
148 $(RM) ./*.texi
149
150
151 .PHONY: maintainer-clean
152 maintainer-clean: mostlyclean
153 $(RM) ./*.gst ./*.ist ./*.mp ./*.pl ./*.pod ./*.sed ./*.sty ./*.tex
154
155
156 .PHONY: tool-check
157 tool-check:
158 @printf '*** LATEX_PROPER = "%s"\n' '$(LATEX_PROPER)'
159 $(LATEX_PROPER) --version
160 @printf '\n\n*** BibTeX\n'
161 bibtex --version
162 @printf '\n\n*** MAKEINDEX = "%s"\n' '$(MAKEINDEX)'
163 $(MAKEINDEX) < /dev/null
164 @printf '\n\n*** METAPOST = "%s"\n' '$(METAPOST)'
165 $(METAPOST) --version
166 @printf '\n*** POD2MAN = "%s"\n' '$(POD2MAN)'
167 $(POD2MAN) --help > /dev/null
168 @printf '\n\n*** POD2TEXI = "%s"\n' '$(POD2TEXI)'
169 $(POD2TEXI) --version
170 @printf '\n\ntool check passed.\n'
171
172
173 .PHONY: update-docs
174 update-docs: doc ex typog-grep.1.pdf
175 cp -f typog.pdf typog-example.pdf typog-grep.1 typog-grep.1.pdf docs
176
177
178 define HELP_SCREEN
179 Selected Phony Targets
180 ----------------------
181 all: Make everything there is to make. This is the .DEFAULT_GOAL.
182
183 bin: Build typog-grep (which is not a binary, but executable).
184
185 clean: Remove some products.
186
187 dist: Create a tar file of the project source files and the PDF
188 documentation files. The archive is in the form and has a
189 name that CTAN prefers.
190
191 distcheck: Create a tar file of the project source files, unpack it in
192 a different location and build all targets.
193
194 doc: Build "typog.pdf" the Typog documentation.
195
196 ex: Build "typog-example.pdf" an example and test file for Typog.
197
198 maintainer-clean: Remove every product file that can be rebuilt even
199 if uncommon tools are necessary.
200
201 mostlyclean: Remove some more products than clean:.
202
203 pdf: Build doc: and gauge:.
204
205 sty: Only extract "typog.sty" from "typog.dtx". This
206 operation requires LaTeX (-> $(LATEX)) and nothing else.
207
208 test: Run some tests.
209
210 tool-check: Check whether some of the required tools to build the
211 project are available.
212
213 update-docs: Copy the documentation files into the "docs"
214 sub-directory.
215
216
217 Selected Implicit Rules
218 -----------------------
219 %.pdf: %.dtx
220 Run LaTeX or pdfLaTeX (-> $(LATEX)) on dtx source until a
221 fix-point is reached.
222
223 %.pdf: %.tex
224 Run LaTeX or pdfLaTeX (-> $(LATEX)) on tex file until a
225 fix-point is reached.
226
227 %.1: %.pod
228 Create a manual page from plain old documentation format.
229 Requires podchecker (-> $(PODCHECKER)) and pod2man
230 (-> $(POD2MAN)).
231
232 %.1.pdf: %.1
233 Convert a manual page into a pdf file. Requires groff
234 (-> $(GROFF)).
235
236
237 Some Explicit Rules
238 -------------------
239 README.html:
240 Convert "README.md" to html. Requires markdown(1).
241
242 README: Convert "README.html" to plain text. Requires w3m(1).
243
244 endef
245
246
247 .PHONY: help
248 help:
249 $(info $(HELP_SCREEN))
250
251
252
253 .PRECIOUS: %.mps
254
255
256
257 define MAKE_INDEX_AND_GLOSSARY
258 sed -e '/@/d' -e 's/{\\ttfamily /{\\ttfamily\\hskip0pt\\relax /' < $*.idx > ,$*.idx; \
259 mv ,$*.idx $*.idx; \
260 $(MAKEINDEX) $(MAKEINDEX_FLAGS) -s $*.ist -t $*.ilg -o $*.ind $*.idx; \
261 $(MAKEINDEX) $(MAKEINDEX_FLAGS) -s $*.gst -t $*.glg -o $*.gls $*.glo
262 endef
263
264 define GREP_LATEX_WARNINGS
265 test -e $*.log && grep -E $(LATEX_WARNING) $*.log | uniq
266 endef
267
268 %.pdf: %.dtx
269 $(RM) ./$*.aux ./$*.ind ./$*.idx ./$*.gls ./$*.glo ./$*.lot ./$*.toc
270 $(LATEX) $(LATEX_FLAGS) -draftmode $<
271 $(MAKE_INDEX_AND_GLOSSARY)
272 $(LATEX) $(LATEX_FLAGS) $<
273 $(MAKE_INDEX_AND_GLOSSARY)
274 while test -e $*.log && grep -q $(LATEX_RERUN_TRIGGER) $*.log; \
275 do \
276 $(LATEX) $(LATEX_FLAGS) $<; \
277 $(MAKE_INDEX_AND_GLOSSARY); \
278 done
279 $(GREP_LATEX_WARNINGS)
280
281
282 %.pdf: %.tex
283 $(RM) ./$*.aux ./$*.ind ./$*.idx ./$*.lot ./$*.toc
284 $(LATEX) $(LATEX_FLAGS) -draftmode $<
285 $(LATEX) $(LATEX_FLAGS) $<
286 while test -e $*.log && grep -q $(LATEX_RERUN_TRIGGER) $*.log; \
287 do \
288 $(LATEX) $(LATEX_FLAGS) $<; \
289 done
290 $(GREP_LATEX_WARNINGS)
291
292
293 %-1.mps %-2.mps %-3.mps %-4.mps: %.mp
294 $(METAPOST) -s 'outputtemplate="%j-%c.mps"' $(METAPOST_FLAGS) $< || { \
295 printf '=== $*.log ===\n'; \
296 cat $*.log; \
297 printf '\n\n=== mpxerr.log ===\n'; \
298 cat mpxerr.log; \
299 false; \
300 } 1>&2
301
302
303 %.1: %.pod
304 $(PODCHECKER) $(PODCHECKER_FLAGS) $<
305 $(POD2MAN) $(POD2MAN_FLAGS) $< $@
306
307 %.1.pdf: %.1
308 $(GROFF) $(GROFF_FLAGS) ./$< > $@
309
310 %.texi: %.pod
311 $(POD2TEXI) $(POD2TEXI_FLAGS) --output=$@ ./$<
312
313 %.info: %.texi
314 $(MAKEINFO) $(MAKEINFO_FLAGS) --output=$@ $<
315
316 %.info.pdf: %.texi
317 $(MAKEINFO) $(MAKEINFO_FLAGS) --pdf --output=$@ $<
318
319 %.tex: %.pod | teximan2latex.sed
320 $(POD2TEXI) $(POD2TEXI_FLAGS) ./$< | sed -f teximan2latex.sed > $@
321
322
323 %.html: %.md
324 markdown $< > $@
325
326 %: %.html
327 w3m -cols 79 $< > $@
328
329
330 crooked-paragraphs.mp inverted-marks.mp slant-angle.mp smooth-parshapes.mp title.mp \
331 teximan2latex.sed \
332 typog-grep.pl.in typog-grep.pod \
333 typog.sty typog.ist typog-example.tex \
334 typog-minimal-test.tex typog-without-microtype-test.tex: \
335 typog.ins typog.dtx
336 $(LATEX) $(LATEX_FLAGS) $<
337
338
339 crooked-paragraphs-1.mps crooked-paragraphs-2.mps \
340 crooked-paragraphs-3.mps crooked-paragraphs-4.mps: crooked-paragraphs.mp
341
342 inverted-marks-1.mps: inverted-marks.mp
343
344 smooth-parshapes-1.mps smooth-parshapes-2.mps smooth-parshapes-3.mps: smooth-parshapes.mp
345
346 slant-angle-1.mps: slant-angle.mp
347
348 title-1.mps: title.mp
349
350 title-1.eps: title-1.mps
351 sed -e 's/ show/ true charpath stroke/' < $< > $@
352
353 typog.pdf: typog.dtx \
354 crooked-paragraphs-1.mps crooked-paragraphs-2.mps \
355 crooked-paragraphs-3.mps crooked-paragraphs-4.mps \
356 inverted-marks-1.mps slant-angle-1.mps title-1.eps \
357 smooth-parshapes-1.mps smooth-parshapes-2.mps smooth-parshapes-3.mps \
358 typog-grep.tex \
359 | typog.sty
360
361
362 typog-grep.pl: typog-grep.pl.in typog.sty
363 sed -ne 's,$(SED_VERSION_REGEXP),s#@DATE@#\2#g\ns#@RELEASE@#\3#g\ns#@TITLE@#\4#g,p' \
364 < typog.sty \
365 > typog-grep.version.sed
366 sed -f typog-grep.version.sed < $< > $@
367 chmod 755 $@
368
369 typog-grep: typog-grep.pl
370 ln -sf $< $@