#!/usr/bin/make -f

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
VER := $(shell dh_listpackages | cut -c15-18)

%:
	dh $@

override_dh_auto_install:
	install -d debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/gxr-$(VER)/backends/
	install build/src/libgxr-openvr.so \
	  debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/gxr-$(VER)/backends/
	chrpath -d debian/tmp/usr/lib/*/gxr-0.*/backends/libgxr-openvr.so

override_dh_missing:
	dh_missing --list-missing

test_env = \
	-u DISPLAY \
	HOME=$(CURDIR)/debian/tmp-home XDG_CACHE_HOME=

override_dh_auto_test:
	install -d $(CURDIR)/debian/tmp-home/.cache/gxr
	# Run tests without VR runtime
	env $(test_env) meson build
	env $(test_env) ninja -C build
	env $(test_env) meson test -C build/ --no-suite gxr:xr --no-suite post-install
