#!/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
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

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

override_dh_auto_configure:
	dh_auto_configure -Skde -- -DKDE4_BUILD_TESTS=OFF

override_dh_auto_install:
	dh_auto_install
	# Remove symlinks of private libraries
	find debian/tmp/usr/lib -maxdepth 1 -name '*private*.so' -type l -delete
	rm -f debian/tmp/usr/lib/librcps_plan.so
	# image/openraster is provided by shared-mime-info >= 0.70
	# (and squeeze has 0.71)
	rm -f debian/tmp/usr/share/mime/packages/krita_ora.xml
ifeq (,$(filter %-dev, $(shell dh_listpackages)))
	# No -dev stuff, so remove their content to shorten the output
	# of dh_install --list-missing
	rm -rf debian/tmp/usr/include
	rm -rf debian/tmp/usr/share/kde4/apps/cmake
	find debian/tmp/usr/lib -maxdepth 1 -name '*.so' -type l -delete
endif

override_dh_install:
	dh_install --list-missing

override_dh_link:
	dh_link -pkrita-sketch /usr/share/kde4/apps/kritasketch/images \
	    usr/lib/$(DEB_HOST_MULTIARCH)/calligra/imports/org/krita/sketch/images
	dh_link --remaining-packages

override_dh_strip:
	dh_strip --dbg-package=calligra-dbg

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

.PHONY: override_dh_auto_test

prune-nonfree:
	# minimized extjs, not installed, nor used
	rm -f kexi/webforms/webroot/extjs/ext-all.js
	rm -f kexi/webforms/webroot/extjs/extjs/adapter/ext/ext-base.js
	# copyright Sun Microsystems, 1996 unknown license
	# Help needed to clarify the license.
	rm -f plugins/colorengines/lcms2/colorprofiles/data/CMY.icm
	# Claims itself as public domain, but included in non-free package
	# icc-profiles.
	# Help needed to clarify the license.
	rm -f plugins/colorengines/lcms2/colorprofiles/data/fogra27l.icm
