#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow

export PYBUILD_NAME=cryptography37
export CARGO_HOME=$(CURDIR)/debian/.cargo

PYTHON3_SUPPORTED_VERSIONS:=$(shell py3versions -s 2>/dev/null | sed 's/python3.//g')

%:
	dh $@ --buildsystem=pybuild


override_dh_auto_clean:
	dh_auto_clean
	rm -rf cryptography37/hazmat/bindings/__pycache__ \
	       cryptography37/hazmat/primitives/__pycache__

override_dh_auto_build:
	for version in $(PYTHON3_SUPPORTED_VERSIONS); do \
		python3.$${version} setup.py build; \
		mkdir -p $(CURDIR)/.pybuild/cpython3_3.$${version}_cryptography37/build/; \
		cp -r build/lib.linux-*/cryptography37 $(CURDIR)/.pybuild/cpython3_3.$${version}_cryptography37/build/; \
	done

override_dh_auto_test:

override_dh_python3:
	dh_python3 --depends=cffi
	find .
	sed -Ei -e '/^cffi/d' debian/python3-cryptography37/usr/lib/python3*/dist-packages/cryptography37-37*.egg-info/requires.txt
