#!/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 optimize=+lto
export QT_SELECT := 5

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

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure --builddirectory=build-qt6 -- \
		-DBUILD_TESTING=$(if $(filter nocheck,$(DEB_BUILD_OPTIONS)),OFF,ON) \
		-DENABLE_QT6=ON \
		-DENABLE_WERROR=OFF
	dh_auto_configure --builddirectory=build-qt5 -- \
		-DBUILD_TESTING=$(if $(filter nocheck,$(DEB_BUILD_OPTIONS)),OFF,ON) \
		-DENABLE_QT6=OFF \
		-DENABLE_WERROR=ON

override_dh_auto_build:
	dh_auto_build --builddirectory=build-qt6
	dh_auto_build --builddirectory=build-qt5

override_dh_auto_test:
	QT_QPA_PLATFORM=minimal LD_LIBRARY_PATH=../src GSETTINGS_BACKEND=memory GSETTINGS_SCHEMA_DIR=. xvfb-run -a dh_auto_test --builddirectory=build-qt6
	QT_QPA_PLATFORM=minimal LD_LIBRARY_PATH=../src GSETTINGS_BACKEND=memory GSETTINGS_SCHEMA_DIR=. xvfb-run -a dh_auto_test --builddirectory=build-qt5

override_dh_auto_install:
	dh_auto_install --builddirectory=build-qt6
	dh_auto_install --builddirectory=build-qt5

execute_before_dh_install:
	rm -rf debian/*/usr/tests

override_dh_auto_clean:
	dh_auto_clean --builddirectory=build-qt6
	dh_auto_clean --builddirectory=build-qt5

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