#!/usr/bin/make -f

-include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk

GNOME_MODULE = clutter

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

ifeq ($(DEB_HOST_ARCH_OS),linux)
	CONFFLAGS += \
		--enable-wayland-backend=yes \
		--enable-wayland-compositor=yes \
		--enable-evdev-input=yes
endif

%:
	dh $@ --with gir,gnome

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	dh_auto_configure -- \
		--enable-x11-backend=yes \
		--enable-gdk-backend=yes \
		--enable-egl-backend=yes \
		--enable-gtk-doc \
		--disable-docs \
		--enable-installed-tests \
		--enable-introspection=yes \
		$(CONFFLAGS)

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

override_dh_missing:
	dh_missing --fail-missing

override_dh_compress:
	dh_compress -X.c

override_dh_gnome:
	dh_gnome --no-gnome-versions

override_dh_makeshlibs:
	dh_makeshlibs -V -- -c4

# Ignore test failures on Debian. See https://bugs.debian.org/874077
override_dh_auto_test:
ifneq (,$(findstring $(DEB_HOST_ARCH),"s390x"))
	# Don't run the tests on s390x since it hangs the build on Launchpad
else ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes))
	dbus-run-session -- xvfb-run -a dh_auto_test
else
	-dbus-run-session -- xvfb-run -a dh_auto_test
endif

override_dh_strip:
	dh_strip --dbgsym-migration='libclutter-1.0-dbg (<< 1.26.2+dfsg-2~)'
