-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
58 lines (46 loc) · 1.99 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
####################################################################################################
# Configuration
####################################################################################################
BUILD = build
MAKEFILE = Makefile
OUTPUT_FILENAME = book
METADATA = metadata.yml
CHAPTERS = chapters/*.md
TOC = --toc --toc-depth=2
IMAGES_FOLDER = images
IMAGES = $(IMAGES_FOLDER)/*
COVER_IMAGE = $(IMAGES_FOLDER)/cover.png
MATH_FORMULAS = --webtex
CSS_FILE = style.css
CSS_ARG = --css=$(CSS_FILE)
METADATA_ARG = --metadata-file=$(METADATA)
ARGS = $(TOC) $(MATH_FORMULAS) $(CSS_ARG) $(METADATA_ARG)
PDF_ARGS = -V geometry:margin=1in -V documentclass=report --pdf-engine=xelatex
####################################################################################################
# Basic actions
####################################################################################################
all: book
book: epub html pdf
clean:
rm -r $(BUILD)
####################################################################################################
# File builders
####################################################################################################
epub: $(BUILD)/epub/$(OUTPUT_FILENAME).epub
html: $(BUILD)/html/$(OUTPUT_FILENAME).html
pdf: $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf
$(BUILD)/epub/$(OUTPUT_FILENAME).epub: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(IMAGES) \
$(COVER_IMAGE)
mkdir -p $(BUILD)/epub
pandoc $(ARGS) --epub-cover-image=$(COVER_IMAGE) -o $@ $(CHAPTERS)
@echo "$@ was built"
$(BUILD)/html/$(OUTPUT_FILENAME).html: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(IMAGES)
mkdir -p $(BUILD)/html
pandoc $(ARGS) --standalone --to=html5 -o $@ $(CHAPTERS)
cp -R $(IMAGES_FOLDER)/ $(BUILD)/html/$(IMAGES_FOLDER)/
cp $(CSS_FILE) $(BUILD)/html/$(CSS_FILE)
@echo "$@ was built"
$(BUILD)/pdf/$(OUTPUT_FILENAME).pdf: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(IMAGES)
mkdir -p $(BUILD)/pdf
pandoc $(ARGS) $(PDF_ARGS) -o $@ $(CHAPTERS)
@echo "$@ was built"