#!/usr/bin/make -f

FLAVORS = gtk3
API_VERSION = 0.1

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)

CONFIGURE_COMMON_FLAGS = --disable-scrollkeeper --enable-introspection \
	--disable-mono-test
CONFIGURE_FLAGS_gtk3 = --with-gtk=3 --enable-gtk-doc

export DPKG_GENSYMBOLS_CHECK_LEVEL = 4

CFLAGS += -fPIC

%:
	dh $@ --with autoreconf,gir$(dh_extra_args)

override_dh_autoreconf:
	NOCONFIGURE=1 dh_autoreconf ./autogen.sh

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

doconfigure-%:
	dh_auto_configure --builddirectory=build/$* -- $(CONFIGURE_FLAGS_$*) $(CONFIGURE_COMMON_FLAGS)

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

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

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

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

override_dh_install:
	find debian/tmp -name \*.la -exec rm {} \;
	find debian/tmp -name \*.a -exec rm {} \;
	rm -rf debian/tmp/*/usr/lib/mono
	rm -rf debian/tmp/*/usr/share/vala/vapi/appindicator*-0.1.deps
	dh_install -plibappindicator-doc --fail-missing --sourcedir=debian/tmp/gtk3
	dh_install -plibappindicator3-1 --fail-missing --sourcedir=debian/tmp/gtk3
	dh_install -plibappindicator3-dev --fail-missing --sourcedir=debian/tmp/gtk3
	dh_install -pgir1.2-appindicator3-0.1 --fail-missing --sourcedir=debian/tmp/gtk3

override_dh_auto_test: $(FLAVORS:%=dotest-%)

dotest-%:
	dh_auto_test --builddirectory=build/$* --

override_dh_auto_clean:
	dh_auto_clean
	rm -rf build

# No dbgsym packages:
override_dh_strip:
	@echo "NO--THANKS ANYWAY--but not building dbgsym packages for MX Linux"
	dh_strip --no-automatic-dbgsym

