-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile.common
159 lines (111 loc) · 5.31 KB
/
Makefile.common
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
# ----------------------------------------------------------------------
# Generic
# ----------------------------------------------------------------------
# tool should be set in the tool-specific Makefile, which should include this
tool ?= $(shell basename $(PWD))
version := $(shell ./$(tool) --version | awk '{print $$2}' )
thisver := $(version)
prevver := $(shell if [ -d ./archive ]; then ls -d ./archive/$(tool)* | grep -v ".tgz" | grep -v "$(version)" | tail -n 1 | sed 's/.*$(tool)-v//'; else echo "0.00"; fi )
language:= $(shell head -1 $(tool) | awk '{ sub("^.+/", "", $$1); print $$1; }')
logentry := $(shell sed -n -r "/^$(tool) \($(version).*\)/,/^ -- /p" changelog | head -n -1 | sed -r 's/"/\\"/g' )
# Sources
sources += $(tool) copyright control.in changelog Makefile Makefile.common
# Webpages
webpages += index.shtml code.shtml copyright.shtml changelog.shtml
# Additional scripts
scripts +=
binaries +=
# Install directory
prefix := /usr/local
# ----------------------------------------------------------------------
# Set up for make in separate build directory
VPATH = archive build
# ----------------------------------------------------------------------
# This is what we want to make:
all: setup manpage changelog package binaries
# ----------------------------------------------------------------------
setup: build archive $(tool)-v0.00
build:
[ -d build ] || mkdir build
archive:
[ -d archive ] || mkdir archive;
$(tool)-v0.00:
touch archive/$@
# ----------------------------------------------------------------------
manpage: $(tool).1.gz
%.1: %.1.txt
txt2man $< > $@
%.1: %
./$(tool) --help | txt2man -t "$(tool) 1" > $@
%.gz: %
gzip -f $< -c > $@
# ----------------------------------------------------------------------
diff: build/$(tool)-$(version).diff.html
build/$(tool)-$(thisver).diff.html: $(tool)-v$(prevver) $(tool)
rfcdiff --width 82 $^ $@
# ----------------------------------------------------------------------
binaries: $(binaries)
# ----------------------------------------------------------------------
test::
# Test suite
# ----------------------------------------------------------------------
package: test archive archive/$(tool)-$(version).tgz archive/$(tool)-v$(version)
archive/$(tool)-$(version).tgz: $(sources) control
mkdir -p $(tool)-$(version)
cp -p $^ $(tool)-$(version)/
tar czf $@ $(tool)-$(version)
rm -rf $(tool)-$(version)
archive/$(tool)-v$(version): $(tool)
cp $< $@
control: control.in $(tool) changelog
sed -r -e 's/^Version:.*/Version: $(version)/' -e "s/^Date:.*/Date: $$(date +'%Y-%m-%d %H:%M:%S')/" $< > $@
packagetest: archive/$(tool)-$(version).tgz
cd archive && tar xzf archive/$(tool)-$(version).tgz
cd archive/$(tool)-$(version)/ && make
# ----------------------------------------------------------------------
webpages: $(webpages:%=build/%)
build/%.shtml: ./%.shtml.frag control template.shtml.pyht
pyht template.shtml.pyht view=$< > $@
build/%.shtml: %.shtml.frag control template.shtml.pyht
pyht template.shtml.pyht view=$< > $@
build/%.shtml: build/%.html control template.shtml.pyht
pyht template.shtml.pyht view=$< > $@
build/%.shtml: ../%.shtml
cp -p $< $@
build/%.html: %
rst2html $< > $@
build/code.html: $(tool)
highlight --style-infile ../highlight.css --syntax $(language) --include-style --quiet $< > $@
build/about.html: $(tool).1.gz
man -l $< | head -n -1 | tail -n +2 | rst2html > $@
build/index.html: $(tool).1.gz
man2html -r $< | sed -n -r -e '/<H2>NAME/,/<HR>/p' > $@
build/changelog.html: changelog
cat $< | sed -r -e 's!$(tool) *\(([0-9.-]+)\)!`\1 </tools/$(tool)/$(tool)-v\1>`_ (`diff-\1 </tools/$(tool)/$(tool)-\1.diff.html>`_)!' -e 's/^ --(.*)$$/ (\1)/' > [email protected]
rst2html [email protected] > $@
# ----------------------------------------------------------------------
build/%.pyht: %.py.frag control template.shtml.pyht
pyht template.shtml.pyht view=$< | sed -r -e 's/<!-- *#include +virtual=/<?python\n\t virtualinc(/' -e 's/" +-->/")\n\t?>/' > $@
# ----------------------------------------------------------------------
commit: diff
@if [ ! "$(logentry)" ]; then echo "Missing changelog entry!"; exit 1; fi
sed -r -i -e "1,/^ -- /s/([A-Za-z-]+ <[a-z0-9.-]+@[a-z0-9.-]+> ).*$$/\1$$(date +'%d %b %Y %H:%M:%S %z')/" changelog
sv commit -m"$(logentry)"
[ -d .svn ] && svn commit -m"$(logentry)" || true
# ----------------------------------------------------------------------
distinfo: $(tool)-$(version).tgz diff
[ -f $@ ] || touch $@
if grep "$<" $@; then echo "Version $(version) has already been uploaded"; exit 1; fi
md5sum $< | awk '{ printf "MD5 (%s) = %s\n", $$2, $$1; }' >> $@
sha256sum $< | awk '{ printf "SHA256 (%s) = %s\n", $$2, $$1; }' >> $@
wc -c $< | awk '{ printf "SIZE (%s) = %s\n", $$2, $$1; }' >> $@
release:: $(tool) $(tool)-v$(version) $(tool)-$(version).tgz $(tool)-$(version).diff.html $(scripts) control distinfo
echo "Made release $(version)"
upload:: $(tool) $(tool)-v$(version) $(webpages) $(tool)-$(version).tgz $(tool)-$(version).diff.html $(scripts) control distinfo
rsync -avuz --exclude /tmp/ $^ /www/tools.ietf.org/tools/$(tool)/
toolpush /www/tools.ietf.org/tools/$(tool)/
toolsfeed control changelog /www/tools.ietf.org/tools/atomfeed.xml
toolpush /www/tools.ietf.org/tools/atomfeed.xml
install:: $(tool) $(tool).1.gz
sudo install $(tool) $(prefix)/bin
sudo install -m 644 $(tool).1.gz /usr/share/man/man1/