#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

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

libpkgs_gen_strict_local_shlibs = calligra-libs
include /usr/share/pkg-kde-tools/qt-kde-team/3/library-packages.mk

include /usr/share/dpkg/architecture.mk

ifeq ($(DEB_HOST_ARCH),i386)
  EXTRA_CMAKE_ARGS += -DWITH_Poppler=OFF -DWITH_PopplerXPDFHeaders=OFF
endif

%:
	dh $@ --with kf6

override_dh_auto_configure:
	dh_auto_configure -Skf6 -- -DBUILD_TESTING=OFF -DBUILD_app_cstester=OFF -DBUILD_app_devtools=OFF $(EXTRA_CMAKE_ARGS)

execute_after_dh_auto_install:
	# Remove development symlinks of libraries
	find debian/tmp/usr/lib -name '*.so' -type l -print -delete
	# Remove stuff belonging to unported calligraflow
	rm -f debian/tmp/usr/lib/*/qt6/plugins/calligra/formatfilters/calligra_filter_vsdx2odg.so
	rm -f debian/tmp/usr/lib/*/qt6/plugins/calligra/formatfilters/calligra_filter_wpg2odg.so
	# Remove translations of stuff not shipped
	rm -f debian/tmp/usr/share/locale/*/LC_MESSAGES/braindump.mo
	rm -f debian/tmp/usr/share/locale/*/LC_MESSAGES/calligra_semanticitem_*.mo
	rm -f debian/tmp/usr/share/locale/*/LC_MESSAGES/calligra_shape_comment.mo
	rm -f debian/tmp/usr/share/locale/*/LC_MESSAGES/calligra_shape_template.mo
	rm -f debian/tmp/usr/share/locale/*/LC_MESSAGES/calligra_shape_webshape.mo
	# Remove color profiles, which ideally should be shipped somewhere ...
	rm -rf debian/tmp/usr/share/color/

override_dh_gencontrol-arch: libpkgs_gen_strict_local_shlibs
	dh_gencontrol -a

.PHONY: override_dh_auto_test
