#!/usr/bin/make -f

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

ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
configure_options += --cross-file=$(DEB_HOST_GNU_TYPE)-gobject-introspection.ini
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		-Dgtk_doc=$(if $(filter %-doc,$(shell dh_listpackages)),true,false) \
		-Dman-pages=$(if $(filter %-tools,$(shell dh_listpackages)),true,false) \
		-Dinstall-tests=true \
		-Dsysprof=$(if $(filter linux,$(DEB_HOST_ARCH_OS)),enabled,disabled) \
		$(configure_options)

override_dh_auto_test-arch:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	debian/tests/run-with-locales \
		--generate en_US.utf8 \
		-- \
	env \
		LC_ALL=en_US.utf8 \
	dh_auto_test
endif

# Skip build-time tests if all we are building is documentation; running
# them once per architecture is plenty
override_dh_auto_test-indep:
	@:

# 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 --recursive --changes a+rX,u+w,og-w debian/*-tests/usr/libexec/installed-tests
endif

override_dh_makeshlibs:
	dh_makeshlibs --add-udeb=libpango1.0-udeb
