summaryrefslogtreecommitdiff
path: root/Makefile
blob: 1ad0e77f65dbf976b0be1fe1f4ac4340b5043fff (plain)
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
all:

GIT = git
GZIP = gzip
TAR = tar
XSLTPROC = xsltproc --xinclude --nonet
CANONXML = xmllint --nsclean --noblanks --c14n --nonet
XML_LINEBREAKS = perl -pe 's/>/>\n/g'
DROP_NAMESPACE = perl -pe '$$hash = chr(35); s{xmlns:tp="http://telepathy\.freedesktop\.org/wiki/DbusSpec$${hash}extensions-v0"}{}g'
RST2HTML = rst2html
PYTHON = python

XMLS = $(wildcard spec/*.xml)
TEMPLATES = $(wildcard doc/templates/*)
INTERFACE_XMLS = $(filter spec/[[:upper:]]%.xml,$(XMLS))
INTROSPECT = $(INTERFACE_XMLS:spec/%.xml=introspect/%.xml)
ASYNC_INTROSPECT = $(INTERFACE_XMLS:spec/%.xml=introspect/async/%.xml)
CANONICAL_NAMES = $(INTERFACE_XMLS:spec/%.xml=tmp/%.name)

$(CANONICAL_NAMES): tmp/%.name: spec/%.xml tools/extract-nodename.py
	@install -d tmp
	python tools/extract-nodename.py $< > $@
	tr a-z A-Z < $@ > $@.upper
	tr A-Z a-z < $@ > $@.lower
	tr -d _ < $@ > $@.camel

TEST_XMLS = $(wildcard test/input/*.xml)
TEST_INTERFACE_XMLS = test/input/_Test.xml
TEST_INTROSPECT = test/output/_Test.introspect.xml
TEST_GENERATED_FILES = \
	test/output/spec.html \
	$(TEST_INTROSPECT) $(TEST_ASYNC_INTROSPECT)

RST = \
    doc/cmcaps.txt \
    doc/clientcaps.txt \
    doc/open-issues.txt \
    doc/request.txt \
    doc/dispatch.txt

$(patsubst %.txt,%.html,$(RST)): %.html: %.txt Makefile
	$(RST2HTML) < $< > $@

GENERATED_FILES = \
	$(patsubst %.txt,%.html,$(RST)) \
	doc/spec.html \
	doc/spec/index.html \
	doc/telepathy-spec.devhelp2 \
	$(INTROSPECT) $(ASYNC_INTROSPECT) \
	$(CANONICAL_NAMES)

doc/spec.html: $(XMLS) tools/doc-generator.xsl
	@install -d tmp/doc
	$(XSLTPROC) tools/doc-generator.xsl spec/all.xml > tmp/$@
	mv tmp/$@ $@
doc/telepathy-spec.devhelp2: $(XMLS) tools/devhelp.xsl
	@install -d tmp/doc
	$(XSLTPROC) tools/devhelp.xsl spec/all.xml > tmp/$@
	mv tmp/$@ $@
test/output/spec.html: $(TEST_XMLS) tools/doc-generator.xsl
	@install -d tmp/test/output
	@install -d test/output
	$(XSLTPROC) tools/doc-generator.xsl test/input/all.xml > tmp/$@
	mv tmp/$@ $@

doc/spec/index.html: $(XMLS) tools/doc-generator.py tools/specparser.py $(TEMPLATES)
	@install -d doc
	$(PYTHON) tools/doc-generator.py spec/all.xml doc/spec/

$(INTROSPECT): introspect/%.xml: spec/%.xml tools/spec-to-introspect.xsl
	@install -d introspect
	$(XSLTPROC) tools/spec-to-introspect.xsl $< | $(DROP_NAMESPACE) > $@
$(TEST_INTROSPECT): $(TEST_INTERFACE_XMLS) tools/spec-to-introspect.xsl
	@install -d test/output
	$(XSLTPROC) tools/spec-to-introspect.xsl $< | $(DROP_NAMESPACE) > $@

$(ASYNC_INTROSPECT): introspect/async/%.xml: introspect/%.xml tools/make_all_async.py
	@install -d introspect/async
	python tools/make_all_async.py $< $@
$(TEST_ASYNC_INTROSPECT): $(TEST_INTROSPECT) tools/make_all_async.py
	@install -d test/output
	python tools/make_all_async.py $< $@

all: $(GENERATED_FILES)

TEST_CANONICALIZED_FILES = test/output/spec.html.canon \
			   test/output/introspect.canon

test/output/spec.html.canon: test/output/spec.html
	$(CANONXML) $< > $@
test/output/introspect.canon: test/output/_Test.introspect.xml
	$(CANONXML) $< | $(XML_LINEBREAKS) > $@

check: all $(TEST_GENERATED_FILES) $(TEST_CANONICALIZED_FILES)
	@e=0; \
	diff -u test/expected/spec.html.canon test/output/spec.html.canon || e=1; \
	diff -u test/expected/introspect.canon test/output/introspect.canon || e=1; \
	exit $$e

clean:
	rm -f $(GENERATED_FILES)
	rm -fr introspect
	rm -rf test/output
	rm -rf tmp

maintainer-upload-snapshot: doc/spec.html
	@install -d tmp
	cp doc/spec.html tmp/spec.html
	sed -i~ -e 's!\(<h2>Version [0-9][0-9.]*\)\(</h2>\)!\1 (git commit '`git rev-list -n 1 --abbrev-commit --abbrev=8 HEAD`', '`date +%Y-%m-%d`')\2!' \
		tmp/spec.html
	scp tmp/spec.html \
		telepathy.freedesktop.org:/srv/telepathy.freedesktop.org/www/spec-snapshot.html

maintainer-upload-release: doc/spec.html
	@install -d tmp
	set -e ; \
	version="`sed -ne s'!<tp:version>\(.*\)</tp:version>!\1!p' spec/all.xml`";\
	if ! echo $$version | egrep '[0-9]+\.[0-9]+\.[0-9]+'; then \
		echo 'This does not look like a spec release'; \
		exit 1; \
	fi; \
	test -f telepathy-spec-$$version.tar.gz; \
	test -f telepathy-spec-$$version.tar.gz.asc; \
	gpg --verify telepathy-spec-$$version.tar.gz.asc; \
	rsync -vzP telepathy-spec-$$version.tar.gz telepathy.freedesktop.org:/srv/telepathy.freedesktop.org/www/releases/telepathy-spec/ ; \
	rsync -vzP telepathy-spec-$$version.tar.gz.asc telepathy.freedesktop.org:/srv/telepathy.freedesktop.org/www/releases/telepathy-spec/ ; \
	rsync -vzP doc/spec.html telepathy.freedesktop.org:/srv/telepathy.freedesktop.org/www/spec-snapshot.html ; \
	rsync -vzP doc/spec/ telepathy.freedesktop.org:/srv/telepathy.freedesktop.org/www/spec/ ; \
	rsync -vzP doc/spec.html telepathy.freedesktop.org:/srv/telepathy.freedesktop.org/www/spec.html

dist:
	@install -d tmp
	set -e ;\
	version="`sed -ne s'!<tp:version>\(.*\)</tp:version>!\1!p' spec/all.xml`";\
	distname="telepathy-spec-$$version";\
	rm -f tmp/ChangeLog "$$distname".tar "$$distname".tar.gz; \
	$(GIT) archive --format=tar --prefix="$$distname"/ "HEAD^{tree}" \
		> "$$distname".tar;\
	rm -rf tmp/"$$distname";\
	mkdir tmp/"$$distname";\
	$(GIT) log --stat > tmp/"$$distname"/ChangeLog || \
		$(GIT) log > tmp/"$$distname"/ChangeLog;\
	$(TAR) -rf "$$distname".tar -C tmp --owner 0 --group 0 --mode 0664 \
		"$$distname"/ChangeLog;\
	$(GZIP) -9 "$$distname".tar;\
	$(TAR) -ztvf "$$distname".tar.gz;\
	rm -rf tmp/"$$distname"

BRANCH = $(shell sh tools/git-which-branch.sh misc | tr -d '\n' | tr -C "[:alnum:]" _)
UPLOAD_BRANCH_TO = people.freedesktop.org:public_html/telepathy-spec

# Usage: make upload-branch BRANCH=discussion
upload-branch: all
	rsync -zvP doc/spec.html $(patsubst %.txt,%.html,$(RST)) doc/spec \
		$(UPLOAD_BRANCH_TO)-$(BRANCH)/
	@echo Your spec branch might be at:
	@echo '  ' http://people.freedesktop.org/~$$USER/telepathy-spec-$(BRANCH)/