-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
67 lines (52 loc) · 2.24 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
OUTDIR=website
SERVEDIR=public
ROOT=/wiki/
FILTER=filter.py
TEMPLATE=template.html
SERVETEMPLATE=serve.html
REPO=https://github.com/CUCyber/wiki
HIGHLIGHT_STYLE=tango
SERVE=serve.py
WEBSITE=../website
SITE=
SOURCES!=find * \( -path '__pycache__' -o -path "$(OUTDIR)" -o -path "$(SERVEDIR)" -o -path "$(FILTER)" -o -path "$(TEMPLATE)" -o -path "$(SERVETEMPLATE)" -o -path "$(SERVE)" \) -prune -o -type f -a -not \( -name 'makefile' -o -name 'LICENSE.md' -o -name 'README.md' \) -print
all: $(OUTDIR)$(ROOT)
website: $(WEBSITE)$(SITE)$(ROOT)
serve: $(SERVEDIR)$(ROOT)
"./$(SERVE)" "$(SERVEDIR)"
update: $(WEBSITE)$(SITE)$(ROOT)
git -C "$(WEBSITE)" add ".$(SITE)$(ROOT)"
git -C "$(WEBSITE)" commit -m "update wiki"
git -C "$(WEBSITE)" push
clean:
rm -rf "$(OUTDIR)"
rm -rf "$(SERVEDIR)"
$(OUTDIR)$(ROOT): $(SOURCES)
mkdir -p $(OUTDIR)$(ROOT)
for file in $?; do \
rm -rf "$(OUTDIR)$(ROOT)$${file%.md}"; \
mkdir -p $$(dirname "$(OUTDIR)$(ROOT)$${file}"); \
if [ "$${file: -3}" == .md ]; then \
env FILTER_URL_EXTENSION='' pandoc --filter="$(FILTER)" --template="$(TEMPLATE)" --highlight-style="${HIGHLIGHT_STYLE}" --standalone --toc --output "$(OUTDIR)$(ROOT)$${file%.md}.html" --metadata=root:"$(ROOT)" --metadata=path:"$$(dirname "$$file" | sed -e 's/^\.$$//')" --metadata=file:"$${file%.md}" --metadata=repo:"$(REPO)" "$${file}"; \
else \
cp "$${file}" "$(OUTDIR)$(ROOT)$${file}"; \
fi \
done
touch "$(OUTDIR)$(ROOT)"
$(SERVEDIR)$(ROOT): $(SOURCES)
mkdir -p $(SERVEDIR)$(ROOT)
for file in $?; do \
rm -rf "$(SERVEDIR)$(ROOT)$${file%.md}"; \
mkdir -p $$(dirname "$(SERVEDIR)$(ROOT)$${file}"); \
if [ "$${file: -3}" == .md ]; then \
pandoc --filter="$(FILTER)" --template="$(SERVETEMPLATE)" --highlight-style="${HIGHLIGHT_STYLE}" --standalone --toc --output "$(SERVEDIR)$(ROOT)$${file%.md}.html" --metadata=root:"$(ROOT)" --metadata=path:"$$(dirname "$$file" | sed -e 's/^\.$$//')" --metadata=file:"$${file%.md}" --metadata=repo:"$(REPO)" "$${file}"; \
else \
cp "$${file}" "$(SERVEDIR)$(ROOT)$${file}"; \
fi \
done
touch "$(SERVEDIR)$(ROOT)"
$(WEBSITE)$(SITE)$(ROOT): $(OUTDIR)$(ROOT)
rsync -av --delete "$(OUTDIR)$(ROOT)" "$(WEBSITE)$(SITE)$(ROOT)"
touch "$(WEBSITE)$(SITE)$(ROOT)"
.PHONY: all website serve update clean