#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl
XP=xsltproc -''-nonet

%.1: %.1.xml
	$(XP) -o $@ $(DB2MAN) $< 

%:
	dh $@ --with python2

build: debian/pyro-gui.1
	dh_testdir
	[ -r setup.cfg.upstream ] || cp setup.cfg setup.cfg.upstream
	cp debian/setup.cfg .
	dh $@

clean:
	dh $@
	rm -f build debian/pyro-gui.1
	rm -rf Pyro.egg-info
	[ ! -r setup.cfg.upstream ] || mv setup.cfg.upstream setup.cfg

override_dh_install:
	python ./setup.py install --root $(CURDIR)/debian/tmp
	mv debian/tmp/usr/local/lib debian/tmp/usr/lib
	dh_install -ppyro -Xwxnsc.py -Xxnsc.py
	dh_install -Npyro -Xdocs/LICENSE

override_dh_fixperms:
	dh_fixperms
	find $(CURDIR)/debian/pyro-examples -type f -name '*.py' | \
		xargs grep -L '#!/usr/bin' | \
		xargs chmod 644
	find $(CURDIR)/debian/pyro-examples -type f -name '*.txt' | \
		xargs chmod 644

override_dh_installinit:
	dh_installinit -ppyro --name=pyro-nsd

.PHONY: build clean override_dh_installinit override_dh_install override_dh_fixperms
