#!/usr/bin/make -f

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

ifeq ($(DEB_HOST_ARCH_OS),linux)
ENABLE_SELINUX := -Dselinux=true
else
ENABLE_SELINUX := -Dselinux=false
endif

ENC_FILES:=$(wildcard debian/source/icons/*.png)

%:
	dh $@ --with gir,gnome

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	$(foreach f,$(ENC_FILES),cp $f icons/;)
	dh_auto_configure -- \
		-Ddocs=true \
		-Dextension=true \
		-Dpackagekit=true \
		-Dtests=none \
		$(ENABLE_SELINUX)

override_dh_strip:
	dh_strip --dbgsym-migration='nautilus-dbg (<< 3.20.0-1~)'

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir -p -m0700 $(CURDIR)/debian/tmp-home/run
	touch $(CURDIR)/debian/tmp-home/.gtk-bookmarks
	env \
		HOME=$(CURDIR)/debian/tmp-home \
		XDG_RUNTIME_DIR=$(CURDIR)/debian/tmp-home/run \
		dbus-run-session -- xvfb-run dh_auto_test
	rm -fr debian/tmp-home
endif

override_dh_makeshlibs:
	dh_makeshlibs -- -c4

override_dh_missing:
	dh_missing --fail-missing
