~jzck/physics-notes

ref: 1a061c9fbe824a468f6aa9652a43b43771af8b78 physics-notes/Makefile -rw-r--r-- 1.0 KiB
1a061c9fJack Halford first commit 1 year, 5 months ago
                                                                                
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
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.RECIPEPREFIX = >

MD	=	$(shell ls -1 md/*.md)
GRAPH	=	$(subst md/,graph/,$(MD))
REFS	=	$(subst md/,external_refs/,$(MD))
HTML	=	$(subst md/,html/,$(MD:.md=.html))

all: $(HTML) html/colors.css html/graph.svg $(REFS)

html/%.html: md/%.md external_refs/%.md
> @mkdir -p html
> @pandoc	--filter tools/pf-filter.py \
		-H tools/header.html \
		--template tools/template.html \
		--mathjax -f markdown \
		tools/latex-includes.yaml \
		$^ -o $@ &
> @printf '$@\n'

external_refs/%.md: graph/%.md
> @mkdir -p external_refs
> @[ -s $^ ] && echo '## See also' > $@
> @awk '{printf "- [%s](%s)\n", $$1, $$1;}' $^>>$@

graph/%.md: md/%.md
> @mkdir -p graph
> @grep $(notdir $@) md/*.md | awk -F: '{print $$1}' | uniq | sed s:md/::g | grep -v lexicon > $@ || true

html/graph.svg: $(GRAPH)
> dot -Tsvg -o $@ <(./tools/generate-graph.sh)

html/colors.css: tools/colors
> ./tools/generate-bg-css.sh >$@

clean:
> rm -rf html graph external_refs

re: clean all

.PHONY: clean all re