#!/usr/bin/make -f

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

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		-Daudiotestsrc=true \
		-Dauto_features=enabled \
		-Ddocs=true \
		-Dffmpeg=false \
		-Dgstreamer-device-provider=false \
		-Dinstalled_tests=true \
		-Dman=true \
		-Dtest=true \
		-Dvideotestsrc=true \
		-Dvolume=true \
		-Dvulkan=false \
		$(NULL)
	install -d debian/ld.so.conf.d
	echo "/usr/lib/$(DEB_HOST_MULTIARCH)/pipewire-0.3/jack/" > "debian/ld.so.conf.d/pipewire-jack-$(DEB_HOST_MULTIARCH).conf"

test_timeout_multiplier = 1

ifneq ($(filter arm hppa ia64 m68k riscv64 sh4 sparc%,$(DEB_HOST_ARCH_CPU)),)
test_timeout_multiplier = 5
endif

ifneq ($(filter mips%,$(DEB_HOST_ARCH_CPU)),)
test_timeout_multiplier = 10
endif

override_dh_auto_test:
	dh_auto_test \
		-- \
		--timeout-multiplier $(test_timeout_multiplier) \
		$(NULL)

override_dh_missing:
	dh_missing --fail-missing

override_dh_makeshlibs:
	dh_makeshlibs \
		--exclude=/usr/lib/$(DEB_HOST_MULTIARCH)/gstreamer-1.0 \
		--exclude=/usr/lib/$(DEB_HOST_MULTIARCH)/pipewire-0.3 \
		--exclude=/usr/lib/$(DEB_HOST_MULTIARCH)/spa-0.2 \
		-- -c4

override_dh_shlibdeps-arch:
	dh_shlibdeps \
		-ppipewire-audio-client-libraries \
		-l/usr/lib/$(DEB_HOST_MULTIARCH)/pipewire-0.3 \
		-- \
		-Ldebian/pipewire-audio-client-libraries.shlibs.local \
		$(NULL)
	dh_shlibdeps \
		--remaining-packages \
		-l/usr/lib/$(DEB_HOST_MULTIARCH)/pipewire-0.3 \
		$(NULL)
