#!/usr/bin/make -f

include /usr/share/dpkg/default.mk
# export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Convert "0.9+git20250413+ds" -> "20250413"
export DEB_UPSTREAM_COMMIT = $(shell echo "$(DEB_VERSION_UPSTREAM)" | sed -E 's/.*\+git([[:digit:]]+)\+.*/\1/')
export DEB_UPSTREAM_DATE = $(shell date -d @$(SOURCE_DATE_EPOCH) --rfc-3339=seconds)

# compile nlohmann-json3 without versioned namespaces: #1106432
export DEB_CXXFLAGS_MAINT_APPEND = -DNLOHMANN_JSON_NAMESPACE_NO_VERSION
NL3_VERSION = $(shell dpkg-query '--showformat=$${Version}' --show 'nlohmann-json3-dev')

%:
	dh $@

# install user service without enabling or starting it
override_dh_installsystemd:
	dh_installsystemduser --no-enable

override_dh_gencontrol:
	test ! -z "$(NL3_VERSION)"
	dh_gencontrol -- -VStaticBuiltUsing="nlohmann-json3-dev (= $(NL3_VERSION))"
