-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
321 lines (253 loc) · 8.46 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
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
# Makefile of "Grammatica de Interlingue in Interlingue"
# By Marcos Cruz (programandala.net)
# http://ne.alinome.net
# Last modified: 20230412T1616+0200.
# See change log at the end of the file.
# ==============================================================
# Requirements {{{1
# Asciidoctor (by Dan Allen, Sarah White et al.)
# http://asciidoctor.org
# Asciidoctor EPUB3 (by Dan Allen and Sarah White)
# http://github.com/asciidoctor/asciidoctor-epub3
# Asciidoctor PDF (by Dan Allen and Sarah White)
# http://github.com/asciidoctor/asciidoctor-pdf
# dbtoepub
# http://docbook.sourceforge.net/release/xsl/current/epub/README
# ebook-convert
# manual.calibre-ebook.com/generated/en/ebook-convert.html
# Pandoc (by John MaFarlane)
# http://pandoc.org
# xsltproc
# http://xmlsoft.org/xslt/xsltproc.html
# ==============================================================
# Config {{{1
VPATH=./src:./target
book=grammatica_de_interlingue_in_interlingue
cover=$(book)_cover
cover_author="Dr. Fritz Haas"
cover_title="Grammatica\nde Interlingue\nin Interlingue"
lang="ie"
editor="Marcos Cruz (programandala.net)"
publisher="ne alinome"
description="Grammatica del lingue international auxiliari Interlingue"
# ==============================================================
# Interface {{{1
.PHONY: recommended
default: epuba pdfa4 thumb
.PHONY: all
all: azw3 epub odt pdf thumb
.PHONY: azw3
azw3: target/$(book).adoc.epub.azw3
.PHONY: epub
epub: epuba epubd epubp epubx
.PHONY: epuba
epuba: target/$(book).adoc.epub
.PHONY: epubd
epubd: target/$(book).adoc.dbk.dbtoepub.epub
.PHONY: epubp
epubp: target/$(book).adoc.dbk.pandoc.epub
.PHONY: epubx
epubx: target/$(book).adoc.dbk.xsltproc.epub
.PHONY: odt
odt: target/$(book).adoc.dbk.pandoc.odt
.PHONY: pdf
pdf: pdfa4 pdfletter
.PHONY: pdfa4
pdfa4: \
target/$(book).adoc._a4.pdf
.PHONY: pdfletter
pdfletter: \
target/$(book).adoc._letter.pdf
.PHONY: dbk
dbk: target/$(book).adoc.dbk
.PHONY: cover
cover: target/$(cover).jpg
.PHONY: thumb
thumb: target/$(cover)_thumb.jpg
.PHONY: clean
clean:
rm -fr target/* tmp/*
.PHONY: cleancover
cleancover:
rm -f target/*.jpg tmp/*.png
# ==============================================================
# Convert Asciidoctor to EPUB {{{1
target/%.adoc.epub: \
src/%.adoc \
src/epub3.css \
src/epub3-css3-only.css \
target/$(cover).jpg
asciidoctor-epub3 \
--out-file=$@ $<
# ==============================================================
# Convert Asciidoctor to DocBook {{{1
target/%.adoc.dbk: src/%.adoc
asciidoctor --backend=docbook5 --out-file=$@ $<
# ==============================================================
# Convert Asciidoctor to PDF {{{1
.SECONDARY: \
tmp/$(book).adoc._a4.pdf \
tmp/$(book).adoc._letter.pdf
tmp/%.adoc._a4.pdf: src/%.adoc tmp/$(cover).pdf
asciidoctor-pdf \
--out-file=$@ $<
tmp/%.adoc._letter.pdf: src/%.adoc tmp/$(cover).pdf
asciidoctor-pdf \
--attribute pdf-page-size=letter \
--out-file=$@ $<
target/%.pdf: tmp/%.pdf
cp -f $< $@
target/%.pdf.zip: tmp/%.pdf
zip -9 $@ $<
target/%.pdf.gz: tmp/%.pdf
gzip -9 --stdout $< > $@
# ==============================================================
# Convert DocBook to EPUB {{{1
# XXX OLD Deprecated.
# ------------------------------------------------
# Convert DocBook to EPUB with dbtoepub {{{2
# XXX TODO -- Add the cover image. There's no parameter to do it.
target/$(book).adoc.dbk.dbtoepub.epub: \
target/$(book).adoc.dbk \
src/$(book)-docinfo.xml \
src/dbtoepub_stylesheet.css
dbtoepub \
--css src/dbtoepub_stylesheet.css \
--output $@ $<
# ------------------------------------------------
# Convert DocBook to EPUB with pandoc {{{2
# XXX REMARK -- Deactivated by default. The cross references dont't work.
target/$(book).adoc.dbk.pandoc.epub: \
target/$(book).adoc.dbk \
src/$(book)-docinfo.xml \
src/pandoc_epub_template.txt \
src/pandoc_epub_stylesheet.css \
target/$(cover).jpg
pandoc \
--from docbook \
--to epub3 \
--template=src/pandoc_epub_template.txt \
--css=src/pandoc_epub_stylesheet.css \
--variable=lang:$(lang) \
--variable=editor:$(editor) \
--variable=publisher:$(publisher) \
--variable=description:$(description) \
--epub-cover-image=target/$(cover).jpg \
--output $@ $<
# ------------------------------------------------
# Convert DocBook to EPUB with xsltproc {{{2
# XXX REMARK -- Deactivated by default. Its result is identical to that of
# dbtoepub, which is a layer above xsltproc.
# XXX TODO -- Add the cover image. Beside copying the image, the files
# <toc.ncx> and <content.opf> must be modified:
#
# cp -f target/$(cover).jpg tmp/xsltproc/OEBPS/cover-image.jpg && \
# XXX TODO -- Find out how to pass parameters and their names, from the XLS:
# --param epub.ncx.filename testing.ncx \
# XXX TODO -- Add the stylesheet. The XLS must be modified first,
# or the resulting XHTML must be modified at the end.
# cp -f src/xsltproc/stylesheet.css tmp/xsltproc/OEBPS/ && \
target/%.adoc.dbk.xsltproc.epub: target/%.adoc.dbk target/$(cover).jpg
rm -fr tmp/xsltproc/* && \
xsltproc \
--output tmp/xsltproc/ \
/usr/share/xml/docbook/stylesheet/docbook-xsl/epub/docbook.xsl \
$< && \
echo -n application/epub+zip > tmp/xsltproc/mimetype && \
cd tmp/xsltproc/ && \
zip -0 -X ../../[email protected] mimetype && \
zip -rg9 ../../[email protected] META-INF && \
zip -rg9 ../../[email protected] OEBPS && \
cd - && \
mv [email protected] $@
# ==============================================================
# Convert DocBook to OpenDocument {{{1
target/$(book).adoc.dbk.pandoc.odt: \
target/$(book).adoc.dbk \
src/$(book)-docinfo.xml \
src/pandoc_odt_template.txt
pandoc \
--from docbook \
--to odt \
--template=src/pandoc_odt_template.txt \
--variable=lang:$(lang) \
--variable=editor:$(editor) \
--variable=publisher:$(publisher) \
--variable=description:$(description) \
--output $@ $<
# ==============================================================
# Convert EPUB to AZW3 {{{1
target/%.epub.azw3: target/%.epub
ebook-convert $< $@
# ==============================================================
# Create the cover image {{{1
include Makefile.cover_image
# ==============================================================
# Build the release archives {{{1
version_file=src/$(book).adoc
branch=trunk
prerequisites=*.adoc target/
include Makefile.release
# ==============================================================
# Change log {{{1
# 2019-02-05: Start.
#
# 2019-02-07: Add stylesheet to dbtoepub.
#
# 2019-02-08: Add debugging rule `xml`. Deprecate pandoc to make the EPUB. Make
# an OpenDocument version.
#
# 2019-02-21: Fix: set `lang` variable. Fix metadata parameters in pandoc
# commands.
#
# 2019-02-27: Don't use xsltproc by default. Make clean recursive. Consider
# DocBook a target, not an intermediate step.
#
# 2019-03-09: Build all EPUB variants by default. This makes instructions
# clearer.
#
# 2019-08-02: Fix directory of the DocBook file.
#
# 2020-02-24: Add a cover image.
#
# 2020-03-30: Use "dkb" DocBook filename extension instead of "xml". Build an
# EPUB also with Asciidoctor EPUB3. Update and improve the list of
# requirements. Update the publisher.
#
# 2020-04-01: Update the project/book title. Improve the cover image. Add the
# cover image to the documents. Rename the Asciidoctor PDF targets to make both
# variants be listed together. Add decoration to the cover image.
#
# 2020-04-02: Build only the recommended formats by default. Add rule
# "cleancover". Make the thumb cover by default. Fix: make Pandoc require the
# cover image to build the EPUB.
#
# 2020-04-06: Adjust the size and layout of the cover texts.
#
# 2020-08-24: Simplify the dependency between the cover and its thumb.
#
# 2020-08-27: Compress the PDF with zip and gzip. Convert also EPUB to AZW3.
# Deprecate the conversions from DocBook to EPUB.
#
# 2020-08-28: Move the cover image rules to an independent file. Improve the
# compression of PDF files and keep them also uncompressed in <tmp>.
#
# 2020-11-01: Update the interface rules to build all formats and only the
# recommended ones. Add the CSS files as prerequisites of the Asciidoctor EPUB3
# target.
#
# 2020-11-03: Update the requirements.
#
# 2020-11-05: Include <Makefile.release>.
#
# 2020-11-14: Update to the new vesion of <Makefile.release>.
#
# 2020-12-20: Add rule to convert <README.adoc> to <doc/README.html>.
#
# 2020-12-24: Move the online version of the README file to <doc/www/>.
#
# 2021-04-24: Don't compress the PDF; it will be compressed in the release
# archives.
#
# 2023-04-12: Remove the online version of the README, after converting the
# repo to Mercurial.