#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --buildsystem=cmake

# Force Qt 6 selection in case both Qt 5 and Qt 6 dev headers are present;
# the upstream find_package(QT NAMES Qt6 Qt5 ...) call would otherwise pick
# whichever appears first on disk. The embedded Capstone and cJSON copies are
# stripped from the source package (Files-Excluded), so link the packaged
# libraries instead.
override_dh_auto_configure:
	dh_auto_configure -- \
		-DQT_VERSION_MAJOR=6 \
		-DHEXWALK_USE_SYSTEM_CAPSTONE=ON \
		-DHEXDIG_USE_SYSTEM_CJSON=ON

# Upstream wires a Python regression suite into ctest only when hexdig is
# the top-level project, so the test target is empty at this scope. Keep
# the override to make that explicit and to avoid surprises if it changes.
override_dh_auto_test:

# hexwalk/CMakeLists.txt sets RUNTIME_OUTPUT_DIRECTORY to ${CMAKE_SOURCE_DIR}/bin,
# so the built executable lands inside the source tree and dh_auto_clean, which
# only removes the build directory, leaves it behind. Policy requires clean to
# restore the tree, and without this dpkg-buildpackage fails the second time
# round with "unrepresentable changes to source".
override_dh_auto_clean:
	dh_auto_clean
	rm -rf bin
