summaryrefslogtreecommitdiff
path: root/Makefile
blob: 03a96e4b6b37647feb7a5c78cb05f8c93d0be61b (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
NAME = simplyread
UPNAME = SimplyRead
VERSION = 0.7
KEYFILE = private.pem

WEBSITE = http://njw.me.uk/software/$(NAME)
REPOURL = http://git.njw.me.uk/$(NAME).git
AUTHORFOAF = http://njw.me.uk/card#i
AUTHORNAME = Nick White
AUTHORHOME = http://njw.me.uk
GECKOID = simplyread@njw.me.uk

all: xpi crx

web: web/index.html web/gecko-updates.rdf web/chromium-updates.xml

$(KEYFILE):
	openssl genrsa 1024 > $@

sign:
	if test -f $(NAME)-$(VERSION).tar.bz2; then \
		gpg -b < $(NAME)-$(VERSION).tar.bz2 > $(NAME)-$(VERSION).tar.bz2.sig; \
		echo $(NAME)-$(VERSION).tar.bz2.sig; fi
	if test -f $(NAME)-$(VERSION).xpi; then \
		gpg -b < $(NAME)-$(VERSION).xpi > $(NAME)-$(VERSION).xpi.sig; \
		echo $(NAME)-$(VERSION).tar.xpi.sig; fi
	if test -f $(NAME)-$(VERSION).crx; then \
		gpg -b < $(NAME)-$(VERSION).crx > $(NAME)-$(VERSION).crx.sig; \
		echo $(NAME)-$(VERSION).tar.crx.sig; fi

# TODO: test makefile dependency is portable (and correct)
web/gecko-updates.rdf: $(NAME)-$(VERSION).xpi $(KEYFILE)
	uhura -o $@ -k $(KEYFILE) $(NAME)-$(VERSION).xpi $(WEBSITE)/$(NAME)-$(VERSION).xpi

# gensig not working yet
#web/gecko-updates.rdf: gecko/updates.ttl
#	sed -e "s/VERSION/$(VERSION)/g" \
#		-e "s|WEBSITE|$(WEBSITE)|g" \
#		-e "s|GECKOID|$(GECKOID)|g" \
#		-e "s/HASH/`sha1sum $(NAME)-$(VERSION).xpi|awk '{print $$1}'`/g" \
#		-e "s/SIG/`sh gecko/gensig.sh gecko/updates.ttl $(KEYFILE)`/g" \
#		< $< | rapper -i turtle -o rdfxml /dev/stdin 2>/dev/null > $@

web/chromium-updates.xml: chromium/updates.xml
	sed -e "s/VERSION/$(VERSION)/g" -e "s|WEBSITE|$(WEBSITE)|g" < $< > $@

web/doap.ttl: web/doap-src.ttl
	sed -e "s|FOAF|$(AUTHORFOAF)|g" -e "s|AUTHORNAME|$(AUTHORNAME)|g" \
	    -e "s|AUTHORHOME|$(AUTHORHOME)|g" -e "s|WEBSITE|$(WEBSITE)|g" \
	    -e "s|REPOURL|$(REPOURL)|g" < $< > $@

web/index.html: web/doap.ttl README
	echo making webpage
	echo "<!DOCTYPE html><html><head><title>$(UPNAME)</title>" > $@
	echo '<link rel="alternate" type="text/turtle" title="rdf" href="doap.ttl" />' >> $@
	echo '<style type="text/css">' >> $@
	echo "body {font-family:sans-serif; width:38em; margin:auto; max-width:94%;}" >> $@
	echo "h1 {font-size:1.6em; text-align:center;}" >> $@
	echo "a {text-decoration:none; border-bottom-width:thin; border-bottom-style:dotted;}" >> $@
	echo "</style></head><body>" >> $@
	smu < README >> $@
	echo "[$(UPNAME) $(VERSION) source]($(NAME)-$(VERSION).tar.bz2) ([sig]($(NAME)-$(VERSION).tar.bz2.sig))" | smu >> $@

	echo "[$(UPNAME) $(VERSION) for Firefox]($(NAME)-$(VERSION).xpi) ([sig]($(NAME)-$(VERSION).xpi.sig))" | smu >> $@

	echo "[$(UPNAME) $(VERSION) for Chromium]($(NAME)-$(VERSION).crx) ([sig]($(NAME)-$(VERSION).crx.sig))" | smu >> $@

	echo '<hr />' >> $@
	sh web/websummary.sh web/doap.ttl | smu >> $@
	echo '</body></html>' >> $@

dist:
	mkdir -p $(NAME)-$(VERSION)
	cp simplyread.js viable.js keybind.js icon.svg COPYING INSTALL README Makefile $(NAME)-$(VERSION)
	cp -R gecko chromium $(NAME)-$(VERSION)
	tar -c $(NAME)-$(VERSION) | bzip2 -c > $(NAME)-$(VERSION).tar.bz2
	rm -rf $(NAME)-$(VERSION)
	echo $(NAME)-$(VERSION).tar.bz2

xpi: $(KEYFILE)
	rm -rf $(NAME)-$(VERSION).xpi gecko-build
	mkdir -p gecko-build/chrome/content
	sed 2q < COPYING > gecko-build/COPYING
	cp gecko/chrome.manifest gecko-build/
	cp gecko/chrome/content/simplyread.xul gecko-build/chrome/content/
	cp simplyread.js gecko-build/chrome/content/
	cat viable.js gecko/viablehook.js > gecko-build/chrome/content/viable.js
	rsvg -w 22 -h 22 icon.svg gecko-build/chrome/content/icon.png
	rsvg -w 64 -h 64 icon.svg gecko-build/icon.png
	sed -e "s/VERSION/$(VERSION)/g" -e "s|WEBSITE|$(WEBSITE)|g" -e "s|GECKOID|$(GECKOID)|g" -e "s/PUBKEY/`sh gecko/genpub.sh $(KEYFILE)`/g" \
		< gecko/install.ttl | rapper -i turtle -o rdfxml /dev/stdin 2>/dev/null > gecko-build/install.rdf
	cd gecko-build; zip -r ../$(NAME)-$(VERSION).xpi . 1>/dev/null
	rm -rf gecko-build
	echo $(NAME)-$(VERSION).xpi

crx: $(KEYFILE)
	rm -rf chromium-build
	mkdir chromium-build
	sed 2q < COPYING > chromium-build/COPYING
	cp simplyread.js keybind.js chromium-build/
	cp chromium/background.html chromium/options.html chromium-build/
	cat viable.js chromium/viablehook.js > chromium-build/viable.js
	rsvg -w 19 -h 19 icon.svg chromium-build/icon.png
	rsvg -w 48 -h 48 icon.svg chromium-build/icon48.png
	rsvg -w 128 -h 128 icon.svg chromium-build/icon128.png
	sed -e "s/VERSION/$(VERSION)/g" -e "s|WEBSITE|$(WEBSITE)|g" < chromium/manifest.json > chromium-build/manifest.json
	sh chromium/makecrx.sh chromium-build $(KEYFILE) > $(NAME)-$(VERSION).crx
	rm -r chromium-build
	echo $(NAME)-$(VERSION).crx

# note that tests require a patched surf browser; see tests/runtest.sh
test:
	for i in tests/html/*.html; do \
		sh tests/webkittest.sh $$i $$i.simple 1>$$i.diff 2>/dev/null; \
		test $$? -eq 0 && echo "$$i passed (webkit)" \
			|| echo "$$i failed (webkit) (see $$i.diff)"; \
		test ! -s $$i.diff && rm $$i.diff; \
	done

.PHONY: all dist xpi crx test web sign
.SUFFIXES: ttl html png svg
.SILENT: