#!/usr/bin/make -f
#export DH_VERBOSE=1

%:
	dh $@ --parallel

override_dh_clean:
	rm -f src/callgrind.h
	rm -f src/valgrind.h
	dh_clean

get-orig-source:
	./debian/get-orig-source

VER_FULL = $(shell dpkg-parsechangelog | grep '^Version' | cut -d' ' -f2 | cut -f1 -d-)

# I could not get spaces working, instead duplicate boilerplate code:
ListofKnownProperties.html:
	wget -O $@ http://openslide.org/List%20of%20Known%20Properties/
Trestleformat.html:
	wget -O $@ http://openslide.org/Trestle%20format/
Hamamatsuformat.html:
	wget -O $@ http://openslide.org/Hamamatsu%20format/
Aperioformat.html:
	wget -O $@ http://openslide.org/Aperio%20format/
MIRAXformat.html:
	wget -O $@ http://openslide.org/MIRAX%20format/
GenerictiledTIFFformat.html:
	wget -O $@ http://openslide.org/Generic%20tiled%20TIFF%20format/

%.xml: %.html
	xsltproc --output $<.dummy.xml --html debian/process.xsl $<
	sed -i -e 's/BEGIN SECTION/<refsection>/g' -e 's@END SECTION@</refsection>@g' $<.dummy.xml
	xmllint --output $@ --format $<.dummy.xml
	rm $<.dummy.xml

debian/openslide-show-properties.1 : ListofKnownProperties.xml Trestleformat.xml Hamamatsuformat.xml Aperioformat.xml MIRAXformat.xml GenerictiledTIFFformat.xml debian/openslide-show-properties.1.xml
	(cd debian && xsltproc --xinclude openslide-show-properties.1.xml)

# DO NOT USE for now
#debian/openslide-quickhash1sum.1: debian/openslide-quickhash1sum.1.in
#	help2man --include=$< --output=$@ \
#		--no-info `basename $@ .1` --version-string=$(VER_FULL) --no-discard-stderr
#
#debian/openslide-write-png.1: debian/openslide-write-png.1.in
#	help2man --include=$< --output=$@ \
#		--name="Write a fragment of a virtual slide to a PNG" \
#		--no-info `basename $@ .1` --help-option=-usage --version-string=$(VER_FULL)
