#!/usr/bin/make -f
# -*- makefile -*-

export DPKG_GENSYMBOLS_CHECK_LEVEL=4

include /usr/share/dpkg/default.mk

# Mir is an optional build dependency
TRUST_STORE_MIR_AGENT_ENABLED = OFF
ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes)
ifneq (,$(filter $(DEB_HOST_ARCH),amd64 arm64 i386 armhf))
        TRUST_STORE_MIR_AGENT_ENABLED = ON
endif
endif

# The home directory of user buildd does not exist on the builders
export XDG_DATA_HOME=/tmp

%:
	dh $@

override_dh_missing:
	dh_missing --fail-missing

override_dh_auto_configure:
	dh_auto_configure -- \
		-DTRUST_STORE_MIR_AGENT_ENABLED=$(TRUST_STORE_MIR_AGENT_ENABLED) \
		-DTRUST_STORE_WAYLAND_AGENT_ENABLED=ON

override_dh_auto_test:
	dh_auto_test --no-parallel

execute_before_dh_install:
	if dpkg-vendor --derives-from Ubuntu; then \
		for arch in amd64 arm64 i386 armhf; do \
			ln -sfv trust-store-bin.install.with_mir \
				debian/trust-store-bin.install.$${arch}; \
		done; \
	fi
