#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1 -Wl,--as-needed -Wl,-Bsymbolic
export BUILDDIR = $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)

%:
	dh $@ --with gir,gnome

override_dh_auto_configure:
	dh_auto_configure -- \
		-Dunicode_support=icu \
		-Dfts=true \
		-Dstemmer=enabled \
		-Ddocs=true \
		-Dfunctional_tests=true \
		-Dnetwork_manager=disabled \
		-Dsystemd_user_services=/usr/lib/systemd/user

# These utils are not used by tracker-miners yet, but they will be used by it
# soon. See upstream commit 8ae991922
override_dh_install:
	rm -rv debian/tmp/usr/lib/*/tracker-2.0/trackertestutils
	dh_install

override_dh_missing:
	dh_missing --fail-missing

# Enforce tight shlibs dependencies
override_dh_makeshlibs:
	dh_makeshlibs -V -X/usr/lib/$(DEB_HOST_MULTIARCH)/tracker-2.0/ -- -c4

override_dh_strip:
	dh_strip --dbgsym-migration='tracker-dbg (<< 1.7.4-1~)'

override_dh_auto_test:
ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
	mkdir -p -m0755 $(BUILDDIR)/HOME
	mkdir -p -m0700 $(BUILDDIR)/XRD
	env HOME=$(BUILDDIR)/HOME XDG_RUNTIME_DIR=$(BUILDDIR)/XRD \
		dbus-run-session -- dh_auto_test --no-parallel || true
endif
