#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

upstreamHash := $(shell echo $(DEB_VERSION_UPSTREAM) | grep -oP '(?<=git)\w+')
upstreamUrl := $(shell grep -oP "(?<=Homepage: )(.+)" $(CURDIR)/debian/control)

get-orig-source:
	wget -O - $(upstreamUrl)+archive/$(upstreamHash).tar.gz > ../$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM).orig.tar.gz

%:
	dh $@ --with python2 --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
	a2x -L --doctype manpage --format manpage $(CURDIR)/debian/gyp.txt > $(CURDIR)/debian/gyp.1

override_dh_auto_clean:
	-dh_auto_clean
	rm -rf build pylib/gyp.egg-info
	rm -f debian/gyp.1
