#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

PYVERS := $(shell pyversions -vr)

PKGROOT=debian/python-pylibacl
DBGROOT=debian/python-pylibacl-dbg

build: $(PYVERS:%=build-python%) build-indep
	touch $@

build-python%:
	python$* setup.py build
	python$*-dbg setup.py build
	touch $@

build-indep:
	make doc
	touch $@

clean:
	dh_testdir
	dh_testroot
	rm -f build-arch-stamp build-indep #CONFIGURE-STAMP#
	rm -rf build html
	rm -f posix1e.so
	rm -f $(PYVERS:%=build-python%)
	dh_clean

install: build $(PYVERS:%=install-python%)
	find $(DBGROOT) ! -type d ! -name '*_d.so' | xargs rm -f
	find $(DBGROOT) -depth -empty -print0|xargs -r0 rmdir

install-python%:
	python$* setup.py install --root $(PKGROOT) --install-layout=deb
	python$*-dbg setup.py install --root $(DBGROOT) --install-layout=deb

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_strip -ppython-pylibacl --dbg-package=python-pylibacl-dbg
	rm -rf $(DBGROOT)/usr/share/doc/python-pylibacl-dbg
	ln -s python-pylibacl $(DBGROOT)/usr/share/doc/python-pylibacl-dbg
	dh_compress -X.js
	dh_fixperms
	dh_pysupport
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture independant packages here.
binary-indep: build install
# Nothing to do

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