#!/usr/bin/make -f
PKGNAME:=python-contract
PYVERS:=$(shell pyversions -r)

build: build-stamp
build-stamp:
	dh_testdir

	set -e; \
	for py in $(PYVERS); do  \
	    $$py setup.py build --build-lib=build/purelib; \
	done

ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	    for py in $(PYVERS); do  \
	        for test in $(wildcard test/test*); do \
		    echo running test: $$test; \
		    PYTHONPATH=build/purelib $$py $$test; \
	        done; \
	    done
endif

	touch $@

clean:
	dh_testdir
	dh_testroot
	-for py in $(PYVERS); do  \
	    $$py setup.py clean; \
	done
	find . -name \*.pyc | xargs rm -f
	rm -rf build
	rm -f install-stamp build-stamp
	dh_clean 

install: install-stamp
install-stamp:
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	set -e; \
	for py in $(PYVERS); do  \
	    $$py setup.py install --root=debian/$(PKGNAME); \
	done

	dh_installdocs -A
	dh_installexamples
	touch install-stamp

binary-arch: build install
# We have nothing to do by default.

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_compress -X.py
	dh_fixperms
	dh_pysupport
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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