#!/usr/bin/make -f

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

%:
	dh $@ --with gnome

override_dh_auto_configure:
	dh_auto_configure -- \
		--with-pam-dir=/lib/$(DEB_HOST_MULTIARCH)/security \
		--enable-docs \
		--enable-ssh-agent

override_dh_install:
	find debian/tmp -name '*.la' -print -delete
	dh_install
ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes))
	install -m0755 -D debian/gnome-keyring.ubiquity debian/gnome-keyring/usr/lib/ubiquity/target-config/50gkd-caps
endif

override_dh_missing:
	dh_missing --fail-missing

TESTHOMEDIR = $(CURDIR)/debian/testhome

override_dh_auto_test:
ifeq (testsuitedisabled, $(filter nocheck, $(DEB_BUILD_OPTIONS)))
	mkdir -p $(TESTHOMEDIR)
	env -u LD_PRELOAD HOME=$(TESTHOMEDIR) XDG_RUNTIME_DIR=$(TESTHOMEDIR) dbus-run-session -- dh_auto_test
endif

override_dh_clean:
	rm -rf $(TESTHOMEDIR)
	dh_clean
