-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
118 lines (87 loc) · 2.83 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
IDR_NW := $(wildcard src/idris/*.nw)
IDR := ${IDR_NW:.nw=.idr}
IDR_HTML := ${IDR_NW:.nw=.html}
IDR_TEX := ${IDR_NW:.nw=.tex}
IDR_PDF := ${IDR_NW:.nw=.pdf}
IDR_SRCS := ${IDR} ${IDR_TEX} ${IDR_PDF} ${IDR_HTML}
IDR_DOCS := $(patsubst src/%,docs/%,${IDR_HTML} ${IDR_PDF})
IDR_ALL := ${IDR_SRCS} ${IDR_DOCS}
ERL_NW := $(wildcard src/erlang/*.nw)
ERL := ${ERL_NW:.nw=.erl}
# ERL_HTML := ${ERL_NW:.nw=.html}
ERL_TEX := ${ERL_NW:.nw=.tex}
ERL_PDF := ${ERL_NW:.nw=.pdf}
ERL_SRCS := ${ERL} ${ERL_TEX} ${ERL_PDF} # ${ERL_HTML}
# ERL_DOCS := $(patsubst src/%,docs/%,${ERL_HTML} ${ERL_PDF})
ERL_DOCS := $(patsubst src/%,docs/%,${ERL_PDF})
ERL_ALL := ${ERL_SRCS} ${ERL_DOCS}
# http://stackoverflow.com/a/17807510
dirname = $(patsubst %/,%,$(dir $1))
tangle = notangle -R'$(basename $(notdir $<))' -filter btdefn $< >$@
define subtree_pull =
git fetch $@ master
git subtree pull --prefix $@ $@ master --squash
endef
define subtree_pdf =
$(call subtree_pull)
ln -f $@/docs/$@.pdf docs/
$(call add_docs_amend)
endef
define subtree_dir =
$(call subtree_pull)
mkdir -p docs/$@
ln -f $@/docs/*.pdf docs/$@/
$(call add_docs_amend)
endef
define add_docs_amend =
git add docs
git commit --amend --no-edit
endef
.SUFFIXES: .nw .erl .idr .html .lisp .pdf .tex
.nw.erl: ; ${tangle}
.nw.idr: ; ${tangle}
.nw.lisp: ; ${tangle}
# NOTE: requires latex2html
.nw.html: ; noweave -filter btdefn -filter l2h -index -html $< >$@
.nw.tex: ; noweave -filter btdefn -n -delay -index $< >$@
.tex.pdf: ; latexmk --shell-escape -pdf -outdir=$(call dirname,$<) $<
all: aaig lol pandoc-minted idris erlang paip docs/index.html
.PHONY: idris erlang paip aaig lol pandoc-minted
idris: ${IDR_ALL}
erlang: ${ERL_ALL}
paip:
@ ${MAKE} -C $@
@ ln -f $@/tex/$@.pdf docs/
# git remote add -f aaig git@github.com:yurrriq/abstract-algebra-in-gap.git
# git subtree add --prefix aaig aaig master --squash
aaig:
$(call subtree_pdf)
# git remote add -f eunix git@github.com:yurrriq/eunix.git
# git subtree add --prefix eunix eunix master --squash
eunix:
$(call subtree_dir)
# git remote add -f lol git@github.com:yurrriq/land-of-lisp.git
# git subtree add --prefix lol lol master --squash
lol:
$(call subtree_dir)
# git remote add -f pandoc-minted git@github.com:yurrriq/pandoc-minted.git
# git subtree add --prefix pandoc-minted pandoc-minted master --squash
pandoc-minted:
$(call subtree_pdf)
docs/index.html: README.md
pandoc -f markdown_github -t html5 -s $< -o $@
docs/%.html: src/%.html
@ mkdir -p $(dir $@)
@ mv $< $@
docs/%.pdf: src/%.pdf
@ mkdir -p $(dir $@)
@ mv $< $@
.PHONY: clean clean-docs clobber
clean_keep_regex := '.*.[bib|erl|idr|lisp|nw|tex]'
clean:
@ find src -type f \! -regex ${clean_keep_regex} -delete
clean-docs:
@ rm -fr docs
clobber_keep_regex := '.*.[bib|nw]'
clobber:
@ find src -type f \! -regex ${clobber_keep_reges} -delete