#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk
builddir = obj-${DEB_HOST_MULTIARCH}
buildopts = --buildsystem=meson+ninja --builddir=${builddir}
export PYTHONDONTWRITEBYTECODE=1

build-arch build-indep build clean install-indep install-arch install binary-arch binary-indep binary: %:
	dh $@ ${buildopts}

# dh build insists on running autoreconf because ./configure has the same
# timestamp as ./configure.ac.  We do not use autoconf, there is no need
# to (re-)run configure at all.
override_dh_update_autotools_config:
override_dh_autoreconf:

override_dh_gencontrol:
# gstreamer-libav is in Universe in Ubuntu, can only suggest it,
# but on Debian it can be Recommended
	if dpkg-vendor --derives-from Ubuntu; then \
	    dh_gencontrol -- \
		-Vgstreamer-libav:recommends= \
		-Vgstreamer-libav:suggests=gstreamer1.0-libav \
		; \
	else \
	    dh_gencontrol -- \
		-Vgstreamer-libav:recommends=gstreamer1.0-libav \
		-Vgstreamer-libav:suggests= \
		; \
	fi

execute_after_dh_auto_install:
# XXX hack alert: remove Requires.private and Libs.private defs from .pc file
# these are needed for static build and we're not providing static libs
	sed -E -i \
	 -e '/^(Libs|Requires)\.private:/D' \
	 debian/tmp/usr/lib/${DEB_HOST_MULTIARCH}/pkgconfig/spice-server.pc

# the test-listen test uses dconf which insists on creating a cache dir in $HOME
# set $HOME to a sane value
# the test is disabled in debian/patches/
#override_dh_auto_test:
#	HOME=${PWD}/${builddir} \
#		dh_auto_test ${buildopts}
