-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
93 lines (70 loc) · 2.39 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
# base names of individual tutorials, pillar sources, included images
KATAS := lan-simulator
SOURCES := index $(KATAS)
IMAGES := lan-star lan-routes
#
# Important places and file sets
#
DESTDIR := output
BUILDIR := build
HTML_SUPPORT := $(addprefix $(DESTDIR)/, \
css/remarkdown.css \
css/custom.css \
$(IMAGES:%=images/%.svg) \
)
HTML_OUTPUTS := $(SOURCES:%=$(DESTDIR)/%.html)
PDF_OUTPUTS := $(KATAS:%=$(DESTDIR)/%.pdf)
TEX_OUTPUTS := $(KATAS:%=$(BUILDIR)/%.tex)
ALL = $(HTML_OUTPUTS) $(HTML_SUPPORT) $(PDF_OUTPUTS)
#
# Build rules
#
$(DESTDIR) :
git worktree prune
git worktree add $(DESTDIR) gh-pages
$(HTML_OUTPUTS) $(PDF_OUTPUTS) : $(DESTDIR)/% : $(BUILDIR)/% | $(DESTDIR)
cp $< $@
$(HTML_SUPPORT) : $(DESTDIR)/% : % | $(DESTDIR)
mkdir -p $(@D) && cp $< $@
$(BUILDIR) :
mkdir $(BUILDIR)
$(BUILDIR)/%.pdf %(BUILDIR)/%.d : $(BUILDIR)/%.tex
cd $(BUILDIR); \
TEXINPUTS=../:../latex/sbabook/: \
texfot latexmk -r ../.latexmkrc -deps -deps-out=$*.d $*
$(BUILDIR)/*.html : template.html.mustache
$(BUILDIR)/*.tex : template.latex.mustache
$(BUILDIR)/%.html $(BUILDIR)/%.tex : %.pillar pillar.conf | $(BUILDIR)
pillar/pillar export $<
sed -ie '/^\\includegraphics/s/\.svg//' $(BUILDIR)/$*.tex
output-git = git -C output
#
# Build targets
#
.DEFAULT_GOAL := help
.phony : all watch clean clobber prune snapshot deploy help
all : $(ALL) ## Build output
watch : all ## Auto-rerun 'make all' on file changes
@which watchman-make >/dev/null \
|| { echo "Missing command 'watchman-make': brew install watchman >&2"; false; }
watchman-make -p pillar.conf template.*.mustache 'css/*' 'latex/*' 'images/*' '*.pillar' -t all
clean : ## Delete intermediate build files
rm -fr $(BUILDIR) pillarPostExport.sh
clobber : clean ## Delete all build files and products
rm -fr $(DESTDIR)
git worktree prune --verbose
prune :
find $(DESTDIR) -mindepth 1 ! -name .git -delete
snapshot : prune all ## Commit a snapshot of the output
$(output-git) add --all
$(output-git) diff --quiet --exit-code --cached \
|| $(output-git) commit --message "Pillar export on $(shell date '+%Y-%m-%d %H:%M:%S')"
deploy : snapshot ## Snapshot and publish to Github Pages
$(output-git) push origin
# Some shell magic to auto-document the main targets
# http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help :
@awk -F ':|##' \
'/^[^\t].+?:.*?##/ {\
printf "\033[36m%-10s\033[0m %s\n", $$1, $$NF \
}' $(MAKEFILE_LIST)