#!/usr/bin/make -f

DEB_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
VERSION = $(shell echo $(DEB_VERSION) | sed -e 's/-.*//; s/+dfsg.*//')

%:
	dh $@ --parallel

override_dh_auto_build:
	dh_auto_build -D libpit
	dh_auto_build -D heimdall

override_dh_auto_configure:
	dh_auto_configure -D libpit
	dh_auto_configure -D heimdall

override_dh_auto_install:
	dh_auto_install -D libpit
	dh_auto_install -D heimdall

override_dh_auto_clean:
	dh_auto_clean -D libpit
	dh_auto_clean -D heimdall

override_dh_install:

get-orig-source:
	git clone https://github.com/Benjamin-Dobell/Heimdall.git
	cd Heimdall && git checkout v$(VERSION)
	cd Heimdall && rm -rf libusb-1.0 Win32 libpit/autom4te.cache \
		.git Heimdall/heimdall/autom4te.cache
	mv Heimdall heimdall-flash-$(VERSION)
	tar zcvf heimdall_$(VERSION)+dfsg.orig.tar.gz heimdall-flash-$(VERSION)/ --numeric-owner
	rm -rf heimdall-flash-$(VERSION)

