#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/pkg-info.mk
include /usr/share/rustc/architecture.mk

export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE
export PATH := /usr/share/cargo/bin:$(PATH)
export CARGO_HOME := $(CURDIR)/debian/cargo_home
export DEB_CARGO_CRATE := raygeo_$(DEB_VERSION_UPSTREAM)
export PYBUILD_NAME=raygeo

%:
	dh $@ --buildsystem=pybuild

execute_before_dh_auto_configure:
	cargo prepare-debian debian/cargo_registry --link-from-system

execute_before_dh_auto_build:
	if test -f Cargo.lock; then mv Cargo.lock Cargo.lock.saved; fi
	cargo generate-lockfile --offline

execute_before_dh_auto_clean:
	if test -f Cargo.lock.saved; then mv Cargo.lock.saved Cargo.lock; fi
	rm -rf debian/cargo_home debian/cargo_registry

override_dh_clean:
	dh_clean -X Cargo.toml.bak
