#!/usr/bin/make -f

DEB_CONFIGURE_EXTRA_FLAGS := --libdir=/usr/lib --enable-purple --disable-telepathy --enable-openssl=no

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_auto_configure:
	./autogen.sh
	dh_auto_configure -- $(DEB_CONFIGURE_EXTRA_FLAGS)

override_dh_auto_install:
	dh_auto_install

	find debian/pidgin-sipe -name *.la -delete

	dh_install debian/extra/pidgin usr/bin
	dh_install debian/extra/pidgin-sipe etc/default

override_dh_strip:
	dh_strip --dbgsym-migration='pidgin-sipe-dbg (<< 1.21.0-1~)'

override_dh_installdocs:
	dh_installdocs --link-doc=pidgin-sipe

override_dh_auto_clean:
	# Preserve pot file from being deleted as it's a part of orig tarball.
	mv po/pidgin-sipe.pot po/pidgin-sipe.pot.keep
	dh_auto_clean
	mv po/pidgin-sipe.pot.keep po/pidgin-sipe.pot

	rm -f GITVERSION INSTALL aclocal.m4 compile config.guess config.h.in config.sub configure \
		depcomp install-sh intltool-extract.in intltool-merge.in intltool-update.in ltmain.sh \
		missing test-driver
	find -type f -name Makefile.in\* -delete

VERSION=$(shell dpkg-parsechangelog -S Version | cut -d- -f1)
get-orig-source:
	uscan --force-download --download-version $(VERSION) \
		--rename --destdir=$(CURDIR) \
		--repack --compression xz

.PHONY: override_dh_auto_configure override_dh_auto_install override_dh_strip override_dh_installdocs override_dh_auto_clean get-orig-source
