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

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

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND =
export QT_SELECT := 5

# Force aligned access to fix FTBFS / Bus Error on armhf
export DEB_CFLAGS_MAINT_APPEND = -mno-unaligned-access

# Skip tests on the archs they are known to be flaky
testskip_architectures := powerpc armhf

include /usr/share/dpkg/architecture.mk

override_dh_install:
	rm -rf debian/*/usr/tests
	dh_install

override_dh_auto_install:
	mkdir "$(CURDIR)/debian/run-dir/"
	chmod 7700 "$(CURDIR)/debian/run-dir/"
	export XDG_RUNTIME_DIR="$(CURDIR)/debian/run-dir/" && dh_auto_install --no-parallel
	rm -Rfv "$(CURDIR)/debian/run-dir/"

override_dh_auto_test:
ifneq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(testskip_architectures)))
	QT_QPA_PLATFORM=minimal LD_LIBRARY_PATH=../src GSETTINGS_BACKEND=memory GSETTINGS_SCHEMA_DIR=. xvfb-run -a dh_auto_test
endif

override_dh_makeshlibs:
	# passed to dpkg-gensymbols
	dh_makeshlibs -- -c4

%:
	dh $@ --with pkgkde_symbolshelper


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