forked from merklebloom/bookbuilder
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (72 loc) · 2.15 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
# This makefile generates all the output files from the source Asciidoc files.
ifndef $(LANG)
LANG = en
endif
# Constants
DIR = _build
DIST = dist
BOOKFILE = master
TAG = `git describe --tags --always`
TITLE = TheBookTitle
RUBYDIR = /usr/lib/ruby/gems/2.4.0/gems/
ADOCFONTSDIR = ${RUBYDIR}/asciidoctor-pdf-1.5.0.alpha.16/data/fonts/
EPUBCSSDIR= ${RUBYDIR}/asciidoctor-epub3-1.5.0.alpha.7/data/styles/
TTFFONTSDIR = /usr/share/fonts/
KINDLEGEN_PATH = /usr/local/bin/
KINDLEGEN_OPTS = -c2
PDFOPTS = -a lang=${LANG}
EPUBOPTS = -a lang=${LANG}
# ---------------------------------
# Public targets
all: pdf epub kindle
# Usage
# make [LANG=xx] {pdf, epub, kindle}
pdf: clean create_pdf dist_pdf
epub: clean create_epub dist_epub
kindle: clean create_kindle dist_kindle
clean:
if [ -d "${DIR}" ]; \
then rm -r ${DIR}; \
fi; \
create_folder:
if [ ! -d "${DIR}" ]; then \
mkdir ${DIR}; \
fi; \
cp -u images/* ${DIR}; \
cp -u chapters/${LANG}/* ${DIR}; \
cp -u ${EPUBCSSDIR}/* ${DIR};
cp -u conf/* ${DIR}; \
copy_fonts:
find ${TTFFONTSDIR} -name *ttf -exec cp -u {} ${DIR} \;
find ${ADOCFONTSDIR} -name *ttf -exec cp -u {} ${DIR} \;
compress_images: create_folder
cd ${DIR}; \
for f in *.png; \
do mogrify -depth 4 -colorspace gray -resize 504 "$$f"; \
done; \
# Generate PDF
create_pdf: create_folder copy_fonts
cd ${DIR}; \
asciidoctor-pdf --verbose ${PDFOPTS} ${BOOKFILE}.asciidoc
create_epub: create_folder copy_fonts
cd ${DIR}; \
asciidoctor-epub3 --verbose ${EPUBOPTS} ${BOOKFILE}.asciidoc
create_kindle: create_folder copy_fonts
cd ${DIR}; \
asciidoctor-epub3 -a ebook-format=kf8 --verbose ${EPUBOPTS} ${BOOKFILE}.asciidoc
create_dist:
if [ ! -d "${DIST}/${LANG}" ]; then \
mkdir -p ${DIST}/${LANG}; \
fi; \
dist_pdf: create_dist
if [ -f "${DIR}/${BOOKFILE}.pdf" ]; then \
cp ${DIR}/${BOOKFILE}.pdf "${DIST}/${LANG}/${TITLE}_${TAG}.pdf"; \
fi; \
dist_epub: create_dist
if [ -f "${DIR}/${BOOKFILE}.epub" ]; then \
cp ${DIR}/${BOOKFILE}.epub "${DIST}/${LANG}/${TITLE}_${TAG}.epub"; \
fi; \
dist_kindle: create_dist
if [ -f "${DIR}/${BOOKFILE}.mobi" ]; then \
cp ${DIR}/${BOOKFILE}.mobi "${DIST}/${LANG}/${TITLE}_${TAG}.mobi"; \
fi; \