summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/synthslant/Makefile
blob: 8ef77a6982b5bf0a6d361176b0048ce004a9f204 (plain)
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
###  name:      	Makefile
###  synopsis:  	Build `synthslant' style file and documentation
###  author:    	Dr. Christoph L. Spiel
###  GNU make version:  4.3


SHELL := /bin/sh


BASE64 := base64
BASE64_FLAGS :=


DVIPDFMX := dvipdfmx
DVIPDFMX_FLAGS :=


DVIPS := dvips
DVIPS_FLAGS := -d1 # debug \special{}


LATEX_PROPER := pdflatex
LATEX := /usr/bin/env max_print_line=2147483647 $(LATEX_PROPER)
LATEX_FLAGS := -file-line-error -halt-on-error -interaction=nonstopmode -output-directory=.
LATEX_RERUN_TRIGGER := '^Package rerunfilecheck Warning: File [^ ]* has changed'
LATEX_WARNING := '^LaTeX (|[A-Za-z0-9_]* )Warning:'


MAKEINDEX := makeindex
MAKEINDEX_FLAGS := -q


METAPOST := mpost
METAPOST_FLAGS := -file-line-error -interaction=nonstopmode -tex=latex


PROJECT_NAME := synthslant
SOURCE_FILES := LICENSE Makefile README.md synthslant.dtx synthslant.ins
DOCUMENTATION_FILES := synthslant-gauge.pdf synthslant.pdf



.PHONY: all
all: sty pdf


.PHONY: sty
sty: synthslant.sty


.PHONY: pdf
pdf: doc gauge test


.PHONY: doc
doc: synthslant.pdf


.PHONY: gauge
gauge: synthslant-gauge.pdf


.PHONY: test
test: synthslant-minimal-test.pdf


export TEMPORARY_DIRECTORY


.PHONY: dist
dist:
	$(eval TEMPORARY_DIRECTORY := $(shell mktemp -d))
	trap '$(RM) -r $(TEMPORARY_DIRECTORY); exit 1' HUP INT QUIT TERM;  $(MAKE) __dist
	$(RM) -r $(TEMPORARY_DIRECTORY)


.PHONY: __dist
__dist: LATEX_FLAGS += -interaction=batchmode
__dist: $(DOCUMENTATION_FILES)
	test -d '$(TEMPORARY_DIRECTORY)'
	test -w '$(TEMPORARY_DIRECTORY)'
	mkdir $(TEMPORARY_DIRECTORY)/$(PROJECT_NAME)
	cp $(SOURCE_FILES) $(TEMPORARY_DIRECTORY)/$(PROJECT_NAME)
	mkdir $(TEMPORARY_DIRECTORY)/$(PROJECT_NAME)/docs
	cp $(DOCUMENTATION_FILES) $(TEMPORARY_DIRECTORY)/$(PROJECT_NAME)/docs
	tar czf $(PROJECT_NAME).tar.gz -C $(TEMPORARY_DIRECTORY) $(PROJECT_NAME)


.PHONY: distcheck
distcheck: LATEX_FLAGS += -interaction=batchmode
distcheck: dist
	$(eval TEMPORARY_DIRECTORY := $(shell mktemp -d))
	test -d '$(TEMPORARY_DIRECTORY)'
	test -w '$(TEMPORARY_DIRECTORY)'
	tar xzf $(PROJECT_NAME).tar.gz -C $(TEMPORARY_DIRECTORY)
	$(MAKE) --directory=$(TEMPORARY_DIRECTORY)/$(PROJECT_NAME) LATEX_FLAGS='$(LATEX_FLAGS)' all
	$(RM) -r $(TEMPORARY_DIRECTORY)
	@printf '\n\ndistcheck passed.\n'


.PHONY: clean
clean:
	$(RM) ./*.aux ./*.brf ./*.dvi ./*.glg ./*.glo ./*.gls
	$(RM) ./*.hd ./*.idx ./*.ilg ./*.ind ./*.loe ./*.lof ./*.log ./*.lot
	$(RM) ./*.mp ./*.mps ./*.mpx ./*.out ./*.pdf ./*.ps ./*.toc
	$(RM) mptextmp.* mpxerr.tex
	$(RM) README README.html RELEASE-HOWTO RELEASE-HOWTO.html
	$(RM) compare-with-the-gimp.eps compare-with-the-gimp.png
	$(RM) $(PROJECT_NAME).tar.gz


.PHONY: mostlyclean
mostlyclean: clean


.PHONY: maintainer-clean
maintainer-clean: mostlyclean
	$(RM) ./*.base64 ./*.gst ./*.ist ./*.mp ./*.sty ./*.tex


.PHONY: perf
perf: synthslant-gauge.tex synthslant.sty
	perf stat --repeat=10 -- $(LATEX) $(LATEX_FLAGS) -interaction=batchmode -draftmode $<


.PHONY: tool-check
tool-check:
	@printf '***  LATEX_PROPER = "%s"\n' '$(LATEX_PROPER)'
	$(LATEX_PROPER) --version
	@printf '\n\n***  BibTeX\n'
	bibtex --version
	@printf '\n\n***  MAKEINDEX = "%s"\n' '$(MAKEINDEX)'
	$(MAKEINDEX)  < /dev/null
	@printf '\n\n***  METAPOST = "%s"\n' '$(METAPOST)'
	$(METAPOST) --version
	@printf '\n***  BASE64 = "%s"\n' '$(BASE64)'
	$(BASE64) --version
	@printf '\n\ntool check passed.\n'


.PHONY: update-docs
update-docs: pdf
	cp -f synthslant.pdf synthslant-gauge.pdf docs


define HELP_SCREEN
Selected Phony Targets
----------------------
all:    Make everything there is to make.  This is the .DEFAULT_GOAL.

clean:  Remove some products.

dist:   Create a tar file of the project source files and the PDF
        documentation files.  The archive is in the form and has a
        name that CTAN prefers.

distcheck: Create a tar file of the project source files, unpack it in
        a different location and build all targets.

doc:    Build "synthslant.pdf" the Syntslant documentation.

gauge:  Build "synthslant-gauge.pdf" the Syntslant gauge and example
        file.

maintainer-clean: Remove every product file that can be rebuilt even
        if uncommon tools are necessary.

mostlyclean: Remove some more products than clean:.

pdf:    Build doc: and gauge:.

sty:    Only extract "synthslant.sty" from "synthslant.dtx".  This
        operation requires LaTeX (-> $(LATEX)) and nothing else.

test:   Run some tests.  Currently only compiles a minimal document
        to check whether "synthslant.sty" contains all the necessary
        \RequirePackage directives.

tool-check: Check whether some of the required tools to build the
        project are available.

update-docs: Copy the documentation files into the "docs"
        sub-directory.


Selected Implicit Rules
-----------------------
%: %.html
        Convert HTML to plain text.  Requires w3m(1).

%.dvi %.pdf: %.dtx
        Run LaTeX or pdfLaTeX (-> $(LATEX)) on dtx source until a
        fix-point is reached.

%.dvi %.pdf: %.tex
        Run LaTeX or pdfLaTeX (-> $(LATEX)) on tex file until a
        fix-point is reached.

%.html: %.md
        Convert markdown to HTML.  Requires markdown(1).

%.mx.pdf: %.dvi
        Convert dvi to pdf via dvipdfmx (-> $(DVIPDFMX)).

%.ps: %.dvi
        Convert dvi to ps via dvips (-> $(DVIPS)).


Some Explicit Rules
-------------------
README.html:
        Convert "README.md" to html.

README: Convert "README.html" to plain text.

endef

.PHONY: help
help:
	$(info $(HELP_SCREEN))



.PRECIOUS: %.mps



define MAKE_INDEX_AND_GLOSSARY
sed -e '/@/d'  < $*.idx  > ,$*.idx;  mv ,$*.idx $*.idx;  \
$(MAKEINDEX) $(MAKEINDEX_FLAGS) -s $*.ist -t $*.ilg -o $*.ind $*.idx;  \
$(MAKEINDEX) $(MAKEINDEX_FLAGS) -s $*.gst -t $*.glg -o $*.gls $*.glo
endef

define GREP_LATEX_WARNINGS
test -e $*.log  &&  grep -E $(LATEX_WARNING) $*.log  |  uniq
endef

%.dvi %.pdf: %.dtx
	$(RM) ./$*.aux ./$*.ind ./$*.idx ./$*.gls ./$*.glo ./$*.lof ./$*.lot ./$*.toc
	$(LATEX) $(LATEX_FLAGS) -draftmode $<
	$(MAKE_INDEX_AND_GLOSSARY)
	$(LATEX) $(LATEX_FLAGS) $<
	$(MAKE_INDEX_AND_GLOSSARY)
	while test -e $*.log  &&  grep -q $(LATEX_RERUN_TRIGGER) $*.log;  \
        do  \
	    $(LATEX) $(LATEX_FLAGS) $<;  \
	    $(MAKE_INDEX_AND_GLOSSARY);  \
	done
	$(GREP_LATEX_WARNINGS)


%.dvi: LATEX=latex


%.dvi %.pdf: %.tex
	$(RM) ./$*.aux ./$*.ind ./$*.idx ./$*.lof ./$*.lot ./$*.toc
	$(LATEX) $(LATEX_FLAGS) -draftmode $<
	$(LATEX) $(LATEX_FLAGS) $<
	while test -e $*.log  &&  grep -q $(LATEX_RERUN_TRIGGER) $*.log;  \
        do  \
	    $(LATEX) $(LATEX_FLAGS) $<;  \
	done
	$(GREP_LATEX_WARNINGS)


%.mx.pdf: %.dvi
	$(DVIPDFMX) $(DVIPDFMX_FLAGS) -o $@ $<


%.ps: %.dvi
	$(DVIPS) $(DVIPS_FLAGS) -o $@ $<


%.mps: %.mp
	$(METAPOST) -s 'outputtemplate="%j.mps"' $(METAPOST_FLAGS) $<  ||  {  \
            printf '===  $*.log  ===\n';  \
            cat $*.log;  \
            printf '\n\n===  mpxerr.log  ===\n';  \
            cat mpxerr.log;  \
            false;  \
        }  1>&2


%.eps: %.png
	convert $< -compress lzw eps2:$@


%.html: %.md
	markdown $<  > $@

%: %.html
	w3m -cols 79 $<  > $@



synthslant.sty synthslant.ist  \
synthslant-gauge.tex synthslant-minimal-test.tex  \
compare-with-the-gimp.png.base64 shear-transform.mp title.mp:  \
  synthslant.ins synthslant.dtx
	$(LATEX) $(LATEX_FLAGS) $<


synthslant.pdf:  \
    synthslant.dtx  \
    compare-with-the-gimp.png  \
    shear-transform.mps  \
    title.mps  \
    | synthslant.sty

synthslant.dvi:  \
    synthslant.dtx  \
    compare-with-the-gimp.eps  \
    shear-transform.mps  \
    title.mps


compare-with-the-gimp.png: compare-with-the-gimp.png.base64
	$(BASE64) $(BASE64_FLAGS) --decode $<  > $@


shear-transform.mps: shear-transform.mp


title.mps: title.mp


##  compare-with-the-gimp.png: compare-with-the-gimp.orig.png
##       convert $< -depth 8 -resize 50% -set colorspace Gray -separate -average $@
##
##  compare-with-the-gimp.png.base64: compare-with-the-gimp.png
##       $(BASE64) $(BASE64_FLAGS) $<  > $@