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

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export DPKG_GENSYMBOLS_CHECK_LEVEL=4

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
# Skip qml tests on the archs they are known to be flaky with current configuration
# Ref.: https://bugs.launchpad.net/ubuntu/+source/mesa/+bug/1585942
qmltestskip_architectures := arm64 powerpc s390x

%:
	dh $@ --with=translations

override_dh_missing:
	dh_missing --fail-missing

override_dh_auto_configure:
ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(qmltestskip_architectures)))
	dh_auto_configure -- -DCMAKE_BUILD_TYPE=Debug \
	                     -DSKIP_QML_TESTS="on"
else
	dh_auto_configure -- -DCMAKE_BUILD_TYPE=Debug
endif

override_dh_auto_test:
ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
	QT_QPA_PLATFORM=minimal CTEST_OUTPUT_ON_FAILURE=1 dh_auto_test --no-parallel
endif

override_dh_translations:
	# Override dh_translations to work around http://pad.lv/1183262.
	dh_auto_build -- telephony-service.pot

override_dh_installsystemduser:
	dh_installsystemduser --package=telephony-service --name=telephony-service-indicator
	dh_installsystemduser --package=telephony-service --name=telephony-service-approver
