#!/usr/bin/make -f

include /usr/share/python3/python.mk

here = $(dir $(firstword $(MAKEFILE_LIST)))/..
upstream_version = $(shell cd $(here) && dpkg-parsechangelog | sed -n -r -e '/^Version: ([0-9.]+).*/ { s//\1/p }')
upstream_url_py2 = $(shell cd $(here) && uscan --dehs --download-version="$(upstream_version)" | sed -n -r -e '/<upstream-url>(.*)<.*/ { s//\1/p }')
upstream_url_py3 = $(subst /python-pipeline-,/python3-pipeline-,$(upstream_url_py2))

.PHONY: get-orig-source
get-orig-source:
	wget $(upstream_url_py2) -O python-pipeline_$(upstream_version).orig.tar.gz
	wget $(upstream_url_py3) -O python-pipeline_$(upstream_version).orig-py3k.tar.gz

.PHONY: override_dh_auto_install
override_dh_auto_install:
	dh_auto_install
	cd py3k && python3 setup.py install $(py_setup_install_args) --root=$(CURDIR)/debian/tmp

.PHONY: override_dh_pysupport
override_dh_pysupport:
	dh_pysupport -p python-pipeline
	dh_python3 -p python3-pipeline

.PHONY: override_dh_auto_test
override_dh_auto_test:
ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
	set -e -x; \
	for python in $(shell pyversions -r); do \
		$$python -c 'import pipeline as p, doctest as d; d.testmod(p, report=1)'; \
	done
	cd py3k && set -e -x; \
	for python3 in $(shell py3versions -r); do \
		$$python3 -c 'import pipeline as p, doctest as d; d.testmod(p, report=1)'; \
	done
endif

.PHONY: build build-arch build-indep binary binary-arch binary-indep clean
build binary binary-indep clean:
	dh $(@)
build-indep: build
build-arch binary-arch:
	# Nothing to do.

# vim:ts=4 sw=4 noet
