#!/usr/bin/make -f

export DH_VERBOSE = 1

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


export PYBUILD_NAME=lzallright
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=lzallright_0.1.0

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 Cargo.toml
	$(CARGO) build

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

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