#!/usr/bin/make -f
#export DH_VERBOSE=1

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

# qhelpgenerator stamps CreationTime/LastRegisterTime and the per-file
# TimeStamp into the embedded Qt Help collection (manual-en_US.qhc), which is
# compiled into the binary. Make sure it honors SOURCE_DATE_EPOCH so the
# generated help is reproducible regardless of the build time/locale/TZ.
# Default to the package's own changelog timestamp if the build system did
# not already export SOURCE_DATE_EPOCH (same source dpkg-buildpackage uses).
export SOURCE_DATE_EPOCH ?= $(shell dpkg-parsechangelog -STimestamp)

%:
	dh $@ --buildsystem=cmake --sourcedirectory=src

execute_before_dh_auto_configure:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS) $(DEB_BUILD_PROFILES)))
	cd doc/src && $(MAKE) QHELPGENERATOR=/usr/lib/qt6/libexec/qhelpgenerator build-bundled update-prebuilt-manual
endif

override_dh_auto_build:
	dh_auto_build -- VERBOSE=1
	docbook2x-man debian/speedcrunch.1.docbook
	convert -resize 32x32 src/resources/speedcrunch.png speedcrunch.xpm

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	QT_QPA_PLATFORM=offscreen dh_auto_test -- 'ARGS+=-E ^testdisplayui'
endif
