forked from mpark/wg21
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (45 loc) · 1.61 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
SRCDIR ?= .
OUTDIR ?= generated
DEFAULTS ?= $(wildcard $(SRCDIR)/defaults.yaml)
METADATA ?= $(wildcard $(SRCDIR)/metadata.yaml)
override DATADIR := $(dir $(lastword $(MAKEFILE_LIST)))data
override SRC := $(filter-out %/README.md, $(wildcard $(SRCDIR)/*.md))
override HTML := $(SRC:.md=.html)
override LATEX := $(SRC:.md=.latex)
override PDF := $(SRC:.md=.pdf)
override define PANDOC
$(eval override FILE := $(filter %.md, $^))
$(eval override CMD := pandoc $(FILE) -o $@ -d $(DATADIR)/defaults.yaml)
$(eval $(and $(DEFAULTS), override CMD += -d $(DEFAULTS)))
$(eval $(and $(METADATA), override CMD += --metadata-file $(METADATA)))
$(if $(filter %.html, $@),
$(eval override TOCDEPTH := $(shell $(DATADIR)/toc-depth.py < $(FILE)))
$(eval $(and $(TOCDEPTH), override CMD += --toc-depth $(TOCDEPTH))))
$(CMD)
endef
override DEPS := $(addprefix $(DATADIR)/, defaults.yaml index.yaml annex-f)
$(eval $(and $(DEFAULTS), override DEPS += $(DEFAULTS)))
$(eval $(and $(METADATA), override DEPS += $(METADATA)))
.PHONY: all
all: $(PDF)
ifneq ($(SRCDIR), $(OUTDIR))
.PHONY: clean
clean:
rm -rf $(OUTDIR)
.PHONY: $(HTML) $(LATEX) $(PDF)
$(HTML) $(LATEX) $(PDF): $(SRCDIR)/%: $(OUTDIR)/%
endif
.PHONY: update
update:
@$(MAKE) --always-make $(DATADIR)/index.yaml $(DATADIR)/annex-f
$(OUTDIR):
mkdir -p $@
$(DATADIR)/defaults.yaml: $(DATADIR)/defaults.py
$< > $@
$(DATADIR)/index.yaml:
wget https://wg21.link/index.yaml -O $@
$(DATADIR)/annex-f:
wget https://timsong-cpp.github.io/cppwp/annex-f -O $@
$(OUTDIR)/%.html $(OUTDIR)/%.latex $(OUTDIR)/%.pdf: $(DEPS) $(SRCDIR)/%.md | $(OUTDIR)
$(PANDOC) \
--bibliography $(DATADIR)/index.yaml