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

NULL =

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

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

%:
	dh $@

override_dh_auto_configure:
	# disable plugins because the only plugin defaultinvitationplugin has
	# a non-free license
	dh_auto_configure --builddirectory=build-qt6 --buildsystem=cmake .. -- \
		-DENABLE_QT6=ON \
		-DBUILD_PLUGINS=OFF \
		-DBUILD_DOCUMENTATION=$(if $(filter %-doc,$(shell dh_listpackages)),ON,OFF) \
	$(NULL)
	dh_auto_configure --builddirectory=build-qt5 --buildsystem=cmake .. -- \
		-DENABLE_QT6=OFF \
		-DBUILD_PLUGINS=OFF \
		-DBUILD_DOCUMENTATION=$(if $(filter %-doc,$(shell dh_listpackages)),ON,OFF) \
	$(NULL)

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

override_dh_auto_test:
	mkdir $(CURDIR)/debian/test
	MKCAL_STORAGEDB=$(CURDIR)/debian/test/testdb-qt6 xvfb-run -a dh_auto_test --builddirectory=build-qt6 --buildsystem=cmake --no-parallel
	MKCAL_STORAGEDB=$(CURDIR)/debian/test/testdb-qt5 xvfb-run -a dh_auto_test --builddirectory=build-qt5 --buildsystem=cmake --no-parallel

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

override_dh_clean:
	-rm -rf $(CURDIR)/debian/test
	dh_clean

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