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

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

export DPKG_GENSYMBOLS_CHECK_LEVEL=4

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

# http://ccache.samba.org/manual.html#_precompiled_headers
export CCACHE_SLOPPINESS=time_macros

export QT_SELECT=qt5

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure --builddirectory=build-qt5 --buildsystem=cmake .. -- \
	   -DENABLE_QT6=OFF \
	   -DCHECK_WHITESPACE_IGNORE=$(CURDIR)/build-qt6\;$(CURDIR)/build-qt5 \
	   -DCHECK_COPYRIGHT_IGNORE=$(CURDIR)/build
	dh_auto_configure --builddirectory=build-qt6 --buildsystem=cmake .. -- \
	   -DENABLE_QT6=ON \
	   -DCHECK_WHITESPACE_IGNORE=$(CURDIR)/build-qt6\;$(CURDIR)/build-qt5 \
	   -DCHECK_COPYRIGHT_IGNORE=$(CURDIR)/build

override_dh_auto_build:
	dh_auto_build --builddirectory=build-qt6 --buildsystem=cmake ..
	dh_auto_build --builddirectory=build-qt5 --buildsystem=cmake ..

# Tests are not written to be run in parallel.
# We ignore failing tests on PPC and s390x because the storage-framework is irrelevant there.
test_args = ARGS=\"--verbose\"
override_dh_auto_test:
ifneq (,$(filter powerpc ppc64el s390x,$(DEB_HOST_ARCH)))
	-dh_auto_test --builddirectory=build-qt5 --buildsystem=cmake --no-parallel .. -- $(test_args)
	-dh_auto_test --builddirectory=build-qt6 --buildsystem=cmake --no-parallel .. -- $(test_args)
else
	dh_auto_test --builddirectory=build-qt5 --buildsystem=cmake --no-parallel .. -- $(test_args)
	dh_auto_test --builddirectory=build-qt6 --buildsystem=cmake --no-parallel .. -- $(test_args)
endif

override_dh_auto_install:
	dh_auto_install --builddirectory=build-qt6 --buildsystem=cmake ..
	dh_auto_install --builddirectory=build-qt5 --buildsystem=cmake ..

override_dh_auto_clean:
	dh_auto_clean --builddirectory=build-qt5 --buildsystem=cmake ..
	dh_auto_clean --builddirectory=build-qt6 --buildsystem=cmake ..
