#!/usr/bin/make -f

# Plain `dh` invocation; every override below delegates the actual work
# to the top-level Makefile so the build / install logic is single-
# sourced for both packagers and the `make install PREFIX=$$prefix`
# convention from the README.

# Map the package's host architecture to a Rust target triple so that
# `dpkg-buildpackage --host-arch arm64` resolves to
# aarch64-unknown-linux-gnu and the Makefile cross-compiles accordingly.
# The Debian GNU type (x86_64-linux-gnu, aarch64-linux-gnu) becomes the
# Rust triple by inserting the `unknown` vendor field.
include /usr/share/dpkg/architecture.mk
CARGO_TARGET := $(subst -linux-gnu,-unknown-linux-gnu,$(DEB_HOST_GNU_TYPE))

%:
	dh $@

override_dh_auto_build:
	$(MAKE) all CARGO_TARGET=$(CARGO_TARGET)

override_dh_auto_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/xdg-desktop-portal-crustace PREFIX=/usr CARGO_TARGET=$(CARGO_TARGET)

override_dh_auto_clean:
	$(MAKE) clean
	dh_clean

# The crate's `cargo test` only exercises pure-fn code today; expose
# it via `make test` once such tests exist. Disabled here so packaging
# does not pull network dependencies during a sandboxed Debian build.
override_dh_auto_test:
