#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export CARGO_HOME = $(CURDIR)/.cargo-home
# Use the versioned Rust toolchain so plain `cargo`/`rustc` resolve to 1.91
# (Edition 2024 in transitive deps requires >= 1.85; noble's default cargo is 1.75).
export PATH := /usr/lib/rust-1.91/bin:$(PATH)

%:
	dh $@

override_dh_auto_build:
	cargo build --release --offline --frozen

override_dh_auto_install:
	install -D -m 0755 target/release/rdmatop \
	    debian/rdmatop/usr/bin/rdmatop

override_dh_auto_test:
	# skip; PPA builders lack RDMA hardware

override_dh_auto_clean:
	cargo clean --offline || true
	rm -rf $(CARGO_HOME)

# dh_clean defaults to deleting *.orig files (treats them as backups).
# cargo vendor's Cargo.toml.orig files are metadata required by
# cargo's offline checksum verification — keep them.
override_dh_clean:
	dh_clean -X.orig
