#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

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


%:
	dh $@

override_dh_build:
	cp single_include/catch.hpp single_include/catch.hpp.bak
	python scripts/generateSingleHeader.py nobump

override_dh_clean:
	if [ -f single_include/catch.hpp.bak ]; then \
		mv -f single_include/catch.hpp.bak single_include/catch.hpp; \
	fi;
	dh_clean

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

