#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

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

TESTS_HOME=$(CURDIR)/debian/tests.home

# Starting with a library package $*, remove the ABI and append a
# -MAJOR.MINOR suffix without the third component of the upstream version.
ABIVirtualPackage = $(shell echo $* | sed 's/abi[0-9]\+//')-$(basename $(DEB_VERSION_UPSTREAM))
pkgs_lib := $(filter-out %-dev %-dbg %-bin %-data,$(filter lib%,$(shell dh_listpackages)))

%:
	dh $@

override_dh_makeshlibs: $(pkgs_lib:=-makeshlibs)
	dh_makeshlibs --remaining-packages
$(pkgs_lib:=-makeshlibs): %-makeshlibs:
	dh_makeshlibs -p$* '-V$* (>= $(DEB_VERSION_EPOCH_UPSTREAM)), $(ABIVirtualPackage)'

override_dh_gencontrol: $(pkgs_lib:=-gencontrol)
	dh_gencontrol --remaining-packages
$(pkgs_lib:=-gencontrol): %-gencontrol:
	dh_gencontrol -p$* -- -VABI:VirtualPackage=$(ABIVirtualPackage)

override_dh_auto_test:
	: # presumably timeout in RichTextComposerTest
#ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
#	mkdir -p "$(TESTS_HOME)"
#	- HOME=$(TESTS_HOME) xvfb-run -a --server-args="-screen 0 1024x768x24" debian/testsuite.xsession
#	rm -rf "$(TESTS_HOME)"
#endif
