#!/usr/bin/make -f

here = $(dir $(firstword $(MAKEFILE_LIST)))/..
debian_version = $(word 2, $(shell cd $(here) && dpkg-parsechangelog | grep ^Version:))
upstream_dfsg_version = $(firstword $(subst -, ,$(debian_version)))

.PHONY: get-orig-source
get-orig-source:
	sh $(here)/debian/get-orig-source.sh $(upstream_dfsg_version)

.PHONY: clean
clean:
	dh_clean
	rm -rf build
	find -name '*.py[co]' -delete

.PHONY: build build-arch build-indep
build build-indep:
	dh_testdir
	set -ex; \
	for python in $(shell pyversions -r); do \
		$$python setup.py build; \
	done
ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
	-cd test && \
	set -ex; \
	for python in $(shell pyversions -r); do \
		$$python test_all.py; \
	done
endif

.PHONY: binary binary-arch binary-indep
binary binary-indep: build-indep
	dh_testdir
	dh_testroot
	dh_prep
	for python in $(shell pyversions -r); do \
		$$python setup.py install --prefix=/usr --root=debian/python-libxmp/; \
	done
	sed -i 's/Metadata-Version: 1\.0/Metadata-Version: 1\.1/' debian/python-libxmp/usr/lib/python2.*/*-packages/*.egg-info
	dh_installdocs AUTHORS README docs_src/using.rst
	dh_installchangelogs
	dh_pysupport
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# vim:ts=4 sw=4 noet
