#!/usr/bin/make -f

binaries := $(shell dh_listpackages)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1 -Wl,-z,defs

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		-Dinstalled_tests=true

override_dh_auto_test:
	dh_auto_test -- --timeout-multiplier 3

# debhelper >= 13.4 makes all of /usr/libexec executable, which is not
# quite right for installed-tests
override_dh_fixperms:
	dh_fixperms -Xusr/libexec/installed-tests
ifneq ($(filter %-tests,$(binaries)),)
	chmod --changes u=rw,og=r debian/*-tests/usr/libexec/installed-tests/*/*.so
	chmod --recursive --changes a+rX,u+w,og-w debian/*-tests/usr/libexec/installed-tests
endif

# Don't strip translations from the installed tests; makes them environment dependent.
override_dh_translations:
	dh_translations -Xinstalled-tests
