#!/usr/bin/make -f
# -*- makefile -*-

export DPKG_GENSYMBOLS_CHECK_LEVEL=4
export QT_SELECT=qt5

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

%:
	dh $@

override_dh_auto_configure:
	# Backup .db file that gets modified during build...
	cp plugins/bn/src/database_bn.db plugins/bn/src/database_bn.db.bak
	dh_auto_configure -- -recursive \
	                     MALIIT_DEFAULT_PROFILE=lomiri \
	                     CONFIG+=debug \
	                     CONFIG+=nodoc \
	                     CONFIG+=enable-presage \
	                     CONFIG+=enable-hunspell \
	                     CONFIG+=enable-pinyin

override_dh_auto_test:
	# Tests write $HOME/.presage/lm.db, make sure $HOME is
	# writable.
	rm -rf $(CURDIR)/debian/test-home
	mkdir -p $(CURDIR)/debian/test-home
	HOME=$(CURDIR)/debian/test-home xvfb-run -a make check

execute_before_dh_clean:
	rm -rf $(CURDIR)/debian/test-home
	# Restore .db file that gets modified at build time
	-mv plugins/bn/src/database_bn.db.bak plugins/bn/src/database_bn.db
	# Remove .mo files from po/ after build (before next build)
	-rm po/*.mo

execute_after_dh_fixperms:
	# ignore if this fails (during arch:all builds)
	-chmod 0644 debian/lomiri-keyboard-bengali-avro/usr/lib/lomiri-keyboard/plugins/bn-avro/data/regex.json

execute_after_dh_install:
	rm -fv  debian/tmp/usr/bin/ut_*
	rm -Rfv debian/tmp/usr/share/maliit/tests/lomiri-keyboard/*

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=..
