#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# See FEATURE AREAS in dpkg-buildflags(1).
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk
include /usr/share/rustc/architecture.mk
export DEB_HOST_RUST_TYPE
export PATH:=/usr/share/cargo/bin:$(PATH)
export CARGO=/usr/share/cargo/bin/cargo
export CARGO_HOME=$(CURDIR)/debian/cargo_home
export CARGO_REGISTRY=$(CURDIR)/debian/cargo_registry
export DEB_CARGO_CRATE=$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)

%:
	dh $@ --buildsystem=cargo

override_dh_auto_build:
	cargo build --release

execute_after_dh_auto_clean:
	$(CARGO) clean
	rm -rf $(CARGO_HOME)
	rm -rf $(CARGO_REGISTRY)
	rm -f debian/cargo-checksum.json

execute_before_dh_auto_configure:
	$(CARGO) prepare-debian $(CARGO_REGISTRY) --link-from-system
	touch debian/cargo-checksum.json

execute_after_dh_auto_install:
	/usr/share/cargo/bin/dh-cargo-built-using cloud-image-checker
