#!/usr/bin/make -f

lib_pkgs := calligra-libs

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

export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed
export QT_SELECT=4

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@ --parallel --with kde

override_dh_auto_configure:
	dh_auto_configure -Skde -- -DKDE4_BUILD_TESTS=OFF -DBUILD_krita=OFF

override_dh_auto_install:
	dh_auto_install
	# Remove development stuff:
	# - symlinks of libraries
	find debian/tmp/usr/lib -name '*.so' -type l -print -delete
	# - headers
	rm -rfv debian/tmp/usr/include
	# - cmake configuration files
	rm -rfv debian/tmp/usr/share/kde4/apps/cmake
	# Remove mimetypes already provided by shared-mime-info
	rm -f debian/tmp/usr/share/mime/packages/msooxml-all.xml
	rm -f debian/tmp/usr/share/mime/packages/x-iwork-keynote-sffkey.xml

override_dh_install:
	dh_install --list-missing

override_dh_link:
	# the calligra-gemini components are installed in a multi-arch library
	# directory, but kdelibs 4.x does not support that -- instead,
	# create a simple symlink to avoid shuffling things too much
	if [ -d debian/calligra-gemini ]; then \
	    ln -s $(DEB_HOST_MULTIARCH)/calligra $(CURDIR)/debian/calligra-gemini/usr/lib/calligra; \
	fi
	dh_link

override_dh_strip:
	dh_strip --dbgsym-migration='calligra-dbg (<< 1:2.9.11)'

override_dh_shlibdeps:
	dh_shlibdeps $(addprefix -p,$(lib_pkgs)) -- -xkde-runtime -xkdepim-runtime
	dh_shlibdeps --remaining-packages

.PHONY: override_dh_auto_test
