#!/usr/bin/make -f

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

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

%:
	dh $@ --with python3

override_dh_clean:
	dh_clean
	rm -f voctomix-outcasts.html debian/debhelper-build-stamp
	rm -rf ./lib/__pycache__

new-upstream-version: clean
	mkdir -p $(PKG)-$(UVER)/
	rsync -av --delete --exclude=debian/ --exclude=$(PKG)-$(UVER)/ * $(PKG)-$(UVER)/
	find "$(PKG)-$(UVER)" -xdev \( -type f -o -type l \) -print| sort \
	    | tar -cJaf "../$(PKG)_$(UVER).orig.tar.xz" -T- --owner=root --group=root --mode=a+rX \
	    && $(RM) -r "$(PKG)-$(UVER)"
