-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
68 lines (56 loc) · 1.74 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
BUILD = build
BOOKNAME = i4tvsolution
METADATA = metadata.yaml
SRC_DIR = src/
TOC = --toc
LATEX_CLASS = report
GHUSER =
GHPASS =
all: book
book: epub mobi html
epub: $(BUILD)/epub/$(BOOKNAME).epub
html: $(BUILD)/html/$(BOOKNAME).html
pdf: $(BUILD)/pdf/$(BOOKNAME).pdf
mobi: $(BUILD)/mobi/$(BOOKNAME).mobi
clean:
rm -r $(BUILD)
#pandoc generate great TOC for epub, html, pdf
#so In this makefile, we will omit Readme.md
$(BUILD)/epub/$(BOOKNAME).epub: $(TITLE)
mkdir -p $(BUILD)/epub
pandoc $(TOC) -S -o $@ $(METADATA) `ls $(SRC_DIR)*.md`
$(BUILD)/html/$(BOOKNAME).html:
mkdir -p $(BUILD)/html
cp -r images $(BUILD)/images
cp images/i4tvsolution.png $(BUILD)/html
@tmpdir=`pwd`;\
cd $(BUILD)/html;\
mdtogh --css --user=$(GHUSER) --pass=$(GHPASS) --toc --toc_file=$$tmpdir/$(SRC_DIR)Readme.md --book=$$tmpdir/book.json --file_reg='^\d.+\.md$$' $$tmpdir/$(SRC_DIR);
$(BUILD)/pdf/$(BOOKNAME).pdf: $(TITLE)
mkdir -p $(BUILD)/pdf
pandoc $(TOC) --latex-engine=xelatex -V documentclass=$(LATEX_CLASS) -o $@ `ls $(SRC_DIR)*.md`
$(BUILD)/mobi/$(BOOKNAME).mobi: $(TITLE)
mkdir -p build/mobi
@if [ ! -e $(BUILD)/epub/$(BOOKNAME).epub ];\
then \
echo "make epub first"; \
make epub ;\
fi;
@echo "generating mobi now"
@ebook_convert_cmd=`which ebook-convert`; \
if [ -z $$ebook_convert_cmd ]; \
then \
mac_osx_path='Applications/calibre.app/Contents/MacOS/ebook-convert';\
ebook_convert_cmd=$$mac_osx_path;\
fi;\
if [ ! -e $$ebook_convert_cmd ];\
then \
echo "You need install calibre first!";\
exit 1;\
fi; \
$$ebook_convert_cmd "$(BUILD)/epub/$(BOOKNAME).epub" "$(BUILD)/mobi/$(BOOKNAME).mobi" \
--cover i4tvsolution.png \
--authors July \
--level1-toc 'h1'\
--language zh_CN ;
.PHONY: all book clean epub html pdf mobi