#!/usr/bin/make -f

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

dh = --dbg-package=phonon-dbg

include /usr/share/pkg-kde-tools/qt-kde-team/2/debian-qt-kde.mk

# Enable strict interdependencies
libpkgs_gen_strict_local_shlibs = $(libpkgs_all_packages)
include /usr/share/pkg-kde-tools/qt-kde-team/2/library-packages.mk

RECOMMENDED_PHONON_BACKEND := phonon-backend-vlc

override_dh_auto_configure:
	$(overridden_command) -- -DPHONON_INSTALL_QT_EXTENSIONS_INTO_SYSTEM_QT=ON -DLIB_SUFFIX=/$(DEB_HOST_MULTIARCH)

# shlibs is needed for library-packages.mk (strict shlibs) to work
override_dh_makeshlibs:
	$(overridden_command) -plibphonon4 -V'libphonon4 (>= $(dqk_upstream_version)), phonon'
	$(overridden_command) -V --remaining-packages

override_dh_shlibdeps:
	$(overridden_command) -- -xphonon

override_dh_gencontrol:
	# Expand some variables in maintainer scripts and debconf templates
	@for f in debian/*/DEBIAN/post* \
	          debian/*/DEBIAN/pre* \
	          debian/*/DEBIAN/config \
	          debian/*/DEBIAN/templates; do \
	    if [ -f "$$f" ]; then \
	        cmd="awk -f debian/expand_vars.awk -v recommended_backend='$(RECOMMENDED_PHONON_BACKEND)' -- $$f > $$f.tmp && cat $$f.tmp >| $$f && rm -f $$f.tmp"; \
	        echo "$$cmd"; eval "$$cmd"; \
	    fi; \
	done
	if [ -d debian/phonon-backend-null ]; then \
	    sed -i 's/\$${recommended_backend}/$(RECOMMENDED_PHONON_BACKEND)/g' \
	        debian/phonon-backend-null/usr/share/doc/phonon-backend-null/README.Debian; \
	fi
	$(overridden_command) -- -Vphonon:Recommended-Backend=$(RECOMMENDED_PHONON_BACKEND)
