#!/usr/bin/make -f

.PHONY: override_dh_auto_configure override_dh_auto_test override_dh_auto_install override_dh_installdocs

export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export QT_SELECT=6

# Give the build more time to finish the test suite.
# Timeouts have been appearing on buildd machines for some architectures.
export GAMMARAY_LAUNCHER_TIMEOUT=240

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

%:
	dh $@ --with pkgkde_symbolshelper --buildsystem=cmake+ninja

override_dh_auto_configure:
	dh_auto_configure -- \
		--log-level=STATUS \
		-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) \
		-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE \
		-DQT_VERSION_MAJOR=6 \
		-DECM_MKSPECS_INSTALL_DIR=/usr/lib/${DEB_HOST_MULTIARCH}/qt6/mkspecs/modules \
		-DPLUGIN_INSTALL_DIR=/usr/lib/${DEB_HOST_MULTIARCH}/qt6/plugins/gammaray \
		-DGAMMARAY_BUILD_DOCS=TRUE \
		-DGAMMARAY_USE_PCH=TRUE \
		-DQT_VERSION_MAJOR=6 /
		-DGAMMARAY_WITH_KDSME=TRUE
#		-DENABLE_GOLD_LINKER=TRUE

override_dh_auto_install:
	dh_auto_install
	rm -f debian/tmp/usr/share/doc/gammaray/LICENSE.*

#execute_after_dh_auto_install:
#	# Reproducible builds: remove build paths from .prl files
#	sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libQt6*.prl

override_dh_auto_test:
    :

override_dh_installdocs:
	dh_installdocs --link-doc=gammaray
