#!/usr/bin/make -f
%:
	dh --with python2 $@

override_dh_auto_clean:
	-dh_auto_clean
	find zmq -name '*.c' -delete
	find zmq -name '*.so' -delete
	rm -f conf/*.pickle

override_dh_install:
	# Install everything excluding the *_d.so debug extensions to python-zmq
	dh_install -X"*_d.so" "debian/tmp/*" -p python-zmq

	# Install the debug extensions to python-zmq-dbg
	dh_install "usr/lib/python*/*-packages/zmq/*/*_d.so" -p python-zmq-dbg

	# Continue with regular dh_install
	dh_install

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	set -e; \
	for python in $(shell pyversions -r); do \
		for build in \  -dbg; do \
			find zmq -name '*.so' -delete; \
			$$python$$build setup.py build_ext --inplace; \
			$$python$$build setup.py test; \
		done; \
	done
endif

override_dh_strip:
ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
	dh_strip --dbg-package=python-zmq-dbg
	find debian/python-zmq-dbg/usr/lib/debug -name '*_d.so' -delete
endif

get-orig-source:
	cd $(dir $(firstword $(MAKEFILE_LIST)))../ && \
	uscan \
		--verbose \
		--rename  \
		--destdir $(CURDIR)      \
		--watchfile debian/watch \
		--force-download
