#!/usr/bin/make -f
#Ubuntu doesn't have dh_xulrunner yet
xul:=$(shell which dh_xulrunner)
ppa:=$(shell sed -n "1s/.*~.*/yes/p" debian/changelog)
daily:=$(shell sed -n "1s/.*2010.*-.*/yes/p" debian/changelog)
# Yes, the next variable name and value are the same
,:=,

%:
	dh $@ --with quilt$(if $(xul),$(,)xulrunner)
override_dh_auto_configure:
	./waf configure --nocache --prefix=/usr
override_dh_auto_build:
	./waf build --nocache
override_dh_auto_install:
	./waf install --nocache --destdir=debian/tmp
override_dh_strip:
	dh_strip --dbg-package=xiphos-dbg
override_dh_auto_clean:
	./waf distclean --nocache
override_dh_shlibdeps:
	dh_shlibdeps
# dh_xulrunner replacement when not available
ifeq ($(xul),)
	sed -i "s/\(shlibs:.*\)/\1, $(shell dpkg-query -W xulrunner-1.9* \
	| sed -n "/xulrunner-1.9.*-dev\t./s/\(xulrunner-1.9.*\)-dev\t.*/\1/p")/" \
	debian/xiphos.substvars
endif
override_dh_clean:
	echo $(if $(ppa),"1.0","3.0 (quilt)") > debian/source/format
	$(if $(daily),cp debian/patches/daily.series debian/patches/series)
	dh_clean
	rm -rf .waf*
	rm -rf waffles/*.pyc

override_dh_builddeb:
	dh_builddeb $(if $(ppa),-- -Zlzma)
