#!/usr/bin/make -f

%:
	dh $@ --with autoreconf

override_dh_install:
	dh_install --list-missing

override_dh_auto_configure:
	cp libmatekbd/matekbd-indicator-marshal.c libmatekbd/matekbd-indicator-marshal.c.keep
	cp libmatekbd/matekbd-keyboard-drawing-marshal.c libmatekbd/matekbd-keyboard-drawing-marshal.c.keep
	dh_auto_configure -- \
		--disable-static

override_dh_makeshlibs:
	dh_makeshlibs -V 'libmatekbd4 (>= 1.6.1)'

override_dh_strip:
	dh_strip --dbg-package=libmatekbd-dbg

override_dh_auto_clean:
	-mv libmatekbd/matekbd-indicator-marshal.c.keep libmatekbd/matekbd-indicator-marshal.c
	-mv libmatekbd/matekbd-keyboard-drawing-marshal.c.keep libmatekbd/matekbd-keyboard-drawing-marshal.c
	dh_auto_clean

PKD      = $(abspath $(dir $(MAKEFILE_LIST)))
PKG      = $(word 2,$(shell dpkg-parsechangelog -l$(PKD)/changelog | grep ^Source))
UVER     = $(shell dpkg-parsechangelog -l$(PKD)/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\-\d+.*)};')
REALUVER = $(shell echo $(UVER) | sed -e s/1.7.1.is.//)

get-orig-source:
# keep this if clause as long 1.6.x of libmatekbd upstream is packaged
	if [ "$(UVER)" = "1.7.1.is.$(REALUVER)" ]; then \
	    uscan --noconf --force-download --rename --download-version $(REALUVER) --destdir=.. ; \
	    mv -v ../$(PKG)_$(REALUVER).orig.tar.xz ../$(PKG)_$(UVER).orig.tar.xz; \
	else \
	    uscan --noconf --force-download --rename --download-current-version --destdir=.. ; \
	fi
