#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk


%:
	dh $@ --with python2

override_dh_auto_clean:
	-dh_auto_clean
	if [ -d zmq ]; then \
	  find zmq -name '*.c' -delete; \
	  find zmq -name '*.so' -delete; \
	fi
	rm -rf build
	find $(CURDIR) -name "*.pyc" -delete
	rm -f conf/*.pickle
	rm -f conf/*.json

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

	# Install the debug extensions to python-zmq-dbg
	dh_install "usr/lib/python2.*/*-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

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