#!/usr/bin/make -f

buildvers := $(shell pyversions -sv)
build3vers := $(shell py3versions -sv)

%:
	dh $@ --with python2, --with python3

override_dh_auto_build:
	mv $(CURDIR)/SubnetTree_wrap.cc $(CURDIR)/not.SubnetTree_wrap.cc
	dh_auto_build
	mv $(CURDIR)/not.SubnetTree_wrap.cc $(CURDIR)/SubnetTree_wrap.cc

override_dh_auto_install:
	dh_install -ppython-subnettree
	set -e && for i in $(buildvers); do \
	  python$$i ./setup.py install --install-layout=deb --root $(CURDIR)/debian/python-subnettree; \
	done

	dh_install -ppython3-subnettree
	set -e && for i in $(build3vers); do \
	  python$$i ./setup.py install --install-layout=deb --root $(CURDIR)/debian/python3-subnettree; \
	done

override_dh_clean:
	dh_clean
	-cp -f $(CURDIR)/not.SubnetTree_wrap.cc $(CURDIR)/SubnetTree_wrap.cc
	rm -f $(CURDIR)/not.SubnetTree_wrap.cc
	rm -rf $(CURDIR)/build

override_dh_auto_test:
	:
