forked from httpwg/http-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
164 lines (127 loc) · 4.85 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
xml2rfc ?= "xml2rfc"
saxpath ?= "lib/saxon9.jar"
saxon ?= java -classpath $(saxpath) net.sf.saxon.Transform -l
kramdown2629 ?= XML_RESOURCE_ORG_PREFIX=https://xml2rfc.tools.ietf.org/public/rfc kramdown-rfc2629
names := http2-encryption rfc5987bis rfc6265bis key client-hints encryption-encoding cookie-prefixes cookie-alone origin-frame cookie-same-site cache-digest header-structure immutable expect-ct early-hints rand-access-live
drafts := $(addprefix draft-ietf-httpbis-,$(names))
last_tag = $(shell git tag | grep "$(draft)" | sort | tail -1 | awk -F- '{print $$NF}')
next_ver = $(if $(last_tag),$(shell printf "%.2d" $$(( 1$(last_tag) - 99)) ),00)
next := $(foreach draft, $(drafts), $(draft)-$(next_ver))
TARGETS := $(addsuffix .txt,$(drafts)) \
$(addsuffix .html,$(drafts))
friendly_names := opsec rfc5987bis rfc6265bis key client-hints encryption-encoding cookie-prefixes cookie-alone origin-frame cookie-same-site cache-digest header-structure immutable expect-ct early-hints rand-access-live
FRIENDLY := $(addsuffix .txt,$(friendly_names)) \
$(addsuffix .html,$(friendly_names))
.PHONY: latest submit idnits clean issues.json $(names)
.INTERMEDIATE: $(addsuffix .redxml,$(drafts))
.PRECIOUS: $(TARGETS)
latest: $(TARGETS)
# build rules for specific targets
makerule = $(join $(addsuffix :: ,$(names)),$(addsuffix .$(1),$(drafts)))
$(foreach rule,$(call makerule,txt) $(call makerule,html),$(eval $(rule)))
submit: $(addsuffix .txt,$(next))
idnits: $(addsuffix .txt,$(next))
idnits $<
clean:
-rm -f $(addsuffix .redxml,$(drafts))
-rm -f $(addsuffix *.txt,$(drafts))
-rm -f $(addsuffix *-[0-9][0-9].xml,$(drafts))
-rm -f $(addsuffix *.html,$(drafts))
opsec.%: draft-ietf-httpbis-http2-encryption.%
cp -f $< $@
rfc5987bis.%: draft-ietf-httpbis-rfc5987bis.%
cp -f $< $@
rfc6265bis.%: draft-ietf-httpbis-rfc6265bis.%
cp -f $< $@
key.%: draft-ietf-httpbis-key.%
cp -f $< $@
client-hints.%: draft-ietf-httpbis-client-hints.%
cp -f $< $@
encryption-encoding.%: draft-ietf-httpbis-encryption-encoding.%
cp -f $< $@
cookie-prefixes.%: draft-ietf-httpbis-cookie-prefixes.%
cp -f $< $@
cookie-alone.%: draft-ietf-httpbis-cookie-alone.%
cp -f $< $@
origin-frame.%: draft-ietf-httpbis-origin-frame.%
cp -f $< $@
cookie-same-site.%: draft-ietf-httpbis-cookie-same-site.%
cp -f $< $@
cache-digest.%: draft-ietf-httpbis-cache-digest.%
cp -f $< $@
header-structure.%: draft-ietf-httpbis-header-structure.%
cp -f $< $@
immutable.%: draft-ietf-httpbis-immutable.%
cp -f $< $@
expect-ct.%: draft-ietf-httpbis-expect-ct.%
cp -f $< $@
early-hints.%: draft-ietf-httpbis-early-hints.%
cp -f $< $@
rand-access-live.%: draft-ietf-httpbis-rand-access-live.%
cp -f $< $@
define makerule_submit_xml =
$(1)
sed -e"s/$$(basename $$<)-latest/$$(basename $$@)/" $$< > $$@
endef
submit_deps := $(join $(addsuffix .xml: ,$(next)),$(addsuffix .redxml,$(drafts)))
$(foreach rule,$(submit_deps),$(eval $(call makerule_submit_xml,$(rule))))
%.xml: %.md
$(kramdown2629) $< | sed -e 's/\"rfc2629.dtd\"/\"lib\/rfc2629.dtd\"/' > $@
$(addsuffix .txt,$(next)): %.txt: %.xml
$(xml2rfc) $< $@
draft-ietf-httpbis-rand-access-live.txt: draft-ietf-httpbis-rand-access-live.xml
$(xml2rfc) --text draft-ietf-httpbis-rand-access-live.xml
%.txt: %.redxml
$(xml2rfc) $< $@
draft-ietf-httpbis-rand-access-live.html: draft-ietf-httpbis-rand-access-live.xml
$(xml2rfc) --html draft-ietf-httpbis-rand-access-live.xml
stylesheet := lib/rfcbootstrap.xslt
%.html: %.xml $(stylesheet) $(extra_css)
$(saxon) $< $(stylesheet) > $@
reduction := lib/clean-for-DTD.xslt
%.redxml: %.xml $(reduction)
$(saxon) $< $(reduction) > $@
%.xhtml: %.xml ../../rfc2629xslt/rfc2629toXHTML.xslt
$(saxon) $< ../../rfc2629xslt/rfc2629toXHTML.xslt > $@
GHPAGES_TMP := /tmp/ghpages$(shell echo $$$$)
.TRANSIENT: $(GHPAGES_TMP)
ifeq (,$(TRAVIS_COMMIT))
GIT_ORIG := $(shell git branch | grep '*' | cut -c 3-)
else
GIT_ORIG := $(TRAVIS_COMMIT)
endif
IS_LOCAL := $(if $(TRAVIS),true,)
ifeq (master,$(TRAVIS_BRANCH))
IS_MASTER := $(findstring false,$(TRAVIS_PULL_REQUEST))
else
IS_MASTER := true
endif
ghpages: $(FRIENDLY) $(TARGETS)
ifneq (,$(or $(IS_LOCAL),$(IS_MASTER)))
mkdir $(GHPAGES_TMP)
cp -f $^ $(GHPAGES_TMP)
git clean -qfdX
ifeq (true,$(TRAVIS))
git config user.email "[email protected]"
git config user.name "Travis CI Builder"
git checkout -q --orphan gh-pages
git rm -qr --cached .
git clean -qfd
git pull -qf origin gh-pages --depth=5
else
git checkout gh-pages
git pull
endif
mv -f $(GHPAGES_TMP)/* $(CURDIR)
git add $^
if test `git status -s | wc -l` -gt 0; then git commit -m "Script updating gh-pages."; fi
ifneq (,$(GH_TOKEN))
@echo git push -q https://github.com/$(TRAVIS_REPO_SLUG).git gh-pages
@git push -q https://$(GH_TOKEN)@github.com/$(TRAVIS_REPO_SLUG).git gh-pages >/dev/null 2>&1
endif
-git checkout -qf "$(GIT_ORIG)"
-rm -rf $(GHPAGES_TMP)
endif
# backup issues
issues.json:
python lib/fetch-issues.py > issues.json