#!/usr/bin/make -f

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

%:
	dh $@ --with gir,gnome

override_dh_autoreconf:
	dh_autoreconf --as-needed

ifeq ($(DEB_HOST_ARCH_OS),linux)
CONFFLAGS = \
	--enable-egl-device \
	--enable-wayland \
	--enable-native-backend
else
CONFFLAGS += \
	--disable-wayland-egl-platform \
	--disable-wayland-egl-server \
	--disable-kms-egl-platform \
	--disable-wayland \
	--disable-native-backend
endif

override_dh_auto_configure:
	dh_auto_configure -- \
		--libexecdir="\$${prefix}/lib/mutter" \
		--enable-startup-notification \
		--enable-compile-warnings \
		$(CONFFLAGS)

# See https://bugs.debian.org/874077
# Ignore test failures on Debian and on s390x
override_dh_auto_test:
ifneq (,$(findstring $(DEB_HOST_ARCH),"s390x"))
	-xvfb-run dh_auto_test
else ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes))
	xvfb-run dh_auto_test
else
	-xvfb-run dh_auto_test
endif

override_dh_install:
	find debian/tmp -name '*.la' -print -delete
	dh_install

override_dh_missing:
	dh_missing --fail-missing

override_dh_girepository:
	dh_girepository /usr/lib/$(DEB_HOST_MULTIARCH)/mutter

override_dh_makeshlibs:
	dh_makeshlibs -V'libmutter-2-0 (>= 3.27.91)'

override_dh_strip:
	dh_strip --dbgsym-migration='mutter-dbg (<< 3.18.3-2~)'

