#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

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

binaries := $(shell dh_listpackages)

ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
ifneq ($(filter libgladeui-doc,$(binaries)),)
	ENABLE_DOCS = -Dgtk_doc=true
endif
endif
ifneq (,$(filter $(DEB_HOST_ARCH), ia64 kfreebsd-amd64 kfreebsd-i386))
	ENABLE_WEBKIT = -Dwebkit2gtk=disabled
endif
ifeq (,$(filter $(DEB_HOST_ARCH), amd64 arm64 armhf mips64el mipsel ppc64el s390x riscv64))
	ENABLE_GJS = -Dgjs=disabled
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- -Dauto_features=enabled $(ENABLE_DOCS) $(ENABLE_WEBKIT) $(ENABLE_GJS)

TEST_COMMAND = NO_AT_BRIDGE=1 dh_auto_test -- --wrap="dbus-run-session -- xvfb-run -a" \
	--timeout-multiplier 5

override_dh_auto_test:
	$(TEST_COMMAND) || DEB_HOST_ARCH=$(DEB_HOST_ARCH) debian/debug-test-failure

# There's unclear precedent in the Debian archive for which package
# should install the ITS files. These files probably aren't needed yet anyway.
override_dh_missing:
	dh_missing -X/usr/share/gettext/
