#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Package names
PKG_version     := $(shell dpkg-parsechangelog | sed -n 's/^Version: //p')
PKG_source      := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
UPS_version     := $(shell echo '$(PKG_version)' | sed 's/.*://; s/-[^-]*$$//')
GIT_rev         := $(shell echo '$(UPS_version)' | sed 's/.*+//')
GIT_repo        := https://git.gitorious.org/maliit/maliit-plugins.git

comma :=,
empty :=
space := $(empty) $(empty)

# Build options
QMAKE_OPTIONS = \
	CONFIG+=debug \
	CONFIG+=nodoc \
	CONFIG+=notests

get-packaged-orig-source:
	rm -rf $(PKG_source)-$(UPS_version)
	rm -f $(PKG_source)-$(UPS_version).orig.tar.gz
	git clone $(GIT_repo) $(PKG_source)-$(UPS_version)
	cd $(PKG_source)-$(UPS_version) && git archive \
		--format tar \
		--prefix $(PKG_source)-$(UPS_version)/ \
		$(GIT_rev) \
		| gzip >../$(PKG_source)_$(UPS_version).orig.tar.gz
	rm -rf $(PKG_source)-$(UPS_version)

override_dh_auto_configure:
	dh_auto_configure -- -r $(QMAKE_OPTIONS)

override_dh_auto_test:
	xvfb-run dh_auto_test

override_dh_install:
	dh_install --list-missing \
		--fail-missing \
		-Xsounds/LICENSE \
		-Xmaliit-keyboard-benchmark \
		-Xmaliit-keyboard-viewer

%:
	dh $@ --buildsystem=qmake
