#! /usr/bin/make -f

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

# Needed for testsuite
export XDG_RUNTIME_DIR = $(CURDIR)/debian/tmp/tmp-xdgruntimedir

ifeq ($(DEB_BUILD_ARCH_OS),linux)
CONFFLAGS = -Dcontext_manager=linux
else
CONFFLAGS = -Dcontext_manager=system
endif

%:
	dh $@ --with gnome,gir,python3

override_dh_clean:
	rm -f doc/version.xml
	dh_clean

override_dh_auto_configure:
	dh_auto_configure -- -Dgtk_doc=true $(CONFFLAGS)

override_dh_makeshlibs:
	dh_makeshlibs -- -c4

override_dh_strip:
	dh_strip --dbgsym-migration='libgupnp-1.0-dbg (<< 0.99.0-1~)'

override_dh_installman:
	cp obj-$(DEB_HOST_GNU_TYPE)/doc/version.xml doc
	xsltproc --novalid --nonet --xinclude -o debian/stripped-docs.xml debian/strip-manpages.xsl doc/gupnp-binding-tool.xml
	xsltproc --novalid --nonet /usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl debian/stripped-docs.xml
	rm -f debian/stripped-docs.xml
	dh_installman -p libgupnp-1.2-dev gupnp-binding-tool-1.2.1
	dh_installman --remaining-packages

override_dh_missing:
	dh_missing --fail-missing

override_dh_compress:
	dh_compress -Xexamples
