-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
52 lines (40 loc) · 1.22 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
NPMBIN=node_modules/.bin
CFCM=$(NPMBIN)/commonform-commonmark
CFHTML=$(NPMBIN)/commonform-html
CFDOCX=$(NPMBIN)/commonform-docx
JSON=$(NPMBIN)/json
GIT_TAG=$(shell (git diff-index --quiet HEAD && git describe --exact-match --tags 2>/dev/null | sed 's/v//'))
EDITION:=$(or $(EDITION),$(if $(GIT_TAG),$(GIT_TAG),Development Draft))
BUILD=build
TARGETS=$(addprefix $(BUILD)/,terms.html terms.docx terms.pdf)
all: $(TARGETS)
$(BUILD)/%.form.json: %.md | $(BUILD) $(CFCM)
$(CFCM) parse --only form $< > $@
$(BUILD)/%.html: $(BUILD)/%.form.json $(BUILD)/%.title | $(BUILD) $(CFHTML)
$(CFHTML) \
--title "$(shell cat $(BUILD)/$*.title)" \
--edition "$(EDITION)" \
--ids \
--lists \
--html5 \
< $< > $@
$(BUILD)/%.docx: $(BUILD)/%.form.json $(BUILD)/%.title styles.json | $(BUILD) $(CFDOCX)
$(CFDOCX) \
--number outline \
--left-align-title \
--indent-margins \
--title "$(shell cat $(BUILD)/$*.title)" \
--edition "$(EDITION)" \
--styles styles.json \
$< > $@
$(BUILD)/%.title: %.md | $(BUILD) $(CFCM) $(JSON)
$(CFCM) parse < $< | $(JSON) frontMatter.title > $@
$(BUILD)/%.pdf: $(BUILD)/%.docx
unoconv $<
$(BUILD):
mkdir -p $(BUILD)
$(CFCM) $(CFHTML) $(CFDOCX):
npm ci
.PHONY: clean
clean:
rm -rf $(BUILD)