-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
88 lines (63 loc) · 2 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
# Makefile of _Glosalist 1997-2003_
# By Marcos Cruz (programandala.net)
# Last modified 201901161945
# See change log at the end of the file
# ==============================================================
# XXX TODO --
# - Create HTML versions without header and footer.
# ==============================================================
# Requirements
# - make
# - asciidoctor
# - pandoc
# ==============================================================
# Config
VPATH=./src:./target
# ==============================================================
# Interface
.PHONY: all
all: epub
.PHONY: cleanepub
cleanepub:
rm -f target/*.epub
.PHONY: cleanxml
cleanxml:
rm -f target/*.xml
.PHONY: clean
clean: cleanepub cleanxml
# ==============================================================
# Convert to DocBook
target/%.adoc.xml: src/%.adoc
asciidoctor --backend=docbook5 --out-file=$@ $<
# ==============================================================
# Convert to EPUB
# NB: Pandoc (v1.9.4.2) does not allow EPUB alternative templates using
# `--data-dir` (by default, <~/.pandoc>). The default templates must be
# modified or redirected instead. They are the following:
#
# /usr/share/pandoc-1.9.4.2/templates/epub-coverimage.html
# /usr/share/pandoc-1.9.4.2/templates/epub-page.html
# /usr/share/pandoc-1.9.4.2/templates/epub-titlepage.html
# NB: Option `+RTS -K21000000 -RTS` is required in order to increase the
# stack space.
%.adoc.xml.pandoc.epub: %.adoc.xml
pandoc \
+RTS -K21000000 -RTS \
--from=docbook \
--to=epub \
--epub-stylesheet=src/stylesheet.css \
--output=$@ \
$<
# --data-dir=src/templates \
adoc_files=$(sort $(wildcard src/*.adoc))
docbook_files=$(addprefix target/,$(notdir $(addsuffix .xml,$(adoc_files))))
.PHONY: epub
epub: $(docbook_files)
for file in $^; do \
make $$file.pandoc.epub; \
done;
# ==============================================================
# Change log
# 2018-11-30: Start. Copy from the project _Un Hedo Prince_.
#
# 2019-01-16: Adjust pandoc's parameters.