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

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

include /usr/share/dpkg/architecture.mk

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
include /usr/share/dpkg/buildflags.mk

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure --builddirectory=build-qt5 -- \
		-DBUILD_TESTING=$(if $(filter nocheck,$(DEB_BUILD_OPTIONS)),OFF,ON) \
		-DDISABLE_TESTS_THAT_FAIL_ON_UBUNTU_NOBLE=$(if $(shell dpkg-vendor --derives-from Ubuntu && echo y),ON,OFF) \
		-DENABLE_MIRCLIENT=OFF \
		-DENABLE_QT6=OFF \
		-DENABLE_UBUNTU_COMPAT=OFF
	dh_auto_configure --builddirectory=build-qt6 -- \
		-DBUILD_TESTING=$(if $(filter nocheck,$(DEB_BUILD_OPTIONS)),OFF,ON) \
		-DDISABLE_TESTS_THAT_FAIL_ON_UBUNTU_NOBLE=$(if $(shell dpkg-vendor --derives-from Ubuntu && echo y),ON,OFF) \
		-DENABLE_MIRCLIENT=OFF \
		-DENABLE_QT6=ON \
		-DENABLE_UBUNTU_COMPAT=OFF

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

override_dh_auto_test:
	dh_auto_test --builddirectory=build-qt5
	dh_auto_test --builddirectory=build-qt6

execute_before_dh_install:
	# empty directories
	rmdir debian/tmp/usr/share/doc/qml-module-lomiri-onlineaccounts/html/images/
	rmdir debian/tmp/usr/share/doc/qml-module-lomiri-onlineaccounts-client/html/images/

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

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

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