#!/usr/bin/make -f

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

confflags  = --enable-va-messaging
# Steam Runtime: our libwayland is too old
confflags += --disable-wayland

# Steam Runtime: we want to load VA-API drivers from an arbitrary
# host OS, not just from the Steam Runtime (and in fact not from the Steam
# Runtime at all, since we don't currently ship any).
#
# These are the most common search paths:
#
# - Debian-style multiarch (lib/*-linux-gnu - Debian, Ubuntu, SteamOS,
#   freedesktop.org Flatpak runtime)
# - freedesktop.org Flatpak runtime extensions (lib/*-linux-gnu/intel-vaapi-driver,
#   lib/*-linux-gnu/GL/lib/dri)
# - Red-Hat-style multilib 64-bit drivers (lib64 - Fedora, SUSE, etc.)
#   or Arch-Linux-style multilib 32-bit drivers (lib32 - Arch, Manjaro etc.)
# - Non-specific default path (lib - 32-bit on Fedora etc. or 64-bit on Arch etc.)
ma_libdir := /usr/lib/$(DEB_HOST_MULTIARCH)
confflags += --with-drivers-path=$(ma_libdir)/dri:$(ma_libdir)/dri/intel-vaapi-driver:$(ma_libdir)/GL/lib/dri:/usr/lib$(DEB_HOST_ARCH_BITS)/dri:/usr/lib/dri

export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed
export V=1

%:
	dh $@ --parallel --with autoreconf

override_dh_auto_configure:
	dh_auto_configure -- $(confflags)

debian/dh/dh_libva.1:
	cd debian/dh && pod2man -c Debhelper -r '' dh_libva dh_libva.1

override_dh_auto_build: debian/dh/dh_libva.1
	dh_auto_build

debian/shlibs.local:
	echo "libva 2 libva2 (>= $(DEB_VERSION_UPSTREAM)), libva2 (<< $(DEB_VERSION_UPSTREAM).1)" > debian/shlibs.local

override_dh_shlibdeps: debian/shlibs.local
	dh_shlibdeps

override_dh_installchangelogs:
	dh_installchangelogs NEWS
