-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
286 lines (222 loc) · 7.31 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
# Makefile of _pandunia da leksobuke_
# This file is part of the project
# _pandunia da leksobuke_
# (http://ne.alinome.net)
# By Marcos Cruz (programandala.net)
# Last modified 201902221734
# See change log at the end of the file
# ==============================================================
# Requirements
# - asciidoctor
# - asciidoctor-pdf
# - awk
# - bash
# - dictfmt
# - dbtoepub
# - make
# - pandoc
# ==============================================================
# Config
VPATH=./src:./target
SHELL=/bin/bash
dict_input_format=c5
# ==============================================================
# Interface
.PHONY: all
all: dict epub html odt pdf rtf txt xml
.PHONY: adoc
adoc: target/pandunia_da_leksobuke.adoc
.PHONY: dict
dict: \
target/pandunia.dict.dz \
target/eng-pandunia.dict.dz \
target/epo-pandunia.dict.dz \
target/spa-pandunia.dict.dz
.PHONY: epub
epub: \
target/pandunia_da_leksobuke.adoc.xml.dbtoepub.epub \
target/pandunia_da_leksobuke.adoc.xml.pandoc.epub
.PHONY: html
html: \
target/pandunia_da_leksobuke.adoc.html \
target/pandunia_da_leksobuke.adoc.xml.pandoc.html
.PHONY: odt
odt: target/pandunia_da_leksobuke.adoc.xml.pandoc.odt
.PHONY: pdf
pdf: target/pandunia_da_leksobuke.adoc.pdf
.PHONY: rtf
rtf: target/pandunia_da_leksobuke.adoc.xml.pandoc.rtf
.PHONY: txt
txt: target/pandunia_da_leksobuke.adoc.xml.pandoc.txt
.PHONY: xml
xml: target/pandunia_da_leksobuke.adoc.xml
.PHONY: clean
clean:
rm -f target/* tmp/*
# ==============================================================
# Make Asciidoctor from the original table
target/pandunia_da_leksobuke.adoc: src/pandunia-lekse.tsv
datadate=$$(stat --format='%y' src/pandunia-lekse.tsv);\
awk \
--assign target=asciidoctor \
--assign datadate=$${datadate:0:10} \
--file src/pandunia_da_leksobuke.awk \
$< > $@
# ==============================================================
# Make dictfmt input texts from the original table
# ----------------------------------------------
# Main dictionary, from Pandunia to all other languages
tmp/pandunia_da_leksobuke.txt: src/pandunia-lekse.tsv
datadate=$$(stat --format='%y' src/pandunia-lekse.tsv);\
awk \
--assign target=$(dict_input_format) \
--assign datadate=$${datadate:0:10} \
--file src/pandunia_da_leksobuke.awk \
$< > $@
# ----------------------------------------------
# Vocabulary English-Pandunia
tmp/pandunia_da_leksoliste_na_engli.txt: src/pandunia-lekse.tsv
datadate=$$(stat --format='%y' src/pandunia-lekse.tsv);\
awk \
--assign target=$(dict_input_format) \
--assign datadate=$${datadate:0:10} \
--assign lang=eng \
--file src/pandunia_da_leksoliste.awk \
$< > $@
# ----------------------------------------------
# Vocabulary Esperanto-Pandunia
tmp/pandunia_da_leksoliste_na_esperanti.txt: src/pandunia-lekse.tsv
datadate=$$(stat --format='%y' src/pandunia-lekse.tsv);\
awk \
--assign target=$(dict_input_format) \
--assign datadate=$${datadate:0:10} \
--assign lang=epo \
--file src/pandunia_da_leksoliste.awk \
$< > $@
# ----------------------------------------------
# Vocabulary Esperanto-Pandunia
tmp/pandunia_da_leksoliste_na_spani.txt: src/pandunia-lekse.tsv
datadate=$$(stat --format='%y' src/pandunia-lekse.tsv);\
awk \
--assign target=$(dict_input_format) \
--assign datadate=$${datadate:0:10} \
--assign lang=spa \
--file src/pandunia_da_leksoliste.awk \
$< > $@
# ==============================================================
# Make DocBook from Asciidoctor
%.adoc.xml: %.adoc
asciidoctor --backend=docbook5 --out-file=$@ $<
# ==============================================================
# Make EPUB from DocBook
# ----------------------------------------------
# With dbtoepub
%.adoc.xml.dbtoepub.epub: %.adoc.xml
dbtoepub --output $@ $<
# ----------------------------------------------
# With pandoc
%.adoc.xml.pandoc.epub: %.adoc.xml
pandoc -f docbook -t epub --output $@ $<
# ==============================================================
# Make HTML
# ----------------------------------------------
# From Asciidoctor
# Note: This HTML file includes the Asciidoctor's default stylesheet in the
# HTML header. A default stylesheet may be used, set by documents attributes
# `:stylesheet:` and `:stylesheet:`, which can be set also from the command
# line, e.g. `-a stylesheet=my_styles.css -a stylesdir=../stylesheets`.
# Setting a missing CSS file causes the document to use no stylesheet.
%.adoc.html: %.adoc
asciidoctor --backend=html --out-file=$@ $<
# ----------------------------------------------
# From DocBook
%.adoc.xml.pandoc.html: %.adoc.xml
pandoc -f docbook -t html --standalone --output $@ $<
# ==============================================================
# Make ODT from DocBook
%.adoc.xml.pandoc.odt: %.adoc.xml
pandoc -f docbook -t odt --output $@ $<
# ==============================================================
# Make PDF from Asciidoctor
%.adoc.pdf: %.adoc
asciidoctor-pdf --out-file=$@ $<
# ==============================================================
# Make RTF from DocBook
%.adoc.xml.pandoc.rtf: %.adoc.xml
pandoc -f docbook -t rtf --standalone --output $@ $<
# ==============================================================
# Make plain text from DocBook
%.adoc.xml.pandoc.txt: %.adoc.xml
pandoc -f docbook -t plain --standalone --output $@ $<
# ==============================================================
# Make dict
target/pandunia.dict: tmp/pandunia_da_leksobuke.txt
dictfmt \
--utf8 \
--allchars \
-u "http://pandunia.info" \
-s "pandunia da leksobuke (Pandunia Dictionary)" \
-$(dict_input_format) \
$(basename $@) < $<
target/eng-pandunia.dict: tmp/pandunia_da_leksoliste_na_engli.txt
dictfmt \
--utf8 \
--allchars \
-u "http://pandunia.info" \
-s "English-Pandunia Vocabulary" \
-$(dict_input_format) \
$(basename $@) < $<
target/epo-pandunia.dict: tmp/pandunia_da_leksoliste_na_esperanti.txt
dictfmt \
--utf8 \
--allchars \
-u "http://pandunia.info" \
-s "Vortaro Esperanto-Pandunio" \
-$(dict_input_format) \
$(basename $@) < $<
target/spa-pandunia.dict: tmp/pandunia_da_leksoliste_na_spani.txt
dictfmt \
--utf8 \
--allchars \
-u "http://pandunia.info" \
-s "Vocabulario español-pandunia" \
-$(dict_input_format) \
$(basename $@) < $<
%.dict.dz: %.dict
dictzip --force $<
# ==============================================================
# Install and uninstall dict
.PHONY: install
install: \
target/pandunia.dict.dz \
target/eng-pandunia.dict.dz \
target/epo-pandunia.dict.dz \
target/spa-pandunia.dict.dz
cp --force \
$^ \
$(addsuffix .index, $(basename $(basename $^))) \
/usr/share/dictd/
/usr/sbin/dictdconfig --write
/etc/init.d/dictd restart
.PHONY: uninstall
uninstall:
rm --force /usr/share/dictd/*pandunia.*
/usr/sbin/dictdconfig --write
/etc/init.d/dictd restart
# ==============================================================
# Change log
# 2019-01-02: Start. Create first version of EPUB with pandoc, from
# Asciidoctor.
#
# 2019-01-03: Create also a dict format dictionary.
#
# 2019-01-18: Update the requirements. Add rule to uninstall the dict format
# dictionary. Add HTML, ODT, PDF, RTF and TXT outputs.
#
# 2019-02-05: Fix uninstalling the dict.
#
# 2019-02-07: Add rules to build vocabularies English-Pandunia,
# Esperanto-Pandunia and Spanish-Pandunia. Make an additional EPUB with
# dbtoepub.
#
# 2019-02-22: Update after the renaming of the project.