-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
51 lines (39 loc) · 1.29 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
BUILD = build
DOCS = docs
OUTPUT_FILENAME = book
DOCS_FILENAME = index
METADATA = metadata.yml
CHAPTERS = chapters/**/*.md
TOC = --toc --toc-depth=2
IMAGES_FOLDER = images
COVER_IMAGE = images/cover.png
LATEX_CLASS = report
MATH_FORMULAS = --webtex
CSS_FILE = style.css
CSS_ARG = --css=$(CSS_FILE)
ARGS = $(TOC) $(MATH_FORMULAS) $(CSS_ARG)
all: book
book: epub html pdf docs
clean:
rm -r $(BUILD)
rm -r $(DOCS)
epub: $(BUILD)/epub/$(OUTPUT_FILENAME).epub
html: $(BUILD)/html/$(OUTPUT_FILENAME).html
pdf: $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf
docs: $(DOCS)/$(DOCS_FILENAME).html
$(BUILD)/epub/$(OUTPUT_FILENAME).epub: $(METADATA) $(CHAPTERS)
mkdir -p $(BUILD)/epub
pandoc $(ARGS) --epub-metadata=$(METADATA) --epub-cover-image=$(COVER_IMAGE) -o $@ $^
$(BUILD)/html/$(OUTPUT_FILENAME).html: $(CHAPTERS)
mkdir -p $(BUILD)/html
pandoc $(ARGS) --standalone --to=html5 -o $@ $^
cp -R $(IMAGES_FOLDER)/ $(BUILD)/html/$(IMAGES_FOLDER)/
cp $(CSS_FILE) $(BUILD)/html/$(CSS_FILE)
$(BUILD)/pdf/$(OUTPUT_FILENAME).pdf: $(METADATA) $(CHAPTERS)
mkdir -p $(BUILD)/pdf
pandoc $(ARGS) -V documentclass=$(LATEX_CLASS) -o $@ $^
$(DOCS)/$(DOCS_FILENAME).html: $(CHAPTERS)
mkdir -p $(DOCS)
pandoc $(ARGS) --standalone --to=html5 -o $@ $^
cp -R $(IMAGES_FOLDER)/ $(DOCS)/$(IMAGES_FOLDER)/
cp $(CSS_FILE) $(DOCS)/$(CSS_FILE)