#! /usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

REV=$(shell echo $(DEB_VERSION) | sed 's/.*~git/git/' | rev | cut -c 3- | rev)

# 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.9/license/LICENSE-GPLV2 \
				usr/share/kvirc/4.9/license/LICENSE-OPENSSL \
				usr/share/kvirc/4.9/license/COPYING \
				usr/share/pixmaps/kvirc.png

override_dh_auto_configure:
	dh_auto_configure -- \
			-DCMAKE_BUILD_TYPE=RelWithDebInfo \
			-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

override_dh_missing:
	dh_missing --fail-missing

override_dh_strip:
	dh_strip --dbgsym-migration='kvirc-dbg (<< 4:4.2.0-3~)'

%:
	dh $@ --with kf5

.PHONY: override_dh_auto_configure override_dh_install override_dh_missing override_dh_strip
