#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/dpkg/default.mk

export DPKG_GENSYMBOLS_CHECK_LEVEL = 4
export QT_SELECT := 5

ENABLE_TESTS = ON
ifneq (,$(filter $(DEB_HOST_ARCH),s390x powerpc ppc64el))
        ENABLE_TESTS = OFF
endif

%:
	dh $@

override_dh_missing:
	dh_missing --fail-missing

override_dh_auto_configure:
	dh_auto_configure -- \
		-DENABLE_MECHANICD=ON \
		-DENABLE_TESTS=${ENABLE_TESTS} \
		-DENABLE_UBUNTU_COMPAT=ON

override_dh_auto_test:
	dh_auto_test --no-parallel

# FIXME: This should say `--derives-from UBports`, but we haven't got time to
# make a dpkg vendor entry yet.
SUBST_VAR = $(shell \
	dpkg-vendor --derives-from Ubuntu \
		&& echo '-Vmechanicd:Depends=mechanicd -Vmechanicd:Suggests=' \
		|| echo '-Vmechanicd:Depends= -Vmechanicd:Suggests=mechanicd')

override_dh_gencontrol:
	dh_gencontrol -- $(SUBST_VAR)
