#!/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_auto_build:
	# build and avoid https://lintian.debian.org/tags/privacy-breach-generic.html
	grep -v "\[Build Status\]" README.md | pandoc -o voctomix.html
	# just build these
	pandoc -o voctocore.html voctocore/README.md
	pandoc -o voctogui.html voctogui/README.md

override_dh_python3:
	dh_python3 /usr/share/voctomix

override_dh_clean:
	dh_clean
	rm -f voctomix.html voctocore.html voctogui.html debian/debhelper-build-stamp

new-upstream-version: clean
	mkdir -p $(PKG)-$(UVER)/
	rsync -av --delete --exclude=debian/ --exclude=$(PKG)-$(UVER)/ --exclude=.git . $(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)"
