-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
120 lines (87 loc) · 2.82 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
# Original makefile from https://github.com/martinthomson/i-d-template
# Edited by wkumari to remove a bunch of the extra stuff I'll never use.
# The following tools are used by this file.
# All are assumed to be on the path, but you can override these
# in the environment, or command line.
# Mandatory:
# https://pypi.python.org/pypi/xml2rfc
xml2rfc ?= xml2rfc
# For sanity checkout your draft:
# https://tools.ietf.org/tools/idnits/
idnits ?= idnits
# For diff:
# https://tools.ietf.org/tools/rfcdiff/
rfcdiff ?= rfcdiff --browse
# For generating PDF:
# https://www.gnu.org/software/enscript/
enscript ?= enscript
# http://www.ghostscript.com/
ps2pdf ?= ps2pdf
## Work out what to build
draft := $(basename $(lastword $(sort $(wildcard draft-*.xml)) $(sort $(wildcard draft-*.org)) $(sort $(wildcard draft-*.md))))
ifeq (,$(draft))
$(warning No file named draft-*.md or draft-*.xml or draft-*.org)
$(error Read README.md for setup instructions)
endif
draft_type := $(suffix $(firstword $(wildcard $(draft).md $(draft).org $(draft).xml)))
## Targets
default:
@echo
@echo "Useful targets:"
@echo " txt: The Text version of the draft"
@echo " commit: Creates README.md, commits (ci) and pushes the changes to git"
@echo " tag: Lists current tags, gets anew one, commits and pushed to git"
@echo " diff: Unsurprisingly, the diff..."
@echo " README.md: Makes the README.md"
@echo
.PHONY: latest txt html pdf submit diff clean update ghpages
latest: txt html
txt: $(draft).txt
html: $(draft).html
pdf: $(draft).pdf
idnits: $(draft).txt
$(idnits) $<
clean:
-rm -f $(draft).{txt,html,pdf} index.html
-rm -f $(draft)-[0-9][0-9].{xml,md,org,txt,html,pdf}
-rm -f *.diff.html
ifneq (.xml,$(draft_type))
-rm -f $(draft).xml
endif
## diff
diff:
git diff $(draft).xml
README.md: $(draft).txt
@echo "Making README.md"
@echo '**Important:** Read CONTRIBUTING.md before submitting feedback or contributing' > README.md
@echo \`\`\` >> README.md
@cat $(draft).txt >> README.md
@echo \`\`\` >> README.md
commit: $(draft).txt README.md
@echo "Making README.md and committing and pushing to github. Run 'make tag' to add and push a tag."
@echo '**Important:** Read CONTRIBUTING.md before submitting feedback or contributing' > README.md
@echo \`\`\` >> README.md
@cat $(draft).txt >> README.md
@echo \`\`\` >> README.md
read -p "Commit message: " msg; \
git commit -a -m "$$msg";
@git push
tag:
@echo "Current tags:"
git tag
@echo
@read -p "Tag message (e.g: Version-00): " tag; \
git tag -a $$tag -m $$tag
@git push --tags
## Recipes
.INTERMEDIATE: $(draft).xml
%.xml: %.md
$(kramdown-rfc2629) $< > $@
%.xml: %.org
$(oxtradoc) -m outline-to-xml -n "$@" $< > $@
%.txt: %.xml
$(xml2rfc) $< -o $@ --text
%.html: %.xml
$(xml2rfc) $< -o $@ --html
%.pdf: %.txt
$(enscript) --margins 76::76: -B -q -p - $^ | $(ps2pdf) - $@