-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (67 loc) · 1.79 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
# https://github.com/w3c/epubcheck/releases
EPUBCHECKJAR=$(HOME)/pkgs/epubcheck-4.2.2/epubcheck.jar
DOC=desosa2019
CHAPTERS=$(wildcard chapters/*)
CHAPTERS_MD=$(patsubst %,%/index.md,$(CHAPTERS))
RESOURCE_PATH=$(subst $(EVAL) $(EVAL),:,$(CHAPTERS)):./
EXTRACTDIR=zzz-epub-extract
TARGET_DIR=target
OUTPUT_DIR=output
EPUB_OUT=$(TARGET_DIR)/$(DOC).epub
PDF_OUT=$(TARGET_DIR)/$(DOC).pdf
all:
$(MAKE) clean img epub
epub:
mkdir -p $(TARGET_DIR)
pandoc \
--file-scope \
--toc \
--number-sections \
--toc-depth=2 \
--epub-cover-image=img/cover.jpg \
--resource-path=$(RESOURCE_PATH) \
--output=$(EPUB_OUT) \
index.md \
$(CHAPTERS_MD)
check:
java -jar $(EPUBCHECKJAR) $(EPUB_OUT)
# An epub file is just a zip file with html content.
# Provide target for unzipping to help fixing incorrect epubs.
unzip:
rm -rf $(EXTRACTDIR)
mkdir -p $(EXTRACTDIR)
cp $(EPUB_OUT) $(EXTRACTDIR)/$(DOC).zip
cd $(EXTRACTDIR); unzip $(DOC).zip
clean:
rm -rf images $(EXTRACTDIR) $(TARGET_DIR)
# Create the full book.
#
# To create single chapter use:
#
# To create tex source for debugging, use:
# $ make pdf CHAPTERS=chapters/scipy/ PDF_OUT=target/desosa.tex
pdf:
mkdir -p $(TARGET_DIR)
pandoc \
--file-scope \
--include-in-header=preamble.tex \
--variable urlcolor=cyan \
--toc \
--top-level-division=chapter \
--number-sections \
--toc-depth=2 \
--resource-path=$(RESOURCE_PATH) \
--output=$(PDF_OUT) \
index.md \
$(CHAPTERS_MD)
docker:
# Within the docker container you can run your jekyll commands, including "jekyll build --watch"
docker run --rm --volume="$(CURDIR):/srv/jekyll" -it jekyll/builder:3.8.4 bash
serve:
cd _site && python -m SimpleHTTPServer 4000
release:
mkdir -p $(OUTPUT_DIR)
$(MAKE) pdf
cp $(PDF_OUT) $(OUTPUT_DIR)
$(MAKE) epub
cp $(EPUB_OUT) $(OUTPUT_DIR)