-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
212 lines (165 loc) · 4.75 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
# Makefile of _Un Hedo Prince_
# This file is part of project
# _Un Hedo Prince_
# by Marcos Cruz (programandala.net)
# http://ne.alinome.net
# Last modified 201902231523
# See change log at the end of the file
# ==============================================================
# XXX TODO --
# - Create HTML versions without header and footer.
# ==============================================================
# Requirements
# - make
# - asciidoctor
# - asciidoctor-pdf
# - dbtoepub
# - pandoc
# - GraphicsMagick
# ==============================================================
# Config
VPATH=./src:./target
book=un_hedo_prince
# ==============================================================
# Interface
.PHONY: all
all: epub html odt pdf
.PHONY: docbook
docbook: target/$(book).adoc.xml
.PHONY: epub
epub: epubd epubp
.PHONY: epubd
epubd: target/$(book).adoc.xml.dbtoepub.epub
.PHONY: epubp
epubp: target/$(book).adoc.xml.pandoc.epub
.PHONY: html
html: \
target/$(book).adoc.html \
target/$(book).adoc.plain.html \
target/$(book).adoc.xml.pandoc.html
.PHONY: odt
odt: target/$(book).adoc.xml.pandoc.odt
.PHONY: pdf
pdf: pdfa4 pdfletter
.PHONY: pdfa4
pdfa4: target/$(book).adoc.a4.pdf
.PHONY: pdfletter
pdfletter: target/$(book).adoc.letter.pdf
.PHONY: rtf
rtf: target/$(book).adoc.xml.pandoc.rtf
.PHONY: cover
cover: target/$(book)_cover.txt.png
.PHONY: clean
clean:
rm -f target/*
# ==============================================================
# Convert Asciidoctor to DocBook
target/$(book).adoc.xml: $(book).adoc
asciidoctor --backend=docbook5 --out-file=$@ $<
# ==============================================================
# Convert DocBook to EPUB
# ------------------------------------------------
# With dbtoepub
target/$(book).adoc.xml.dbtoepub.epub: \
target/$(book).adoc.xml
dbtoepub \
--output $@ $<
# ------------------------------------------------
# With pandoc
target/$(book).adoc.xml.pandoc.epub: \
target/$(book).adoc.xml \
target/$(book)_cover.txt.png \
src/pandoc_epub_template.txt \
src/stylesheet.css
pandoc \
--from=docbook \
--to=epub3 \
--template=src/pandoc_epub_template.txt \
--css=src/stylesheet.css \
--epub-cover-image=target/$(book)_cover.txt.png \
--output=$@ \
$<
target/$(book)_cover.txt.png: src/$(book)_cover.txt
gm convert \
-page 900x1500 \
-background white -fill black \
-border 50 -bordercolor white \
-pointsize 70 \
-font Courier \
text:$< \
$@
# XXX OLD -- asciidoctor-epub3 is not used anymore:
target/$(book).adoc.epub: $(book).adoc target/$(book)_cover.txt.png
asciidoctor-epub3 \
--destination-dir=target \
$< ; \
mv target/$(book).epub $@
# ==============================================================
# Convert Asciidoctor to HTML
target/$(book).adoc.plain.html: $(book).adoc
adoc \
--attribute="stylesheet=none" \
--quiet \
--out-file=$@ \
$<
target/$(book).adoc.html: $(book).adoc
adoc --out-file=$@ $<
# ==============================================================
# Convert DocBook to HTML
target/$(book).adoc.xml.pandoc.html: \
target/$(book).adoc.xml \
src/pandoc_html_template.txt
pandoc \
--from=docbook \
--to=html \
--template=src/pandoc_html_template.txt \
--standalone \
--output=$@ \
$<
# ==============================================================
# Convert DocBook to ODT
target/$(book).adoc.xml.pandoc.odt: \
target/$(book).adoc.xml \
src/pandoc_odt_template.txt
pandoc \
+RTS -K15000000 -RTS \
--from=docbook \
--to=odt \
--template=src/pandoc_odt_template.txt \
--output=$@ \
$<
# ==============================================================
# Convert Asciidoctor to PDF
target/$(book).adoc.a4.pdf: $(book).adoc
asciidoctor-pdf \
--out-file=$@ $<
target/$(book).adoc.letter.pdf: $(book).adoc
asciidoctor-pdf \
--attribute pdf-page-size=letter \
--out-file=$@ $<
# ==============================================================
# Convert DocBook to RTF
target/$(book).adoc.xml.pandoc.rtf: \
target/$(book).adoc.xml \
src/pandoc_rtf_template.txt
pandoc \
--from=docbook \
--to=rtf \
--template=src/pandoc_rtf_template.txt \
--standalone \
--output=$@ \
$<
# ==============================================================
# Change log
# 2018-11-25: Start. Copy from the project _Plu Glosa Nota_.
#
# 2018-11-27: Add asciidoctor-epub3, as an alternative to Pandoc. Replace the
# `$target` variable with a literal. Add a temporary cover, created by
# GraphicsMagick out of a text file.
#
# 2018-11-29: Add a pandoc EPUB stylesheet. Don't use asciidoctor-epub3
# anymore; use only pandoc. Fix pandoc's RTF and HTML output. Remove old <pic>
# directory link, which was used by HTML.
#
# 2019-02-23: Update pandoc parameters to version 2.6 and add templates. Make
# also a letter-size PDF. Make an alterntive EPUB with dbtoepub.