-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
50 lines (40 loc) · 1.51 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
BUILD = build
MAKEFILE = Makefile
OUTPUT_FILENAME = oct-wave
HTML_OUTPUT_FILENAME = index
METADATA = metadata.yaml
CHAPTERS = chapters/*.md
TOC = --toc --toc-depth=2
IMAGES_FOLDER = images
IMAGES = $(IMAGES_FOLDER)/*
COVER_IMAGE = $(IMAGES_FOLDER)/cover.png
LATEX_CLASS = report
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) --lua-filter=absolute-links.lua
all: book
book: epub pdf html
honkit:
npm ci
npm run honkit -- build
npm run honkit -- epub . book.epub
npm run honkit -- mobi . book.mobi
clean:
rm -r $(BUILD)
epub: $(BUILD)/epub/$(OUTPUT_FILENAME).epub
html: $(BUILD)/html/$(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)
$(BUILD)/html/$(HTML_OUTPUT_FILENAME).html: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(IMAGES)
mkdir -p $(BUILD)/html
pandoc $(ARGS) --standalone --to=html5 -o $@ $(CHAPTERS) --template templates/default.html --toc -V toctitle:'Table of Contents'
cp -R $(IMAGES_FOLDER)/ $(BUILD)/html/$(IMAGES_FOLDER)/
cp $(CSS_FILE) $(BUILD)/html/$(CSS_FILE)
$(BUILD)/pdf/$(OUTPUT_FILENAME).pdf: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(IMAGES)
mkdir -p $(BUILD)/pdf
pandoc $(ARGS) -V documentclass=$(LATEX_CLASS) -o $@ $(CHAPTERS)