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

NULL =

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

include /usr/share/dpkg/architecture.mk

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
include /usr/share/dpkg/buildflags.mk

ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	export DEB_BUILD_PROFILES := cross
	CONFIGURE_OPTS += -DENABLE_DOC="OFF"
endif

# UBports-specific:
#
# The online-accounts-client/client/service/tst_libaccounts_service/ unit
# tests fails on Ubuntu noble. Skip this for now.
#
ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes)
        CONFIGURE_OPTS += -DDISABLE_TESTS_THAT_FAIL_ON_UBUNTU_NOBLE=ON
endif

# Skip tests on the archs they are known to be flaky with current configuration
# See https://launchpad.net/bugs/1630906
testskip_architectures :=

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
	    -DBUILD_TESTING=ON \
	    $(CONFIGURE_OPTS) \
	    $(NULL)

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifneq (,$(filter $(DEB_HOST_ARCH),$(testskip_architectures)))
	mkdir -p debian/home
	-dh_auto_test --no-parallel
else
	mkdir -p debian/home
	dh_auto_test --no-parallel
endif
endif

override_dh_install:
	# empty directories
	rmdir debian/tmp/usr/share/doc/qml-module-lomiri-onlineaccounts/html/images/
	rmdir debian/tmp/usr/share/doc/qml-module-lomiri-onlineaccounts-client/html/images/
	dh_install

override_dh_missing:
	dh_missing --fail-missing

override_dh_clean:
	rm -Rf debian/home
	dh_clean

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=..