-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
585 lines (371 loc) · 19.5 KB
/
Makefile
File metadata and controls
585 lines (371 loc) · 19.5 KB
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# Makefile
#
#
# Copyright: 2025 Marco de Beurs
# Copyright: 2022 - 2024 Octrooicentrum Nederland
# Licensed under the EUPL-1.2 or later.
#
# You may obtain a copy of the licence at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12.
#
# Author: Marco de Beurs
#
#
# Run "make" (or "make all")
#
# Run "make clean" to delete converted files
#
# set var Oud in make for old options for pandoc
# set var Web in make to make website
#
# the languages for the documents
LANGUAGES := en nl
# specific files
BibLaTeXfile := text/reader.bib
StyleSheet := default.css
# options for gladtex, the transformation of math to images for the epub
export GLADTEX_ARGS := -K -d epubimg --epub -P -
# the current directory
CURRENTDIR := $(shell pwd)
# defining the directories
TEXTDIR := text
DEPDIR := deps
MDDIR := mds
LISTDIR_dev := versions
LISTDIR_web := webversions
# select the normal dir versions or the special dir webversions for a website)
LISTDIR := $(if $(or $(filter websiteupdate,$(MAKECMDGOALS)), $(filter website,$(MAKECMDGOALS)), $(Web)), $(LISTDIR_web), $(LISTDIR_dev))
TARGETDIR := targets
LATEXDIR := latex
LIBLATEXDIR := $(LATEXDIR)/libs
MEDIADIR := media
TARGETMEDIA:= $(TARGETDIR)/$(MEDIADIR)
CSSDIR := css
TARGETCSS := $(TARGETDIR)/$(CSSDIR)
PICTDIR := pictures
LIBPICTDIR := $(PICTDIR)/libs
JSDIR := scripts
TARGETJS := $(TARGETDIR)/$(JSDIR)
EPUBPDFDIR := epubimg
SCSSDIR := scss
WEBINDEXDIR := web
WEBTEXTDIR := webtext
WEBFONTSDIR := webfonts
TARGETFONTS := $(TARGETDIR)/$(WEBFONTSDIR)
# the files in the LISTDIR with type .gen or .list are the source files for generating the targets
GEN_DOCS := $(basename $(notdir $(wildcard $(LISTDIR)/*.gen)))
SOURCE_DOCS := $(sort $(basename $(notdir $(wildcard $(LISTDIR)/*.list))) $(GEN_DOCS))
MD_DOCS := $(foreach LANG, $(LANGUAGES),\
$(foreach FILE, $(SOURCE_DOCS), $(FILE)_$(LANG).md))
# the target file types
EXPORTED_DOCS :=\
$(MD_DOCS:.md=.html) \
$(MD_DOCS:.md=.pdf) \
$(MD_DOCS:.md=.epub)
# the readme documents
README_DOCS := $(notdir $(wildcard readme*.md))
README_TARGETS :=\
$(README_DOCS:.md=.pdf) \
$(README_DOCS:.md=.txt)
# libs for latex
LIBSLATEX_DOCS := $(wildcard $(LIBLATEXDIR)/*.tex)
# defining intermediary files
IN_VERSIONS := epub html latex
MD_VERSIONS := $(foreach VER, $(IN_VERSIONS),\
$(foreach LANG, $(LANGUAGES),\
$(foreach FILE, $(SOURCE_DOCS), $(FILE)_$(LANG)_$(VER).md)))
FIGNUM_DOCS := $(foreach LANG, $(LANGUAGES),\
$(foreach FILE, $(SOURCE_DOCS), $(MDDIR)/$(FILE)_$(LANG)_fignum.md))
WEBINDEXDOCS := $(foreach FILE, $(SOURCE_DOCS), $(WEBINDEXDIR)/$(FILE)_index.md)
# some fun to include the index files from the versions when the websiteindex, websiteupdate or website target is selected or variable Web is set, otherwise only the files in the dir are used.
WEBIND_DOCS := $(sort $(wildcard $(WEBINDEXDIR)/*_index.md) $(if $(or $(filter websiteupdate,$(MAKECMDGOALS)), $(filter websiteindex,$(MAKECMDGOALS)), $(filter website,$(MAKECMDGOALS)), $(Web)), $(WEBINDEXDOCS)))
LATEX_TEMP_DOCS:= $(foreach LANG, $(LANGUAGES),\
$(foreach FILE, $(SOURCE_DOCS), $(LATEXDIR)/$(FILE)_$(LANG).tex))
# dependencies
HTMLDEPFILES := $(foreach LANG, $(LANGUAGES),\
$(foreach FILE, $(SOURCE_DOCS), $(DEPDIR)/$(FILE)_$(LANG)_html.d))
DEPFILES := $(SOURCE_DOCS:%=$(DEPDIR)/%.d)
# for css
SCSS_DOCS := $(notdir $(filter-out $(SCSSDIR)/_%.scss ,$(wildcard $(SCSSDIR)/*.scss)))
CSS_DOCS := $(SCSS_DOCS:.scss=.css)
SCSS_DEPS := $(wildcard $(SCSSDIR)/_*.scss)
# for dependencies of .gen files (this is actually too general, should be made more specific)
TPLFILES := $(wildcard $(LISTDIR)/*.tpl)
#$(info $(GEN_DOCS))
#$(info $(SOURCE_DOCS))
#$(info $(MD_DOCS))
#$(info $(EXPORTED_DOCS))
#$(info $(DEPFILES))
#$(info $(TARGETMEDIA))
#$(info $(TARGETDIR))
#$(info $(MD_VERSIONS))
#$(info $(TARGETDIR))
#$(info $(HTMLCLEAN))
#$(info $(SCSS_DOCS))
#$(info $(CSS_DOCS))
#$(info $(SCSS_DEPS))
$(info $(README_TARGETS))
#$(info $(CURRENTDIR))
$(info $(LISTDIR))
#$(info $(PLAN_DOCS))
#$(info $(MAKEFLAGS))
# for generating info
null :=
space := $(null) #
comma := ,
Info_MDDOCS := $(sort $(wildcard $(TEXTDIR)/*.md))
Info_LISTDOCS := $(sort $(wildcard $(LISTDIR)/*.list))
Info_TPLDOCS := $(sort $(wildcard $(LISTDIR)/*.tpl))
# the programs
RM=rm
PANDOC=pandoc
SASS=sassc
LATEX=latexmk -lualatex -r latexmkrc
# options for the programs
CITEPROC := $(if $(or $(filter oud,$(MAKECMDGOALS)), $(filter websiteupdateoud,$(MAKECMDGOALS)), $(filter websiteoud,$(MAKECMDGOALS)), $(Oud)),--filter pandoc-citeproc,--citeproc)
TODOOPTION := $(if $(filter todo,$(MAKECMDGOALS)),-DPrintToDo=yes, "")
PANDOC_OPTIONS=-f markdown
README_OPTIONS=-s -N --toc
PANDOC_HTML_OPTIONS= -s --toc -t html5 $(CITEPROC) --reference-location=document -M link-citations=true -M link-bibliography=true --number-sections --bibliography=$(BibLaTeXfile) -c $(CSSDIR)/$(StyleSheet) -H $(WEBTEXTDIR)/headerinclude.html --template=htmltemplate --mathml
PANDOC_HTML_DEPS= htmltemplate.html5 $(WEBTEXTDIR)/headerinclude.html
PANDOC_PDF_OPTIONS= -s -N --toc -t pdf
PANDOC_DOCX_OPTIONS=
PANDOC_RTF_OPTIONS=
PANDOC_ODT_OPTIONS=
PANDOC_EPUB_OPTIONS=-s --toc -t epub3 $(CITEPROC) -M link-citations -M link-bibliography --number-sections --bibliography=$(BibLaTeXfile) --filter gladtex --verbose
PANDOC_LATEX_OPTIONS=-t latex --wrap none --top-level-division=chapter --bibliography=$(BibLaTeXfile) --biblatex
PANDOC_TXT_OPTIONS=-t plain
# Targets and dependencies
.PHONY: all clean
.SECONDARY: $(MDDOCS) $(MD_VERSIONS) $(LATEX_TEMP_DOCS)
all : $(addprefix $(TARGETDIR)/,$(EXPORTED_DOCS)) $(README_TARGETS) todo.pdf style | $(TARGETMEDIA) $(TARGETCSS) $(TARGETJS) $(TARGETFONTS)
clean :
- $(RM) $(addprefix $(TARGETDIR)/,$(EXPORTED_DOCS))
- $(RM) $(addprefix $(MDDIR)/,$(MD_DOCS))
- $(RM) $(addprefix $(MDDIR)/,$(MD_VERSIONS))
- $(RM) $(LATEX_TEMP_DOCS)
- $(RM) $(DEPFILES)
- $(RM) $(HTMLDEPFILES)
- $(RM) $(wildcard $(HTMLCLEAN))
info : info.pdf
oud : all
todo: all
style : $(addprefix $(CSSDIR)/,$(CSS_DOCS)) | $(CSSDIR) $(TARGETFONTS)
webindex : $(WEBINDEXDOCS) websiteindex
websiteindex : $(TARGETDIR)/index.html $(TARGETDIR)/index_en.html
# website update with all deps rebuild if neccessary.
website: all websiteindex | $(TARGETMEDIA) $(TARGETCSS) $(TARGETJS) $(TARGETFONTS)
# this is a target to update a website and to make an index file, with deps on the targets but not to update targets. See the WEBDEPS_rule and WEBDEP_rule rules.
websiteupdate : websiteindex style | $(TARGETMEDIA) $(TARGETCSS) $(TARGETJS) $(TARGETFONTS)
websiteupdateoud : websiteupdate
websiteoud : website
# directories to be created
$(DEPDIR): ; mkdir -p $@
$(MDDIR): ; mkdir -p $@
$(TARGETDIR): ; mkdir -p $@
$(MEDIADIR): ; mkdir -p $@
$(LATEXDIR): ; mkdir -p $@
$(PICTDIR): ; mkdir -p $@
$(CSSDIR): ; mkdir -p $@
$(JSDIR): ; mkdir -p $@
$(WEBFONTSDIR): ; mkdir -p $@
$(WEBINDEXDIR): ; mkdir -p $@
$(LIBLATEXDIR): | $(LATEXDIR) ; mkdir -p $@
$(TARGETMEDIA): | $(MEDIADIR) $(TARGETDIR); ln -s -t $(TARGETDIR) $(CURRENTDIR)/$(MEDIADIR)
$(TARGETCSS): | $(CSSDIR) $(TARGETDIR); ln -s -t $(TARGETDIR) $(CURRENTDIR)/$(CSSDIR)
$(TARGETFONTS): | $(WEBFONTSDIR) $(TARGETDIR); ln -s -t $(TARGETDIR) $(CURRENTDIR)/$(WEBFONTSDIR)
$(LIBPICTDIR): | $(PICTDIR) $(LIBLATEXDIR) ; ln -s -t $(PICTDIR) $(CURRENTDIR)/$(LIBLATEXDIR)
$(TARGETJS): | $(JSDIR) $(TARGETDIR); ln -s -t $(TARGETDIR) $(CURRENTDIR)/$(JSDIR)
$(EPUBPDFDIR): ; mkdir -p $@
# rules
define MD_rule
$(MDDIR)/$(1)_$(2).md : $(LISTDIR)/$(1).list $(DEPDIR)/$(1).d preincl.m4 | $(MDDIR)
m4 -EE -P -DDefLang=$(2) -DDefFileName=$(1)_$(2) $(TODOOPTION) preincl.m4 $(LISTDIR)/$(1).list | sed -l 0 -f countchapter.sed - > $(MDDIR)/$(1)_$(2).md
$(MDDIR)/$(1)_$(2)_1.md : $(MDDIR)/$(1)_$(2).md $(MDDIR)/$(1)_$(2)_1.gls $(TEXTDIR)/glossary.md prein1.m4 | $(MDDIR)
m4 -EE -P -DGlossaryFile=$(MDDIR)/$(1)_$(2)_1.gls prein1.m4 $(TEXTDIR)/glossary.md $(MDDIR)/$(1)_$(2).md > $(MDDIR)/$(1)_$(2)_1.md
$(MDDIR)/$(1)_$(2)_colofon.md : $(MDDIR)/$(1)_$(2).md colofondata.m4 translations.m4 | $(MDDIR)
m4 -EE -P -DDefLang=$(2) -DDefFileName=$(MDDIR)/$(1)_$(2).md colofondata.m4 > $(MDDIR)/$(1)_$(2)_colofon.md
$(MDDIR)/$(1)_$(2)_cites.md : $(MDDIR)/$(1)_$(2).md nocites.m4 | $(MDDIR)
sed -l 0 -n -f getcites.sed $(MDDIR)/$(1)_$(2).md | m4 -EE -P nocites.m4 - > $(MDDIR)/$(1)_$(2)_cites.md
endef
define MDGLOSS_rule
$(MDDIR)/$(1)_$(2)_1.glo : $(MDDIR)/$(1)_$(2).md $(MDDIR)/glossary_nogls.md glosmd.m4 | $(MDDIR)
m4 -EE -P -DDefLang=$(2) glosmd.m4 $(MDDIR)/glossary_nogls.md $(MDDIR)/$(1)_$(2).md > $(MDDIR)/$(1)_$(2)_1.glo
$(MDDIR)/$(1)_$(2).glo : $(MDDIR)/$(1)_$(2)_1.md $(MDDIR)/glossary_nogls.md glosmd.m4 | $(MDDIR)
m4 -EE -P -DDefLang=$(2) glosmd.m4 $(MDDIR)/glossary_nogls.md $(MDDIR)/$(1)_$(2)_1.md > $(MDDIR)/$(1)_$(2).glo
endef
define GLOGLOSS_rule
$(MDDIR)/$(1)_$(2)_1.gls : $(MDDIR)/$(1)_$(2)_1.glo gloss_$(2).ist | $(MDDIR)
makeindex -s gloss_$(2).ist -t $(MDDIR)/$(1)_$(2)_1.glg -o $(MDDIR)/$(1)_$(2)_1.gls $(MDDIR)/$(1)_$(2)_1.glo
$(MDDIR)/$(1)_$(2).gls : $(MDDIR)/$(1)_$(2).glo gloss_$(2).ist | $(MDDIR)
makeindex -s gloss_$(2).ist -t $(MDDIR)/$(1)_$(2).glg -o $(MDDIR)/$(1)_$(2).gls $(MDDIR)/$(1)_$(2).glo
endef
define MDFIG_rule
$(MDDIR)/$(1)_$(2)_fignum.md : $(MDDIR)/$(1)_$(2)_1.md $(MDDIR)/glossary_nogls.md figuremd.m4 | $(MDDIR)
m4 -EE -P -DHtmlFileName=$(1)_$(2).html -DNameTarget=$(1)_$(2) figuremd.m4 $(MDDIR)/glossary_nogls.md $(MDDIR)/$(1)_$(2)_1.md > $(MDDIR)/$(1)_$(2)_fignum.md
endef
define MD_IN_rule
$(MDDIR)/$(1)_$(2)_$(3).md : $(MDDIR)/$(1)_$(2).md $(MDDIR)/$(1)_$(2).gls $(TEXTDIR)/glossary.md $(MDDIR)/$(1)_$(2)_fignum.md $(MDDIR)/$(1)_$(2)_colofon.md $(MDDIR)/$(1)_$(2)_cites.md prein$(3).m4 glos$(3).m4 links.m4 preincommon.m4 novid.m4 linksepub.m4 figureepub.m4 vid.m4 linkshtml.m4 figurehtml.m4 | $(MDDIR)
m4 -EE -P -DDefLang=$(2) -DGlossaryFile=$(MDDIR)/$(1)_$(2).gls -DGlossaryIncl=$(TEXTDIR)/glossary.md -DEpubPdfDir=$(EPUBPDFDIR) -DColofonFile=$(MDDIR)/$(1)_$(2)_colofon.md -DNoCitesFile=$(MDDIR)/$(1)_$(2)_cites.md prein$(3).m4 $(MDDIR)/$(1)_$(2)_fignum.md $(MDDIR)/$(1)_$(2).md > $(MDDIR)/$(1)_$(2)_$(3).md
endef
define LATEX_CAT_rule
$(LATEXDIR)/$(1)_$(2).tex : $(LATEXDIR)/$(1)_$(2)_mid.tex $(LATEXDIR)/begin_$(2).tex $(LATEXDIR)/end.tex | $(LATEXDIR)
cat $(LATEXDIR)/begin$(3)_$(2).tex $(LATEXDIR)/$(1)_$(2)_mid.tex $(LATEXDIR)/end.tex > $(LATEXDIR)/$(1)_$(2).tex
endef
define HTML_IN_rule
$(MDDIR)/$(1)_$(2)_in_html.md : $(MDDIR)/$(1)_$(2)_html.md $(DEPDIR)/$(1)_$(2)_pict.d firsthtml.m4 | $(MDDIR)
m4 -EE -P firsthtml.m4 $(MDDIR)/$(1)_$(2)_html.md > $(MDDIR)/$(1)_$(2)_in_html.md
$(MDDIR)/$(1)_$(2)_navbar.html : $(MDDIR)/$(1)_$(2)_fignum.md navbar.m4 navbar1.m4 $(PANDOC_HTML_DEPS) | $(MDDIR)
m4 -EE -P -DDefLang=$(2) -DFileName=$(1) -DSplitFile=first navbar.m4 $(MDDIR)/$(1)_$(2)_fignum.md navbar1.m4 $(MDDIR)/$(1)_$(2)_fignum.md > $(MDDIR)/$(1)_$(2)_navbar.html
$(TARGETDIR)/$(1)_$(2).html : $(MDDIR)/$(1)_$(2)_in_html.md $(DEPDIR)/$(1)_$(2)_html.d $(DEPDIR)/$(1)_$(2)_pict.d $(TARGETDIR)/$(1)_$(2)_index.html $(MDDIR)/$(1)_$(2)_navbar.html $(PANDOC_HTML_DEPS) | $(TARGETDIR) $(TARGETJS)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_HTML_OPTIONS) -M lang=$(2) -B $(MDDIR)/$(1)_$(2)_navbar.html -o $(TARGETDIR)/$(1)_$(2).html $(MDDIR)/$(1)_$(2)_in_html.md
$(DEPDIR)/$(1)_$(2)_html.d : $(MDDIR)/$(1)_$(2)_html.md htmldep.m4 | $(DEPDIR)
m4 -EE -P -DNameTarget=$(MDDIR)/$(1)_$(2) -DDefLang=$(2) -DFileName=$(1) htmldep.m4 $(MDDIR)/$(1)_$(2)_html.md > $(DEPDIR)/$(1)_$(2)_html.d
include $(DEPDIR)/$(1)_$(2)_html.d
endef
define HTML_INDEX_rule
$(MDDIR)/$(1)_$(2)_index.md : $(MDDIR)/$(1)_$(2)_fignum.md $(MDDIR)/$(1)_$(2).md $(MDDIR)/$(1)_$(2)_colofon.md htmlindex.m4 htmlindex1.m4 | $(MDDIR)
m4 -EE -P -DDefLang=$(2) -DFileName=$(1) -DColofonFile=$(MDDIR)/$(1)_$(2)_colofon.md htmlindex.m4 $(MDDIR)/$(1)_$(2)_fignum.md $(MDDIR)/$(1)_$(2).md htmlindex1.m4 > $(MDDIR)/$(1)_$(2)_index.md
$(MDDIR)/$(1)_$(2)_index_html.md : $(MDDIR)/$(1)_$(2)_index.md $(MDDIR)/$(1)_$(2)_fignum.md preinhtml.m4 firsthtml.m4 | $(MDDIR)
m4 -EE -P -DDefLang=$(2) -DGlossaryIncl=$(TEXTDIR)/glossary.md preinhtml.m4 $(MDDIR)/$(1)_$(2)_fignum.md $(MDDIR)/$(1)_$(2)_index.md | m4 -EE -P firsthtml.m4 - > $(MDDIR)/$(1)_$(2)_index_html.md
$(MDDIR)/$(1)_$(2)_index_navbar.html : $(MDDIR)/$(1)_$(2)_fignum.md navbar.m4 navbar1.m4 | $(MDDIR)
m4 -EE -P -DDefLang=$(2) -DFileName=$(1) -DSplitFile=index navbar.m4 $(MDDIR)/$(1)_$(2)_fignum.md navbar1.m4 $(MDDIR)/$(1)_$(2)_fignum.md > $(MDDIR)/$(1)_$(2)_index_navbar.html
$(TARGETDIR)/$(1)_$(2)_index.html : $(MDDIR)/$(1)_$(2)_index_html.md $(MDDIR)/$(1)_$(2)_index_navbar.html $(PANDOC_HTML_DEPS) | $(TARGETDIR)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_HTML_OPTIONS) -M lang=$(2) -B $(MDDIR)/$(1)_$(2)_index_navbar.html -o $(TARGETDIR)/$(1)_$(2)_index.html $(MDDIR)/$(1)_$(2)_index_html.md
endef
define PICTURE_rule
$(DEPDIR)/$(1)_$(2)_pict.d : $(MDDIR)/$(1)_$(2).md pictdep.m4 | $(DEPDIR)
m4 -EE -P -DDefLang=$(2) -DDepTarget=$(DEPDIR)/$(1)_$(2)_pict.d -DNameTarget=$(TARGETDIR)/$(1)_$(2) -DPdfTarget=$(LATEXDIR)/$(1)_$(2) pictdep.m4 $(MDDIR)/$(1)_$(2).md > $(DEPDIR)/$(1)_$(2)_pict.d
include $(DEPDIR)/$(1)_$(2)_pict.d
endef
define PICTUREstart_rule
$(PICTDIR)/$(1)_$(2).tex : $(PICTDIR)/beginsvg.tex $(PICTDIR)/begin_$(2).tex $(PICTDIR)/$(1).tex $(PICTDIR)/end.tex | $(PICTDIR)
cat $(PICTDIR)/beginsvg.tex $(PICTDIR)/begin_$(2).tex $(PICTDIR)/$(1).tex $(PICTDIR)/end.tex > $(PICTDIR)/$(1)_$(2).tex
$(PICTDIR)/$(1)_$(2)_preview.tex : $(PICTDIR)/beginpreview.tex $(PICTDIR)/begin_$(2).tex $(PICTDIR)/$(1).tex $(PICTDIR)/end.tex | $(PICTDIR)
cat $(PICTDIR)/beginpreview.tex $(PICTDIR)/begin_$(2).tex $(PICTDIR)/$(1).tex $(PICTDIR)/end.tex > $(PICTDIR)/$(1)_$(2)_preview.tex
endef
define LISTDEP_rule
$(DEPDIR)/$(1)_list.d : $(LISTDIR)/$(1).gen prelistdep.m4 | $(DEPDIR)
m4 -EE -P -DNameTarget=$(DEPDIR)/$(1)_list.d gen1.m4 $(LISTDIR)/$(1).gen prelistdep.m4 > $(DEPDIR)/$(1)_list.d
include $(DEPDIR)/$(1)_list.d
endef
define WEBDEP_rule
ifeq (,$(wildcard $(TARGETDIR)/$(1).html))
websiteupdate: $(TARGETDIR)/$(1).html
endif
endef
define WEBDEPS_rule
ifeq (,$(wildcard $(TARGETDIR)/$(1)_$(2).html))
websiteupdate: $(TARGETDIR)/$(1)_$(2).html
endif
ifeq (,$(wildcard $(TARGETDIR)/$(1)_$(2).pdf))
websiteupdate: $(TARGETDIR)/$(1)_$(2).pdf
endif
ifeq (,$(wildcard $(TARGETDIR)/$(1)_$(2).epub))
websiteupdate: $(TARGETDIR)/$(1)_$(2).epub
endif
endef
define WEBDEPADD_rule
websiteupdate: $(TARGETDIR)/$(1).html
endef
define WEBDEPSADD_rule
websiteupdate: $(TARGETDIR)/$(1)_$(2).html
websiteupdate: $(TARGETDIR)/$(1)_$(2).pdf
websiteupdate: $(TARGETDIR)/$(1)_$(2).epub
endef
# Pattern-matching Rules
$(foreach LANG, $(LANGUAGES),\
$(foreach FILE, $(SOURCE_DOCS),\
$(eval $(call MD_rule,$(FILE),$(LANG)))\
$(eval $(call MDGLOSS_rule,$(FILE),$(LANG)))\
$(eval $(call GLOGLOSS_rule,$(FILE),$(LANG)))\
$(eval $(call HTML_IN_rule,$(FILE),$(LANG)))\
$(eval $(call HTML_INDEX_rule,$(FILE),$(LANG)))\
$(eval $(call PICTURE_rule,$(FILE),$(LANG)))\
$(eval $(call WEBDEPS_rule,$(FILE),$(LANG)))\
$(eval $(call MDFIG_rule,$(FILE),$(LANG)))))
# $(eval $(call LATEX_CAT_rule,$(FILE),$(LANG)))\
#$(info $(PICT_DOCS))
$(foreach LANG, $(LANGUAGES),\
$(foreach FILE, $(sort $(PICT_DOCS)),\
$(eval $(call PICTUREstart_rule,$(FILE),$(LANG)))))
$(foreach LANG, $(LANGUAGES),\
$(foreach VER, $(IN_VERSIONS),\
$(foreach FILE, $(SOURCE_DOCS),\
$(eval $(call MD_IN_rule,$(FILE),$(LANG),$(VER))))))
$(foreach FILE, $(sort $(GEN_DOCS)),\
$(eval $(call LISTDEP_rule,$(FILE))))
# generate list files
$(LISTDIR)/%.list : $(LISTDIR)/%.gen $(DEPDIR)/%_list.d gen1.m4 gen2.m4
m4 -EE -P -DNameTarget=$* gen1.m4 $< gen2.m4 > $@
# for one index file for website
# info of targets
$(WEBINDEXDIR)/%_index.md : $(LISTDIR)/%.list genindex.m4 | $(WEBINDEXDIR)
m4 -EE -P genindex.m4 $< > $@
# final index
$(WEBINDEXDIR)/index.md : $(WEBIND_DOCS) $(TEXTDIR)/index_intro.md genindex2.m4 | $(WEBINDEXDIR)
m4 -EE -P genindex2.m4 $(TEXTDIR)/index_intro.md $(WEBIND_DOCS) > $@
$(WEBINDEXDIR)/index_nl.md : $(WEBINDEXDIR)/index.md genindex3.m4 | $(WEBINDEXDIR)
m4 -EE -P -DDefLang=nl genindex3.m4 $< > $@
$(WEBINDEXDIR)/index_en.md : $(WEBINDEXDIR)/index.md genindex3.m4 | $(WEBINDEXDIR)
m4 -EE -P -DDefLang=en genindex3.m4 $< > $@
$(TARGETDIR)/index.html : $(WEBINDEXDIR)/index_nl.md $(WEBTEXTDIR)/index_nl_navbar.html $(PANDOC_HTML_DEPS) | $(TARGETDIR) $(TARGETCSS)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_HTML_OPTIONS) -M lang=nl -B $(WEBTEXTDIR)/index_nl_navbar.html -o $@ $<
$(TARGETDIR)/index_en.html : $(WEBINDEXDIR)/index_en.md $(WEBTEXTDIR)/index_en_navbar.html $(PANDOC_HTML_DEPS) | $(TARGETDIR) $(TARGETCSS)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_HTML_OPTIONS) -M lang=en -B $(WEBTEXTDIR)/index_en_navbar.html -o $@ $<
# pictures to be build
$(MEDIADIR)/%.svg : $(PICTDIR)/%.xdv
dvisvgm --bbox=min --no-fonts=1 --output=$@ $<
$(PICTDIR)/%.xdv : $(PICTDIR)/%.tex $(PICTDIR)/settings.tex | $(LIBPICTDIR)
xelatex -no-pdf -output-directory=$(PICTDIR) $<
$(PICTDIR)/%.pdf : $(PICTDIR)/%.tex $(PICTDIR)/settings.tex | $(LIBPICTDIR)
xelatex -output-directory=$(PICTDIR) $<
# dependencies to be build
$(DEPDIR)/%.d : $(LISTDIR)/%.list predep.m4 predep1.m4 | $(DEPDIR)
m4 -EE -P -DNameTarget=$@ -DFileName=$* -DGlossaryFile=$(TEXTDIR)/glossary.md predep.m4 $< predep1.m4 > $@
$(DEPDIR)/epubpdf.d : $(FIGNUM_DOCS) epubpdfdep.m4 | $(DEPDIR)
m4 -EE -P -DDepTarget=$@ -DEpubPdfDir=$(EPUBPDFDIR) epubpdfdep.m4 $(FIGNUM_DOCS) > $@
include $(DEPDIR)/epubpdf.d
# glossary
$(MDDIR)/glossary_nogls.md : $(TEXTDIR)/glossary.md preglosmd.m4 | $(MDDIR)
m4 -EE -P preglosmd.m4 $< > $@
$(LATEXDIR)/glossary.tex : $(TEXTDIR)/glossary.md glostolatex.m4 | $(LATEXDIR)
m4 -EE -P glostolatex.m4 $(TEXTDIR)/glossary.md > $(LATEXDIR)/glossary.tex
# most targets to be build
$(LATEXDIR)/%.pdf : $(LATEXDIR)/%.tex $(LATEXDIR)/settings-default.tex $(LATEXDIR)/settings-common.tex $(LIBLATEX_DOCS) $(LATEXDIR)/glossary.tex | $(LATEXDIR)
$(LATEX) -output-directory=$(LATEXDIR) $<
$(TARGETDIR)/%.pdf : $(LATEXDIR)/%.pdf | $(TARGETDIR)
cp $< $@
$(TARGETDIR)/%.docx : $(MDDIR)/%.md | $(TARGETDIR)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_DOCX_OPTIONS) -o $@ $<
$(TARGETDIR)/%.rtf : $(MDDIR)/%.md | $(TARGETDIR)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_RTF_OPTIONS) -o $@ $<
$(TARGETDIR)/%.odt : $(MDDIR)/%.md | $(TARGETDIR)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_ODT_OPTIONS) -o $@ $<
$(TARGETDIR)/%.epub : $(MDDIR)/%_epub.md $(DEPDIR)/%_pict.d | $(TARGETDIR)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_EPUB_OPTIONS) -o $@ $<
$(LATEXDIR)/%_mid.tex : $(MDDIR)/%_latex.md | $(LATEXDIR)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_LATEX_OPTIONS) -o $@ $<
readm%.txt : readm%.md
$(PANDOC) $(README_OPTIONS) $(PANDOC_TXT_OPTIONS) -o $@ $<
readm%.pdf : readm%.md
$(PANDOC) $(README_OPTIONS) $(PANDOC_PDF_OPTIONS) -o $@ $<
# extra's
info.pdf : info.md
$(PANDOC) $(README_OPTIONS) $(PANDOC_PDF_OPTIONS) -o $@ $<
info.md : info_md.txt info_list.txt info_tpl.txt info.m4
m4 -EE -P info.m4 > $@
info_md.txt: $(Info_MDDOCS)
echo -n "$(subst $(space),$(comma),$(Info_MDDOCS))" > info_md.txt
info_list.txt: $(Info_LISTDOCS)
echo -n "$(subst $(space),$(comma),$(Info_LISTDOCS))" > info_list.txt
info_tpl.txt: $(Info_TPLDOCS)
echo -n "$(subst $(space),$(comma),$(Info_TPLDOCS))" > info_tpl.txt
todo.pdf : todo.md
$(PANDOC) $(README_OPTIONS) $(PANDOC_PDF_OPTIONS) -o $@ $<
todo.md : info_md.txt listtodo.m4
m4 -EE -P listtodo.m4 > $@
# css
$(CSSDIR)/%.css : $(SCSSDIR)/%.scss $(SCSS_DEPS) | $(CSSDIR) $(TARGETCSS)
$(SASS) $< $@
$(DEPFILES):
include $(wildcard $(DEPFILES))