#!/usr/bin/make -f

export OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
export PREFIX=/usr

upstream_version ?= $(shell dpkg-parsechangelog | sed -rne 's/^Version: ([0-9.]+)(\+dfsg\d+)?.*$$/\1/p')
git_date= $(shell date +%Y%m%d)
dfsg_version = $(upstream_version)+git$(git_date)~repack0
pkg = $(shell dpkg-parsechangelog | sed -ne 's/^Source: //p')

%:
	dh $@

override_dh_auto_clean:
	rm -rf get-orig-source
	dh_auto_clean

# get-orig-source to drop upstream .gitignore file
get-orig-source:
	git  clone  git://github.com/swh/lv2 swh-lv2
	rm -fR $(pkg)/.git
	rm -fR $(pkg)/.gitignore
	rm -fR $(pkg)/util/gsm
	tar cf $(pkg)_$(dfsg_version).orig.tar $(pkg)
	xz -zf $(pkg)_$(dfsg_version).orig.tar
	rm -rf $(pkg)
	mv $(pkg)_$(dfsg_version).orig.tar.xz ../$(pkg)_$(dfsg_version).orig.tar.xz
