-
Notifications
You must be signed in to change notification settings - Fork 12
/
makefile
67 lines (47 loc) · 2.48 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
SHELL=/bin/bash
OUTFILE=hackpack.pdf
OUTFILE_HTML=hackpack.html
OUTDIR=public
WEBDIR=website
ROOT=/documents/
TEMPLATE=template.latex
FILTER_HTML=filter.py
TEMPLATE_HTML=template.html
WEBTEMPLATE_HTML=website.html
HIGHLIGHT_STYLE=tango
FIND=find.py
SERVE=serve.py
WEBSITE=../website
SITE=
SOURCES!="./$(FIND)" -e 'LICENSE.md' -e 'README.md' -e "$(OUTDIR)" -e "$(WEBDIR)" -f general -f checklists -l appendix -g index.md .
all: $(OUTDIR)/$(OUTFILE)
open: $(OUTDIR)/$(OUTFILE)
which xdg-open >/dev/null 2>&1 && (setsid xdg-open "$(OUTDIR)/$(OUTFILE)" >/dev/null 2>&1 &) || open "$(OUTDIR)/$(OUTFILE)" >/dev/null 2>&1
open-html: $(OUTDIR)/$(OUTFILE_HTML)
which xdg-open >/dev/null 2>&1 && (setsid xdg-open "$(OUTDIR)/$(OUTFILE_HTML)" >/dev/null 2>&1 &) || open "$(OUTDIR)/$(OUTFILE_HTML)" >/dev/null 2>&1
website: $(WEBSITE)$(SITE)$(ROOT)$(OUTFILE) $(WEBSITE)$(SITE)$(ROOT)$(OUTFILE_HTML)
serve: $(OUTDIR)/$(OUTFILE) $(OUTDIR)/$(OUTFILE_HTML)
"./$(SERVE)" "$(OUTDIR)"
update: $(WEBSITE)$(SITE)$(ROOT)$(OUTFILE) $(WEBSITE)$(SITE)$(ROOT)$(OUTFILE_HTML)
git -C "$(WEBSITE)" add ".$(SITE)$(ROOT)$(OUTFILE)" ".$(SITE)$(ROOT)$(OUTFILE_HTML)"
git -C "$(WEBSITE)" commit -m "update hackpack"
git -C "$(WEBSITE)" push
clean:
rm -rf "$(OUTDIR)"
rm -rf "$(WEBDIR)"
$(OUTDIR)/$(OUTFILE): $(SOURCES)
mkdir -p "$(OUTDIR)"
pandoc --template="$(TEMPLATE)" --highlight-style="${HIGHLIGHT_STYLE}" --standalone --toc --output "$(OUTDIR)/$(OUTFILE)" $(SOURCES)
$(OUTDIR)/$(OUTFILE_HTML): $(SOURCES)
mkdir -p "$(OUTDIR)"
pandoc --filter="$(FILTER_HTML)" --template="$(TEMPLATE_HTML)" --highlight-style="${HIGHLIGHT_STYLE}" --standalone --toc --output "$(OUTDIR)/$(OUTFILE_HTML)" --metadata=root:/ --metadata=path:/ --metadata=file:"$(OUTFILE_HTML)" $(SOURCES)
$(WEBDIR)$(ROOT)$(OUTFILE_HTML): $(SOURCES)
mkdir -p "$(WEBDIR)$(ROOT)"
pandoc --filter="$(FILTER_HTML)" --template="$(WEBTEMPLATE_HTML)" --highlight-style="${HIGHLIGHT_STYLE}" --standalone --toc --output "$(WEBDIR)$(ROOT)$(OUTFILE_HTML)" --metadata=root:"$(ROOT)" --metadata=path:"$$(dirname "$(ROOT)$(OUTFILE_HTML)")" --metadata=file:"$(ROOT)$(OUTFILE_HTML)" $(SOURCES)
$(WEBSITE)$(SITE)$(ROOT)$(OUTFILE): $(OUTDIR)/$(OUTFILE)
mkdir -p "$(WEBSITE)$(SITE)$(ROOT)"
cp "$(OUTDIR)/$(OUTFILE)" "$(WEBSITE)$(SITE)$(ROOT)$(OUTFILE)"
$(WEBSITE)$(SITE)$(ROOT)$(OUTFILE_HTML): $(WEBDIR)$(ROOT)$(OUTFILE_HTML)
mkdir -p "$(WEBSITE)$(SITE)$(ROOT)"
cp "$(WEBDIR)$(ROOT)$(OUTFILE_HTML)" "$(WEBSITE)$(SITE)$(ROOT)$(OUTFILE_HTML)"
.PHONY: all open open-html serve update clean