#!/usr/bin/make -f
# -*- makefile -*-


include /usr/share/quilt/quilt.make

#export DH_VERBOSE=1
export DH_ALWAYS_EXCLUDE="CVS:.svn"

export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

CONFIGURE_FLAGS = --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
PYVERS = $(shell pyversions -vr)


build: $(QUILT_STAMPFN) $(PYVERS:%=build-python%)
build-python%:
	./autogen.sh
	dh build --before auto_configure

	test -r config.sub && mv -f config.sub config.sub.save || echo "not found"
	test -r config.guess && mv -f config.guess config.guess.save || echo "not found"
	test -r /usr/share/misc/config.sub && cp -f /usr/share/misc/config.sub config.sub
	test -r /usr/share/misc/config.guess && cp -f /usr/share/misc/config.guess config.guess

	dh_auto_configure -- $(CONFIGURE_FLAGS)
	dh build --after auto_configure
	touch $@


clean: unpatch
	test -r config.sub.save && mv -f config.sub.save config.sub || echo "not found"
	test -r config.guess.save && mv -f config.guess.save config.guess || echo "not found"

	dh clean
	rm -f build-python* install-python*


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


binary-indep: install
	dh binary-indep --before pysupport
	dh_pysupport /usr/bin /usr/lib/python?.?/site-packages
	dh binary-indep --after pysupport

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

binary: binary-indep binary-arch

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

