forked from httpwg/http2-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (97 loc) · 3.33 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
xml2rfc ?= "xml2rfc"
saxpath ?= "lib/saxon9.jar"
saxon ?= java -classpath $(saxpath) net.sf.saxon.Transform -novw -l
kramdown2629 ?= kramdown-rfc2629
names := http2 header-compression
drafts := $(addprefix draft-ietf-httpbis-,$(names))
last_tag = $(shell git tag | grep "$(draft)-[0-9][0-9]" | 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 := index compression
FRIENDLY := $(addsuffix .txt,$(friendly_names)) \
$(addsuffix .html,$(friendly_names))
.PHONY: latest submit idnits clean issues $(names) hpack
.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)))
hpack: header-compression
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))
index.%: draft-ietf-httpbis-http2.%
cp -f $< $@
compression.%: draft-ietf-httpbis-header-compression.%
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 '/DOCTYPE/,/>/d' > $@
$(addsuffix .txt,$(next)): %.txt: %.xml
$(xml2rfc) $< $@
%.txt: %.redxml
$(xml2rfc) $< $@
stylesheet := lib/myxml2rfc.xslt
extra_css := lib/style.css
%.html: %.xml $(stylesheet) $(extra_css)
$(saxon) $< $(stylesheet) | sed -f lib/addstyle.sed > $@
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 :=
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 https://github.com/$(TRAVIS_REPO_SLUG).git gh-pages
@git push https://$(GH_TOKEN)@github.com/$(TRAVIS_REPO_SLUG).git gh-pages
endif
-git checkout -qf "$(GIT_ORIG)"
-rm -rf $(GHPAGES_TMP)
endif
# backup issues
issues:
curl https://api.github.com/repos/http2/http2-spec/issues?state=open > issues.json