#!/usr/bin/make -f

# Delegate build/install to the top-level Makefile so packagers and the
# `make install PREFIX=...` convention stay single-sourced. The arm64 package
# is cross-built from amd64 via `make arm64` (cargo --target aarch64-...), so we
# dispatch on the Debian host architecture and install from its target dir.

include /usr/share/dpkg/architecture.mk

%:
	dh $@

override_dh_auto_build:
ifeq ($(DEB_HOST_ARCH),arm64)
	$(MAKE) arm64
else
	$(MAKE) all
endif

override_dh_auto_install:
ifeq ($(DEB_HOST_ARCH),arm64)
	$(MAKE) install DESTDIR=$(CURDIR)/debian/eydos-calls PREFIX=/usr RELEASE_DIR=target/aarch64-unknown-linux-gnu/release
else
	$(MAKE) install DESTDIR=$(CURDIR)/debian/eydos-calls PREFIX=/usr
endif

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:
