#!/usr/bin/make -f

#export DH_VERBOSE=1

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

# Used to enable documentation if dependencies are available
define cond_enable
	$(shell if test -x /usr/bin/doxygen && test -x /usr/bin/dot; \
		then echo --enable-documentation; else echo --disable-documentation; fi )
endef

CONFIGURE_OPTIONS ?= $(call cond_enable) \
		     --enable-dri2

%:
	dh $@ --with autoreconf

binary: binary-indep binary-arch ;

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	dh_testdir
	LDFLAGS="-Wl,--as-needed $$(dpkg-buildflags --get LDFLAGS)" ./configure \
		--prefix=/usr --sysconfdir=/etc --libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
		$(CONFIGURE_OPTIONS)

override_dh_installdocs:
	dh_installdocs -X.md5

override_dh_bugfiles:
	dh_bugfiles -A

# ignore the plugin
override_dh_makeshlibs:
	dh_makeshlibs -Xvdpau/libvdpau_trace.so.1

override_dh_strip:
	dh_strip --dbg-package=libvdpau1-dbg
