#!/usr/bin/make -f
#DH_VERBOSE = 1

#LC_ALL=C.UTF-8 Makes sure that it builds correctly with pbuilder

PYTHON3VERSIONS := $(shell py3versions -s -v)
PYTHON2VERSIONS := $(shell pyversions -s -v)

%:
	LC_ALL=C.UTF-8 dh $@ --with python2,python3 --buildsystem=pybuild


override_dh_auto_build:
	cd debian/python2_old && PYBUILD_VERSIONS="$(PYTHON2VERSIONS)" pybuild --build
	PYBUILD_VERSIONS="$(PYTHON3VERSIONS)" pybuild --build

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	cd debian/python2_old && PYBUILD_VERSIONS="$(PYTHON2VERSIONS)" pybuild --test
	PYBUILD_VERSIONS="$(PYTHON3VERSIONS)" pybuild --test
endif

override_dh_auto_install:
	cd debian/python2_old && PYBUILD_VERSIONS="$(PYTHON2VERSIONS)" pybuild --install
	PYBUILD_VERSIONS="$(PYTHON3VERSIONS)" pybuild --install

override_dh_auto_clean:
	dh_auto_clean
	cd debian/python2_old && PYBUILD_VERSIONS="$(PYTHON2VERSIONS)" pybuild --clean
	$(RM) -r .pybuild zeroconf.egg-info
	$(RM) -r debian/python2_old/.pybuild/
	$(RM) -r debian/python2_old/debian/
	$(RM) -r debian/python2_old/zeroconf.egg-info/

override_dh_gencontrol:
	dh_gencontrol -ppython3-zeroconf
	dh_gencontrol -ppython-zeroconf -- -v0.19.1-3
