-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
103 lines (85 loc) · 3.44 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
99
100
101
102
103
# textbook content settings
OUTPUT_FILENAME = textbook
OUTPUT_DIRECTORY = public
# looks for :Zone.Identifier files added by https://github.com/microsoft/WSL/issues/4609
CHECK = $(shell find . -name '*:Zone.Identifier' -delete)
IMAGES = $(shell find source/images -type f)
CHAPTERS = source/chapters/*.md
CONTENT = awk 'FNR==1 && NR!=1 {print "\n\n"}{print}' $(CHAPTERS)
# output configuration files
HTML = --filter pandoc-crossref --defaults assets/defaults/html.yml
DOCX = --defaults assets/defaults/docx.yml
LATEX = --filter pandoc-crossref --defaults assets/defaults/latex.yml --no-highlight
EPUB = --filter pandoc-crossref --defaults assets/defaults/epub.yml --mathml
# utilities
MAKEFILE = Makefile
PANDOC_COMMAND = pandoc --quiet
BASE_DEPENDENCIES = $(MAKEFILE) $(CHECK) $(CHAPTERS) $(IMAGES)
# build commands
textbook: html docx latex epub pdf
epub: $(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).epub
html: $(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).html
pdf: $(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).pdf
docx: $(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).docx
latex: $(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).tex
markdown:
@bash ./assets/scripts/preprocess.sh
@echo "📚 Your Markdown files are ready in the /chapters/ folder"
clean:
@rm -r $(OUTPUT_DIRECTORY)
@echo "🧹 Let's start over."
# recipes for outputs
$(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).epub: $(BASE_DEPENDENCIES)
@mkdir -p $(OUTPUT_DIRECTORY)
@$(CONTENT) | tee | $(PANDOC_COMMAND) $(EPUB) -o $@
@echo "📚 The EPUB edition is now available in $@"
$(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).html: $(BASE_DEPENDENCIES)
@mkdir -p $(OUTPUT_DIRECTORY)
@$(CONTENT) | tee | $(PANDOC_COMMAND) $(HTML) -o $@
@cp $(IMAGES) $(OUTPUT_DIRECTORY)
@cp assets/lib/* $(OUTPUT_DIRECTORY)
@cp assets/styles/* $(OUTPUT_DIRECTORY)
@mv $(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).html $(OUTPUT_DIRECTORY)/index.html
@echo "📚 The HTML edition is now available in $@"
$(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).pdf: $(BASE_DEPENDENCIES)
@mkdir -p $(OUTPUT_DIRECTORY)
@$(CONTENT) | tee | $(PANDOC_COMMAND) $(LATEX) -o $@
@echo "📚 The PDF edition is now available in $@"
$(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).tex: $(BASE_DEPENDENCIES)
@mkdir -p $(OUTPUT_DIRECTORY)
@$(CONTENT) | tee | $(PANDOC_COMMAND) $(LATEX) -o $@
@echo "📚 The LaTeX edition is now available in $@"
$(OUTPUT_DIRECTORY)/$(OUTPUT_FILENAME).docx: $(BASE_DEPENDENCIES)
@mkdir -p $(OUTPUT_DIRECTORY)
@$(CONTENT) | tee | $(PANDOC_COMMAND) $(DOCX) -o $@
@echo "📚 The DOCX edition is now available in $@"
# lantern documentation content settings
DOCS_OUTPUT_DIRECTORY = public/docs
DOCS_IMAGES = $(shell find docs/images -type f)
DOCS_CONTENT = awk 'FNR==1 && NR!=1 {print "\n\n"}{print}' $(DOCS_CHAPTERS)
DOCS_DEPENDENCIES = $(MAKEFILE) $(CHECK) $(DOCS_CHAPTERS) $(DOCS_IMAGES)
DOCS = --defaults assets/defaults/docs.yml
DOCS_CHAPTERS += $(addprefix ./docs/chapters/,\
introduction.md\
technology.md\
manuscripts.md\
formatting.md\
online-workflow.md\
desktop-workflow.md\
metadata.md\
content.md\
media.md\
bibliographies.md\
customization.md\
troubleshooting.md\
)
# documentation build commands
docs: $(DOCS_OUTPUT_DIRECTORY)/index.html
# lantern documenation build recipes
$(DOCS_OUTPUT_DIRECTORY)/index.html: $(DOCS_DEPENDENCIES)
mkdir -p $(DOCS_OUTPUT_DIRECTORY)
$(DOCS_CONTENT) | tee | $(PANDOC_COMMAND) $(DOCS) -o $@
cp $(DOCS_IMAGES) $(DOCS_OUTPUT_DIRECTORY)
cp assets/lib/* $(DOCS_OUTPUT_DIRECTORY)
cp assets/styles/* $(DOCS_OUTPUT_DIRECTORY)
@echo "$@ was built"