#! /usr/bin/make -f
#
DH_ALWAYS_EXCLUDE:=CVS:.svn:.svnignore:.hg:.hgignore

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--no-undefined -Wl,--as-needed

DEBVERSION = $(shell head -n 1 debian/changelog | sed -e 's/^[^(]*(\([^)]*\)).*/\1/')
UPVERSION = $(shell echo $(DEBVERSION) | sed -r -e 's/^.*://' -e 's/-[0-9.]*(\+b[0-9])?$$//' -e 's/.dfsg[0-9]*$$//')
REV = $(shell echo $(UPVERSION) | sed -e 's/^.*svn//' -e 's/\+rc[0-9]$$//')

# We don't install all files upstream wants to. Those files get added to
# the following variable which gives us a cleaner buildd output (idea taken
# from the mesa package).
NOT_INSTALLED := \
				usr/lib/$(DEB_HOST_MULTIARCH)/libkvilib.so \
				usr/bin/kvirc-config \
				usr/share/kvirc/4.2/license/LICENSE-GPLV2 \
				usr/share/kvirc/4.2/license/LICENSE-GPLV3 \
				usr/share/kvirc/4.2/license/LICENSE-OPENSSL \
				usr/share/pixmaps/kvirc.png # this one is installed by a symlink

override_dh_auto_configure:
	dh_auto_configure --parallel -Skde -- -DWANT_COEXISTENCE=OFF \
			-DWANT_ESD=OFF -DWANT_OSS=OFF \
			-DWANT_STRIP=OFF \
			-DMANUAL_REVISION=$(REV) \
			-DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)"

override_dh_install:
	set -e; for file in $(NOT_INSTALLED); do rm debian/tmp/$$file; done
	dh_install --fail-missing -XCOPYING

%:
	dh $@ --parallel --dbg-package=kvirc-dbg --with kde

.PHONY: override_dh_auto_configure override_dh_install
