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

# This is the debhelper compatibility version to use.
export DH_COMPAT=5

PYVERS=$(shell pyversions -r) python2.5

build: build-stamp
build-stamp:
	dh_testdir
	set -e; \
	for python in $(PYVERS); do \
		$$python setup.py build; \
		$$python-dbg setup.py build; \
	done
	touch build-stamp

clean:
	dh_testdir
	set -e; \
	for python in $(PYVERS); do \
		$$python setup.py clean; \
		$$python-dbg setup.py clean; \
	done
	rm -rf build-stamp build
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	set -e; \
	for python in $(PYVERS); do \
		$$python setup.py install --root=debian/python-pam; \
		$$python-dbg setup.py install --root=debian/python-pam-dbg; \
	done
	find debian/python-pam-dbg ! -type d ! -name '*_d.so' | xargs rm -f

# Build architecture-independent files here.
binary-indep: build install

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs -a AUTHORS README
	dh_installexamples -a examples/*
	dh_installchangelogs -a ChangeLog
	rm -rf debian/python-pam-dbg/usr/share/doc/python-pam-dbg
	ln -sf python-pam debian/python-pam-dbg/usr/share/doc/python-pam-dbg
	dh_strip -a -Npython-pam-dbg --dbg-package=python-pam-dbg
	dh_compress -a
	dh_fixperms -a
	#dh_pycentral is needed to set the dependency on python
	dh_pycentral -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary
