#!/usr/bin/make -f

%:
	dh $@

VER=$(shell dpkg-parsechangelog | sed -rne 's/^Version: (.+)-.*/\1/p')
BRANCH=opsis-uart-with-eeprom-serialno
get-packaged-orig-source:
	git clone https://github.com/mithro/fx2lib -b $(BRANCH)
	set -xe; \
		GIT_DATE=$$(dpkg-parsechangelog | sed -rne 's/^Version: .*\~git(....)(..)(..)-.*/\1-\2-\3 00:00:00 UTC/p'); \
		cd fx2lib; \
		GIT_COMMIT=$$(git rev-list -n1 --until="$$GIT_DATE" $(BRANCH)); \
		git archive $$GIT_COMMIT --prefix=hdmi2usb-fx2-firmware_$(VER).orig/ \
			-o ../hdmi2usb-fx2-firmware_$(VER).orig.tar
	xz -f hdmi2usb-fx2-firmware_$(VER).orig.tar
	rm -rf fx2lib
