#!/usr/bin/make -f
-include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk

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

CHECK_HOME = $(CURDIR)/debian/tmp/home

%:
	dh $@ --with gir,gnome

override_dh_auto_configure:
	dh_auto_configure -- \
                             -Denable_vala=true \
                             -Dgtk_doc=true \
                             -Dglade-catalog=true

override_dh_makeshlibs:
	dh_makeshlibs -- -c4

override_dh_missing:
	dh_missing --fail-missing

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir -p $(CHECK_HOME)
	# Ignore test failures since tests require Internet access
	env XDG_RUNTIME_DIR=$(CHECK_HOME) dh_auto_test || true
endif

override_dh_clean:
	rm -rf $(CHECK_HOME)
	dh_clean

# Needed by Ubuntu
override_dh_translations:
	ninja -C obj-$(DEB_HOST_GNU_TYPE) libgweather-3.0-pot
	# Workaround gettext crash https://bugzilla.gnome.org/793752
	ninja -C obj-$(DEB_HOST_GNU_TYPE) libgweather-locations-pot || true
	dh_translations

override_dh_auto_clean:
	dh_auto_clean
	rm -f po/libgweather-3.0.pot
	rm -f po-locations/libgweather-locations.pot
