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

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

PKG=libdvdcss-pkg
PKGG=$(patsubst %-pkg,%,$(PKG))
PKGG_VER = $(shell dpkg-parsechangelog | sed -n 's/^Version: *//p' | sed 's/\+/-/')

%: debian/po/templates.pot
	dh $@

override_dh_auto_configure:
	## sync "host" and "guest" package versions
	cd $(PKGG) && debchange \
			--preserve \
			--maintmaint \
			--force-distribution \
			--distribution="local" \
			--force-bad-version \
			--newversion="$(PKGG_VER)~local" \
			"Automated local build of libdvdcss by libdvdcss-pkg"

debian/po/templates.pot:
	debconf-updatepo --verbose

override_dh_installchangelogs:
	dh_installchangelogs $(PKGG)/debian/changelog

override_dh_builddeb:
	dh_builddeb -- -Zxz

VER = $(shell dpkg-parsechangelog | perl -ne 'print $$1 if m{Version:\s*([0-9.]+)}')
get-orig-source: $(PKG)_$(VER).orig.tar.xz
	@

$(PKG)_$(VER).orig.tar.xz:
	mkdir $(PKG)_$(VER)
	cp -r $(PKGG) $(PKG)_$(VER)/
	tar -caf $(PKG)_$(VER).orig.tar.xz $(PKG)_$(VER)
	$(RM) -r $(PKG)_$(VER)
