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

FLAVOURS = gtk2 gtk3

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

COMMON_CONFIGURE_FLAGS = -DENABLE_X11=ON
COMMON_CONFIGURE_FLAGS += -DLIB_INSTALL_DIR="lib/${DEB_HOST_MULTIARCH}"

CONFIGURE_FLAGS_gtk2 = -DENABLE_GTK2=ON -DENABLE_GTK3=OFF
CONFIGURE_FLAGS_gtk3 = -DENABLE_GTK3=ON -DENABLE_GTK2=OFF

%:
	dh $@

override_dh_auto_configure: $(FLAVOURS:%=doconfigure-%)

doconfigure-%:
	DH_VERBOSE=1 dh_auto_configure --builddirectory=builddir/$* -- $(COMMON_CONFIGURE_FLAGS) $(CONFIGURE_FLAGS_$*)

override_dh_auto_build: $(FLAVOURS:%=dobuild-%)

dobuild-%:
	dh_auto_build --builddirectory=builddir/$*

override_dh_auto_test:
	xvfb-run -a dh_auto_test --no-parallel --builddirectory=builddir/gtk2
	xvfb-run -a dh_auto_test --no-parallel --builddirectory=builddir/gtk3

override_dh_auto_install: $(FLAVOURS:%=doinstall-%)

doinstall-%:
	dh_auto_install --builddirectory=builddir/$* --destdir=debian/tmp/$*

override_dh_install:
	dh_install -pmaliit-inputcontext-gtk3 --sourcedir=debian/tmp/gtk3
	dh_install -pmaliit-inputcontext-gtk2 --sourcedir=debian/tmp/gtk2

override_dh_missing:
	dh_missing -pmaliit-inputcontext-gtk3 --sourcedir=debian/tmp/gtk3 --fail-missing
	dh_missing -pmaliit-inputcontext-gtk2 --sourcedir=debian/tmp/gtk2 --fail-missing

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