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

include /usr/share/dpkg/default.mk

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

export DPKG_GENSYMBOLS_CHECK_LEVEL=4

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

export QT_SELECT=qt5

%:
	dh $@

ifneq (,$(filter powerpc,$(DEB_HOST_ARCH)))
  test_arg = || :
else
  test_arg =
endif

override_dh_auto_configure:
	dh_auto_configure --builddirectory=build-qt5 --buildsystem=cmake .. -- -DENABLE_QT6=OFF
	dh_auto_configure --builddirectory=build-qt6 --buildsystem=cmake .. -- -DENABLE_QT6=ON

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

override_dh_auto_test:
	dh_auto_test --builddirectory=build-qt5 --buildsystem=cmake .. -- ARGS="--verbose" $(test_arg)
	dh_auto_test --builddirectory=build-qt6 --buildsystem=cmake .. -- ARGS="--verbose" $(test_arg)

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

override_dh_installdeb:
	dh_apparmor --profile-name=usr.bin.mediascanner-service-2.0 -pmediascanner2.0
	dh_apparmor --profile-name=usr.lib.mediascanner-2.0.mediascanner-extractor -pmediascanner2.0
	dh_installdeb

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