#!/usr/bin/make -f

export DH_VERBOSE=1
%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_install:
	dh_auto_install
	# Make dirs for the tools package (then move scripts from python3-spf)
	mkdir -p debian/spf-tools-python/usr/bin/
	# Rename the `spfquery` tool for the alternatives system
	# (omitting the ".py" language extension):
	mv $(CURDIR)/debian/tmp/usr/bin//spfquery.py debian/spf-tools-python/usr/bin/spfquery.pyspf
	# Give the `type99` tool a more specific name
	# (omitting the ".py" language extension):
	mv $(CURDIR)/debian/tmp/usr/bin//type99.py	 debian/spf-tools-python/usr/bin/pyspf-type99
	rm -rf $(CURDIR)/debian/tmp/usr/bin

override_dh_installdocs:
	cp $(CURDIR)/CHANGELOG $(CURDIR)/changelog
	dh_installdocs
	rm $(CURDIR)/changelog

override_dh_auto_clean:
	set -e && for py3vers in $(shell py3versions -sv); do \
	        python$$py3vers setup.py clean -a; \
	done
	find . -name \*.pyc -exec rm {} \;
	dh_clean

override_dh_fixperms:
	dh_fixperms
	chmod +x $(CURDIR)/debian/tmp/usr/lib/python3*/dist-packages/spf.py

override_dh_python3:
	dh_python3 --shebang=/usr/bin/python3
