#!/usr/bin/make -f

VERSION       = $(shell dpkg-parsechangelog | egrep '^Version: ' | sed 's/Version: //' | sed 's/-.*//')
CMAKE_OPTIONS = -DWANT_MONO=ON -DEMBED_DATA=OFF -DCMAKE_BUILD_TYPE=Debugfull

%:
	dh $@ --buildsystem=cmake --with=kde --parallel

override_dh_clean:
	dh_clean
	rm -rf debian/build-qt4 debian/tmp-qt4

override_dh_auto_configure:
	dh_auto_configure -Skde -- -DWITH_KDE=ON $(CMAKE_OPTIONS)
	dh_auto_configure -Bdebian/build-qt4 -- -DWITH_KDE=OFF -DWANT_CORE=OFF $(CMAKE_OPTIONS)

override_dh_auto_build:
	dh_auto_build -Skde
	dh_auto_build -Bdebian/build-qt4

override_dh_auto_install:
	dh_auto_install -Skde
	dh_auto_install -Bdebian/build-qt4 --destdir=$(CURDIR)/debian/tmp-qt4

override_dh_install:
	dh_install
	pod2man --section=1 --release=$(VERSION) --center "" debian/mans/quassel.pod > quassel.1
	pod2man --section=1 --release=$(VERSION) --center "" debian/mans/quasselcore.pod > quasselcore.1
	pod2man --section=1 --release=$(VERSION) --center "" debian/mans/quasselcore-makecert.pod > quasselcore-makecert.1
	pod2man --section=1 --release=$(VERSION) --center "" debian/mans/quasselclient.pod > quasselclient.1
	[ ! -d debian/quassel-data ] || rm -rf debian/quassel-data/usr/share/kde4/apps/quassel/icons/oxygen/scalable/

override_dh_installinit:
	dh_installinit -r --error-handler=exit --name=quasselcore

override_dh_strip:
	# only strip the KDE stuff to the dbg package
	dh_strip -Nquassel-qt4 -Nquassel-client-qt4 --dbg-package=quassel-dbg
	dh_strip --remaining-packages
