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

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

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

export CFLAGS := $(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
export CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed
export QT_SELECT=qt5

# Skip tests on the archs they are known to be flaky with current configuration
testskip_architectures :=

ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	CONFIGURE_OPTS += "CONFIG+=no_tests"
endif

%:
	dh $@

override_dh_missing:
	dh_missing --fail-missing

override_dh_auto_configure:
	dh_auto_configure -- \
		LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
		DEB_HOST_MULTIARCH=$(DEB_HOST_MULTIARCH) \
		"QMAKE_CXXFLAGS=$(CFLAGS)" \
		$(CONFIGURE_OPTS) \
		lomiri-system-settings-online-accounts.pro

override_dh_auto_install:
	dh_auto_install
	rm -rf debian/*/usr/tests

	# Create the compat module for Ubuntu.OnlineAccounts.Plugin
	P=debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/lomiri-system-settings/private/ ;\

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifneq (,$(filter $(DEB_HOST_ARCH),$(testskip_architectures)))
	-dh_auto_test --max-parallel=1
else
	dh_auto_test --max-parallel=1
endif
endif

override_dh_auto_test-indep:
