#!/usr/bin/make -f

include /usr/share/rustc/architecture.mk
export DEB_HOST_GNU_TYPE
export DEB_HOST_RUST_TYPE

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

ifneq ($(DEB_TARGET_ARCH),mips64el)
# mips64el: see https://bugs.debian.org/1076650
RUSTFLAGS += -C codegen-units=1
endif
# these lto-related options seem to cause build errors that i don't understand
# see https://salsa.debian.org/rust-team/rust/-/merge_requests/41
#RUSTC_ARGS += -C lto=true -C linker-plugin-lto=true -C embed-bitcode=true
export RUSTFLAGS

CARGO_BUILD_ARGS = build --release --verbose

export CARGO_HOME = $(CURDIR)/debian/cargo_home

TARGET_RELEASE_DIR = target/$(DEB_HOST_RUST_TYPE)/release

%:
	dh $@ --buildsystem cargo --with bash-completion

execute_after_dh_auto_build:
	$(CARGO) $(CARGO_BUILD_ARGS) --bin sqopv --features=cliv,sequoia-openpgp/crypto-nettle --no-default-features
	$(CARGO) $(CARGO_BUILD_ARGS) --bin sqop --features=cli

override_dh_auto_test:
	dh_auto_test -- test --all
