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

override_dh_auto_clean:
	-dh_auto_clean
	find zmq -name '*.c' -delete

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:
# Almost all tests are broken because OpenPGM doesn't seem to be initialized
# correctly or there is not support for OpenPGM in libzmq0. I don't know if
# #566126 have something to do with this, anyway the affected tests are:
# zmq/tests/test_context.py
# zmq/tests/test_pair.py
# zmq/tests/test_poll.py
# zmq/tests/test_pubsub.py
# zmq/tests/test_reqrep.py
# zmq/tests/test_socket.py
#ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
#	for python in $(shell pyversions -r); do \
#		$$python setup.py test; \
#		$$python-dbg setup.py test; \
#	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
