#!/usr/bin/make -f

%:
	dh $@ --with python2

override_dh_install:
	# Windows registry file and FontLab script is superfluous
	dh_install --exclude=fontlab-generate-settings --exclude=latin.enc

override_dh_fixperms:
	dh_fixperms
	find debian/googlefontdirectory-tools -name "*.ff" -exec chmod 755 {} +
	find debian/googlefontdirectory-tools -name "*.sh" -exec chmod 755 {} +
	find debian/googlefontdirectory-tools -name "*.py" -exec chmod 755 {} +

override_dh_builddeb:
	dh_builddeb -- -Zxz

NAME=googlefontdirectory-tools
URL="https://googlefontdirectory.googlecode.com/hg/"
HGDIR=gfd-hg
get-orig-source:
	hg clone "$(URL)" "$(HGDIR)"
	# Get last date of commit touching tools/ and use throughout
	export DATE="$$(hg log $(HGDIR)/tools/ --limit 1 \
		--template "{date|isodate}\n" | cut --delimiter=' ' \
		--fields=1 | xargs date +%Y%m%d --date)" ;\
	export DIR="$(NAME)-$$DATE.1.orig" ;\
	export TAR="$(NAME)_$$DATE.1.orig.tar.xz" ;\
	\
	rm -rf "$$DIR" ;\
	mkdir "$$DIR" ;\
	$(: Leave hg repo as-is) \
	cp -r "$(HGDIR)/tools/" "$$DIR" ;\
	rm -rf "$$DIR/tools/ttfautohint/" ;\
	\
	XZ_OPT="-6" tar -cJ --owner root --group root --mode a+rX \
		-f "$$TAR" "$$DIR"
