#!/usr/bin/make -f

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

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

ifeq ($(shell dpkg-vendor --is Ubuntu && echo yes) $(DEB_HOST_ARCH), yes i386)
   skip_packages = -Ngnome-online-accounts
endif

CFLAGS += -Wno-error

%:
	dh $@

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	dh_auto_configure -- \
		--enable-documentation \
		--enable-gtk-doc \
		--enable-kerberos \
		--disable-media-server \
		--disable-facebook \
		--enable-flickr \
		--disable-fedora \
		--enable-windows-live \
		--enable-google \
		--enable-owncloud \
		--enable-imap-smtp \
		--enable-exchange \
		--enable-foursquare

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

override_dh_missing:
	dh_missing --fail-missing

override_dh_makeshlibs:
	dh_makeshlibs -- -c4

override_dh_translations:
	mv po/gnome-online-accounts.pot po/gnome-online-accounts.pot.bak
	dh_translations

override_dh_clean:
	if [ -f po/gnome-online-accounts.pot.bak ]; then \
		mv po/gnome-online-accounts.pot.bak po/gnome-online-accounts.pot; \
	fi
	dh_clean

override_dh_builddeb:
	dh_builddeb ${skip_packages}

override_dh_gencontrol:
	dh_gencontrol ${skip_packages}
