#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk
include /usr/share/dpkg/vendor.mk

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

ifeq (,$(findstring $(DEB_HOST_ARCH), amd64 arm64 armel armhf hppa i386 ia64 mips mips64 mips64el mipsel powerpc powerpcspe ppc64 ppc64el sh4))
	BUILD_UNWIND += -Dlibunwind_optional=true
endif
# see https://gitlab.gnome.org/GNOME/geary/issues/726:
ifneq (,$(filter $(DEB_HOST_ARCH), powerpc s390x))
	DISABLE_YTNEF += -Dtnef-support=false
endif

%:
	dh $@ --buildsystem=meson

override_dh_auto_configure:
	dh_auto_configure -- $(BUILD_UNWIND) $(DISABLE_YTNEF) -Drevno=$(DEB_VENDOR)/$(DEB_VERSION)

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	localehelper LC_COLLATE=en_US.UTF-8 xvfb-run -a dh_auto_test
endif

override_dh_shlibdeps:
	dh_shlibdeps -l/usr/lib/$(DEB_HOST_MULTIARCH)/geary

override_dh_makeshlibs:
	dh_makeshlibs --no-scripts
