#!/usr/bin/make -f

DEB_SRCDIR = .
DEB_BUILDDIR = $(DEB_SRCDIR)/build

CFLAGS = $(shell dpkg-buildflags --get CFLAGS) -Wno-error=deprecated-declarations

include /usr/share/cdbs/1/rules/autoreconf.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/gnome.mk
include /usr/share/cdbs/1/rules/utils.mk

API_VERSION = 0.1

#DEB_MAKE_CHECK_TARGET := check

DEB_CONFIGURE_EXTRA_FLAGS += --disable-scrollkeeper --disable-gtk-doc --enable-introspection
DEB_CONFIGURE_EXTRA_FLAGS += --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)

configure-stamp: 
	cd $(DEB_BUILDDIR) && \
		$(DEB_CONFIGURE_SCRIPT) $(DEB_CONFIGURE_NORMAL_ARGS) $(DEB_CONFIGURE_EXTRA_FLAGS)
	touch $@

configure/libappindicator1:: configure-stamp

build-stamp: 
	$(MAKE) -C $(DEB_BUILDDIR)
	touch $@

build/libappindicator1:: build-stamp

install-stamp:
	$(MAKE) -C $(DEB_BUILDDIR) install DESTDIR=$(CURDIR)/debian/tmp
	touch $@

binary-install/libappindicator1:: install-stamp install-stamp-gtk3
	dh_makeshlibs -plibappindicator1


configure-stamp-gtk3:
	: # configure for GTK+ 3.0
	rm -rf build-gtk3; \
	mkdir build-gtk3; \
	cd build-gtk3; \
	$(DEB_BUILD_MAINT_OPTIONS) CFLAGS="$(CFLAGS)" ../configure --with-gtk=3 \
		$(filter-out --enable-gtk-doc, $(filter-out --srcdir=%, $(DEB_CONFIGURE_NORMAL_ARGS) $(DEB_CONFIGURE_EXTRA_FLAGS))) \
		--enable-gtk-doc=no; \
	cd ..;
	touch $@

configure/libappindicator3-1:: configure-stamp-gtk3

build-stamp-gtk3:
	: # build for GTK+ 3.0
	$(MAKE) -C build-gtk3/src;
	$(MAKE) -C build-gtk3/bindings/vala;
	touch $@

build/libappindicator3-1:: build-stamp-gtk3

install-stamp-gtk3:
	: # install for GTK+ 3.0
	$(MAKE) -C build-gtk3/src DESTDIR=$(CURDIR)/debian/tmp install
	$(MAKE) -C build-gtk3/bindings/vala DESTDIR=$(CURDIR)/debian/tmp install
	touch $@

binary-install/libappindicator3-1:: install-stamp-gtk3
	dh_makeshlibs -plibappindicator3-1

binary-predeb/gir%::
	dh_girepository -p$(cdbs_curpkg)

common-binary-predeb-arch:: list-missing
	dh_fixperms
	dh_strip
	cd po; intltool-update --pot --verbose

clean::
	rm -f configure-stamp*
	rm -f build-stamp*
	rm -f install-stamp*
	rm -rf build
	rm -rf build-gtk3
