#!/usr/bin/make -f

PYVERS=$(shell pyversions -vs)

configure: configure-stamp
configure-stamp:
	dh_testdir
	touch $@

build-indep:
build-arch: configure-stamp $(PYVERS:%=build-python%)
build: build-arch

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

clean:
	dh_testdir
	dh_testroot
	find $(CURDIR) -regex ".+.pyc" | xargs rm -rf
	rm -f build-stamp configure-stamp build-python2.* install-python2.*
	rm -rf build
	dh_clean 

install: build $(PYVERS:%=install-python%)

install-python%:
	dh_testdir
	dh_testroot
	python$* setup.py install --no-compile --root=$(CURDIR)/debian/python-rdflib --single-version-externally-managed --install-layout=deb
	rm -rf $(CURDIR)/debian/python-rdflib/usr/lib/python$*/*-packages/test
	sed -i -e "s@\(/usr/bin/python\).*@\1@" $(CURDIR)/debian/python-rdflib/usr/bin/rdfpipe
	touch $@

binary-indep: build install

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs CHANGELOG
	dh_installdocs
	dh_installexamples
	dh_installman debian/manpages/rdfpipe.1
	dh_strip
	dh_compress
	dh_fixperms
	dh_python2
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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