THEME = debian
INCDIR = ui
EXT = s5.html
SLIDES=slides.$(EXT)

TALKNAME=$(notdir $(PWD))

.PHONY: all
all: $(SLIDES)
	@chmod -R a+rX,og-w $(PWD)

%.$(EXT): %.rst licence.en.rst licence.de.rst
	rst2s5 --stylesheet=$(INCDIR)/docutils.css --link-stylesheet \
		--theme-url=$(INCDIR)/$(THEME) --current-slide $< \
			| sed -e '/<div id="header">/a<p class="copyright">&copy; Martin F. Krafft</p>' \
			      -e 's,$(INCDIR)/$(THEME)/\(slides.js\|\(opera\|outline\|print\)\.css\),$(INCDIR)/base/\1,' \
			> $@

.PRECIOUS: licence.%.rst
licence.%.rst: licence.%.rst.in
	sed -e 's,#THEME#,$(THEME),g' $< > $@

.PHONY: tarball
tarball: $(TALKNAME).tar.gz

$(TALKNAME).tar.gz: $(SLIDES)
	tar -c -z -C .. -f $@ --exclude=\*/.bzr\* $(notdir $(PWD))

.PHONY: clean
clean:
	rm -f $(wildcard *.$(EXT))
	rm -f licence.rst

.PHONY: view
view: slides.$(EXT)
	sensible-browser $(PWD)/$<
