#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

CONFIGURE_FLAGS = \
	-DENABLE_LOAD_ICU=ON \
	-DSQLITE_ICU_EXTENSION=/usr/lib/$(DEB_HOST_MULTIARCH)/sqlite/icu.so

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure --builddirectory=build-qt5 -- $(CONFIGURE_FLAGS) -DENABLE_QT6=OFF
	dh_auto_configure --builddirectory=build-qt6 -- $(CONFIGURE_FLAGS) -DENABLE_QT6=ON

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

override_dh_auto_test:
	glib-compile-schemas schemas/
	GSETTINGS_SCHEMA_DIR=$(CURDIR)/schemas dh_auto_test --builddirectory=build-qt5 --no-parallel
	GSETTINGS_SCHEMA_DIR=$(CURDIR)/schemas dh_auto_test --builddirectory=build-qt6 --no-parallel

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

execute_before_dh_install:
	# remove the tests
	rm -rf debian/tmp/opt
	rm -rf debian/tmp/usr/lib/*/qtcontacts-sqlite-qt*/libtestdlgg.so

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

execute_after_dh_clean:
	rm -f schemas/gschemas.compiled

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