-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
132 lines (95 loc) · 4.04 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
version := $(shell python id2xml/run.py --version | awk '{print $$2}' )
testfiles= \
draft-baba-iot-problems-03.txt \
draft-ietf-6man-rfc2460bis-11.txt \
draft-ietf-curdle-cms-eddsa-signatures-05.txt \
draft-ietf-httpbis-header-structure-01.txt \
draft-ietf-i2nsf-client-facing-interface-req-01.txt \
draft-ietf-mip4-multiple-tunnel-support-07.txt \
draft-ietf-netmod-revised-datastores-02.txt \
draft-ietf-ospf-encapsulation-cap-02.txt \
draft-ietf-perc-dtls-tunnel-01.txt \
draft-ietf-sipcore-name-addr-guidance-01.txt \
draft-jones-cose-rsa-03.txt \
draft-miek-test.txt \
draft-sparks-genarea-review-tracker-03.txt \
rfc5661.txt \
rfc7629.txt \
rfc7752.txt \
rfc7842.txt \
# draft-ietf-curdle-cms-ecdh-new-curves-07.txt is a modified copy, with
# some reference fixes
textfiles= $(addprefix test/in/, $(testfiles))
resfiles = $(addprefix test/out/, $(testfiles))
okfiles = $(addprefix test/ok/, $(testfiles))
origxml = $(addsuffix .xml, $(basename $(okfiles)))
xmlfiles = $(addsuffix .xml, $(basename $(resfiles)))
xml3files= $(addsuffix .v3.xml, $(basename $(resfiles)))
diffiles = $(addsuffix .diff, $(basename $(resfiles)))
tests = $(addsuffix .test, $(basename $(resfiles)))
pyfiles = $(wildcard id2xml/*.py)
all: install upload
%.1: id2xml/run.py id2xml/__init__.py Makefile
id2xml -h | sed -e 's/^ -/\n -/' \
| sed -e '/^ -/N;s/\n */ /' \
| txt2man -s1 -r'RFC Format Tools' -t $< > $@
%.1.gz: %.1
gzip < $< > $@
pyflakes:
pyflakes id2xml
install: id2xml/id2xml.1.gz
python setup.py -q install
env/bin/id2xml: $(pyfiles) setup.py
python setup.py -q install
# ------------------------------------------------------------------------
# specials
.PRECIOUS: $(xmlfiles)
# ------------------------------------------------------------------------
# test
test: env/bin/id2xml clean $(resfiles) $(xml3files) $(diffiles) $(tests)
.PHONY: clean
clean:
rm -f test/out/*
infiles: $(textfiles)
origxml: $(origxml)
test/in/draft-%.txt:
wget -q -N -P test/in/ https://tools.ietf.org/id/$(notdir $@)
test/ok/%.xml:
wget -q -N -P test/ok/ https://tools.ietf.org/id/$(notdir $@) || true
test/in/rfc%.txt:
wget -q -N -P test/in/ https://tools.ietf.org/rfc/$(notdir $@)
test/out/%.test: test/ok/%.diff test/out/%.diff
# cp $(word 2,$^) $(word 1,$^)
@oklen=`grep '^<' $(word 1,$^) | wc -l`; outlen=`grep '^<' $(word 2,$^) | wc -l`; \
totlen=`wc -l < test/in/$(basename $(@F)).txt`; \
ratio=$$(( outlen * 100 / totlen )); \
if [ $$oklen -gt $$outlen ]; then gain=-$$(( oklen - outlen )); else gain=''; fi; \
printf "Changed now/ok: %-48s %2s%% %4s /%4s %4s\n" $(basename $(@F)) $$ratio $$outlen $$oklen $$gain; \
test $$oklen -ge $$outlen || { echo " *** failed ***"; } \
# test $$oklen -ge $$outlen || { diff -y $^ | less; }
test/in/%.raw: test/in/%.txt
id2xml --strip-only $< -o - | sed -r -e '/[Tt]able [Oo]f [Cc]ontents?/,/^[0-9]+\./d' -e 's|<http://www.rfc-editor.org/|<https://www.rfc-editor.org/|' > $@
test/out/%.raw: test/out/%.txt
id2xml --strip-only $< -o - | sed -r -e '/[Tt]able [Oo]f [Cc]ontents?/,/^[0-9]+\./d' > $@
test/out/%.diff: test/in/%.raw test/out/%.raw
diff $(word 1,$^) $(word 2,$^) > $@ || true
test/out/%.txt: test/out/%.xml
xml2rfc --legacy $< -o $@
test/out/%.xml: test/in/%.txt $(pyfiles)
@echo ""
id2xml $< -o $@
test/out/%.v3.xml: test/in/%.txt $(pyfiles)
@echo ""
id2xml -3 $< -o $@
# ------------------------------------------------------------------------
dist/id2xml-$(version).tar.gz: MANIFEST.in setup.py $(pyfiles)
python setup.py -q sdist
dist/id2xml-$(version)-py27-none-any.whl: MANIFEST.in setup.py $(pyfiles)
python setup.py -q bdist_wheel --python-tag py27
dist/%.asc: dist/%
gpg --detach-sign -a $<
sdist: dist/id2xml-$(version).tar.gz dist/id2xml-$(version).tar.gz.asc
bdist_wheel: dist/id2xml-$(version)-py27-none-any.whl dist/id2xml-$(version)-py27-none-any.whl.asc
dist: test sdist # bdist_wheel
upload: install test dist
twine upload dist/id2xml-$(version).tar.gz dist/id2xml-$(version).tar.gz.asc -r pypi