#!/usr/bin/make -f

upstreamVersion := $(shell dpkg-parsechangelog -SVersion | cut -d- -f1)
upstreamHash := $(shell echo $(upstreamVersion) | grep -oP '(?<=git)\w+')
upstreamUrl := $(shell grep -oP "(?<=Homepage: )(.+)" $(CURDIR)/debian/control)
upstreamName := $(shell dpkg-parsechangelog -SSource)

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

%:
	dh $@ --with python2

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
