-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
98 lines (77 loc) · 2.54 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
95
96
97
98
SHELL = /bin/bash
BUILD_DIR = build/
TEMPLATE_DIR = templates/
IMAGES_DIR = images/
CSS_FILE = style.css
VERSION = $(shell git describe --abbrev=0 --tags)
VERSION := $(if $(VERSION),$(VERSION),none)
OUTPUT_BASENAME = $(shell basename $(CURDIR))-$(VERSION)
# CHAPTERS = text/*.md
CHAPTERS = $(shell find text -type f -name '*.md' | sort )
SLIDES = $(shell find slides -type f -name '*.md' | sort )
METADATA = metadata.yml
LATEX_CLASS = book
EPUB_BUILDER_FLAGS = \
--epub-cover-image=$(IMAGES_DIR)cover.png \
--css=templates/$(CSS_FILE) \
--template=templates/epub.html \
--metadata=version:$(VERSION) \
--lua-filter templates/latex.lua \
--toc --toc-depth=2 \
--webtex
HTML_BUILDER_FLAGS = \
--css=templates/$(CSS_FILE) \
--standalone --to=html5 \
--metadata-file=$(METADATA) \
--lua-filter templates/latex.lua \
--toc --toc-depth=2 \
--self-contained \
--webtex
BEAMER_BUILDER_FLAGS = \
--pdf-engine=xelatex \
-t beamer \
--template=templates/presentation.tex \
--slide-level 2
PDF_BUILDER_FLAGS = \
-V documentclass=$(LATEX_CLASS) \
--template=templates/book.tex \
--metadata=version:$(VERSION) \
--lua-filter templates/latex.lua \
--pdf-engine=xelatex \
--toc --toc-depth=2 \
--webtex
WORD_BUILDER_FLAGS = \
--reference-doc=templates/reference.docx \
--metadata-file=$(METADATA) \
--lua-filter templates/latex.lua
HANDOUT_BUILDER_FLAGS = \
-V handout=true
MOBI_BUILDER = kindlegen
.PHONY: show-args
show-args:
@printf "Project Version: %s\n" $(VERSION)
all: book presentation handout
# book: book html epub
clean:
touch $(BUILD_DIR)cleaning
rm -r $(BUILD_DIR)*
docx:
mkdir -p $(BUILD_DIR)
pandoc $(WORD_BUILDER_FLAGS) -o $(BUILD_DIR)$(OUTPUT_BASENAME).docx $(METADATA) $(CHAPTERS)
book:
mkdir -p $(BUILD_DIR)
pandoc $(PDF_BUILDER_FLAGS) -o $(BUILD_DIR)$(OUTPUT_BASENAME)-book.pdf $(METADATA) $(CHAPTERS)
cover:
pandoc --template=templates/cover.tex --pdf-engine=xelatex -o $(BUILD_DIR)$(OUTPUT_BASENAME)-cover.pdf $(METADATA)
html:
mkdir -p $(BUILD_DIR)html
cp -R $(IMAGES_DIR) $(BUILD_DIR)html/$(IMAGES_DIR)
pandoc $(HTML_BUILDER_FLAGS) -o $(BUILD_DIR)html/$(OUTPUT_BASENAME).html $(CHAPTERS)
presentation:
pandoc $(BEAMER_BUILDER_FLAGS) --metadata=aspectratio:169 -o $(BUILD_DIR)$(OUTPUT_BASENAME)-presentation.pdf $(METADATA) $(SLIDES)
handout:
pandoc $(BEAMER_BUILDER_FLAGS) -V handout -o $(BUILD_DIR)$(OUTPUT_BASENAME)-handout.pdf $(METADATA) $(SLIDES)
$(BUILD_DIR)$(OUTPUT_BASENAME).epub:
mkdir -p $(BUILD_DIR)
pandoc $(EPUB_BUILDER_FLAGS) -o $(BUILD_DIR)$(OUTPUT_BASENAME).epub $(CHAPTERS)
epub: $(BUILD_DIR)$(OUTPUT_BASENAME).epub