#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

PYTHON3S:=$(shell py3versions -vr)

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_install:
	set -e && for pyvers in $(PYTHON3S); do \
		python$$pyvers setup.py install --install-layout=deb \
			--root $(CURDIR)/debian/python3-cram; \
	done
	# install Python 3 version with different name
	mv $(CURDIR)/debian/python3-cram/usr/bin/cram \
		$(CURDIR)/debian/python3-cram/usr/bin/cram3
	# run with any Python 3 version
	sed -i s/python3.[0-9]/python3/ \
		$(CURDIR)/debian/python3-cram/usr/bin/cram3

execute_after_dh_auto_test:
	# accept any test result until the relation between cram and coverage is clarified
	# see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=897516#53
	PYTHON=python3 COVERAGE=python3-coverage $(MAKE) test || true

execute_after_dh_clean:
	rm -rf $(CURDIR)/build
	rm -f $(CURDIR)/.coverage
