#!/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.

include /usr/share/dpkg/architecture.mk

# Cross-build: when host != build arch, hand the matching Rust target
# triple to the Makefile so cargo cross-compiles and install picks the
# binary from target/<triple>/release. The linker is set in .cargo/config.
ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
export RUST_TARGET = $(DEB_HOST_GNU_CPU)-unknown-linux-gnu
endif

%:
	dh $@

override_dh_auto_build:
	$(MAKE) all

override_dh_auto_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/calllogs-server PREFIX=/usr

override_dh_auto_clean:
	$(MAKE) clean
	dh_clean

# `cargo test` would pull dependencies from the network, which a sandboxed
# Debian build forbids. Disabled here; run `cargo test` manually.
override_dh_auto_test:
