#!/usr/bin/make -f

#export DH_VERBOSE = 1

include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/buildflags.mk
include /usr/share/rustc/architecture.mk

export PYBUILD_NAME=pyperscan
export CARGO_HOME=$(CURDIR)/debian/cargo_home
export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE
export DEB_CARGO_CRATE=pyperscan_0.2.2

CARGO=/usr/share/cargo/bin/cargo

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_configure:
	mkdir $(CURDIR)/debian/vendor
	# link-from-system must be the 3rd arg (see
	# /usr/share/cargo/bin/cargo)
	$(CARGO) prepare-debian $(CURDIR)/debian/vendor --link-from-system #--manifest-path extension-module/Cargo.toml
	$(CARGO) build

execute_after_dh_install:
	mv target/*/debug/libpyperscan.so $(CURDIR)/debian/python3-pyperscan/usr/lib/python3/dist-packages/pyperscan/pyperscan.abi3.so
	mv pyperscan.pyi $(CURDIR)/debian/python3-pyperscan/usr/lib/python3/dist-packages/pyperscan/__init__.pyi

override_dh_auto_test:

execute_after_dh_clean:
	rm -rf $(CURDIR)/debian/vendor
