#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DEBIAN_DIR = $(shell pwd)/debian

evolution_major_version := $(shell dpkg-query -W -f="\$${Version}\n" evolution-dev | cut -d. -f-2)
evolution_next_version := $(shell echo $(evolution_major_version) | cut -d. -f1).$(shell echo $$(($$(echo $(evolution_major_version) | cut -d. -f2) + 1)))

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp

configure: configure-stamp
configure-stamp:
	dh_testdir
	dh_autotools-dev_updateconfig
	gtk-builder-convert ui/mailbox-properties-dialog.glade ui/mailbox-properties-dialog.ui
	gtk-builder-convert ui/properties-dialog.glade ui/properties-dialog.ui
	sed -i s@'<property name="has_separator">False</property>'@@ ui/mailbox-properties-dialog.ui
	sed -i s@'<property name="has_separator">False</property>'@@ ui/properties-dialog.ui
	./jb configure prefix=/usr sysconfdir=/etc destdir=$(DEBIAN_DIR)/tmp/ cflags="$(shell dpkg-buildflags --get CFLAGS)" cppflags="$(shell dpkg-buildflags --get CPPFLAGS)" ldflags="$(shell dpkg-buildflags --get LDFLAGS)"
	touch $@

build-stamp: configure-stamp
	dh_testdir
	./jb build
	touch $@


clean:
	dh_testdir
	dh_testroot

	rm -rf build
	-rm -f build-stamp configure-stamp install-stamp ui/*.ui
	dh_autotools-dev_restoreconfig
	dh_clean


install: build install-stamp
install-stamp:
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	./jb install

	touch $@


# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
#	dh_testversion
	dh_testdir
	dh_testroot
	dh_install
#	dh_desktop -pmail-notification etc/xdg/autostart/mail-notification.desktop
	dh_installdocs
	dh_installmenu
	dh_installman -pmail-notification debian/mail-notification.1
	dh_gconf -pmail-notification
#	dh_desktop
#	dh_undocumented
	dh_installchangelogs 
	dh_link 
	dh_strip
	dh_compress
	dh_fixperms
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol -- -Vevo:majorVersion=$(evolution_major_version) -Vevo:nextVersion=$(evolution_next_version)
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
