#!/usr/bin/make -f
# -*- makefile -*-

%:
	dh $@

override_dh_auto_test:
	# Cannot run tests without a X11 server (with VAAPI support)

override_dh_makeshlibs:
	dh_makeshlibs -n

# The remaining of this debian/rules has been mostly stolen from
# http://wiki.debian.org/onlyjob/get-orig-source.

PKD  = $(abspath $(dir $(MAKEFILE_LIST)))
PKG  = $(word 2,$(shell dpkg-parsechangelog -l$(PKD)/changelog | grep ^Source))
VER ?= $(shell dpkg-parsechangelog -l$(PKD)/changelog | perl -ne 'print $$1 if m{^Version:\s+(\d.*)(?:\-\d+.*)};')

.PHONY: get-orig-source
get-orig-source: $(PKG)_$(VER).orig.tar.gz $(info I: $(PKG)_$(VER))
	@

UURL = git://github.com/i-rinat/libvdpau-va-gl.git
USHA = $(shell echo $(VER) | sed -n 's/.*+git[0-9]\{8\}\.\([a-f0-9]\{10\}\)$$/\1/p')
$(PKG)-$(VER): $(info I: USHA=$(USHA))
	@echo "# Downloading..."
	git clone $(UURL) $(PKG)-$(VER) || $(RM) -r $(PKG)-$(VER)
	cd $(PKG)-$(VER) \
	&& git checkout $(USHA) \
	&& $(RM) -r .git .git*
$(PKG)_$(VER).orig.tar.gz: $(PKG)-$(VER)
	@echo "# Packing..."
	find -L "$(PKG)-$(VER)" -xdev -type f -print | sort \
	| tar -zcaf "$(PKG)_$(VER).orig.tar.gz" -T- --owner=root --group=root --mode=a+rX \
	&& $(RM) -r "$(PKG)-$(VER)"
