#!/usr/bin/make -f
SHELL := sh -e
VERSION := $(shell dpkg-parsechangelog -SVersion)
VERSION_UPSTREAM := $(shell echo "$(VERSION)" | sed -e 's,-[^-]*$$,,')

UPSTREAM_SOURCE = linux-board-support-package
DIR_ORIG = ./$(UPSTREAM_SOURCE)-r$(VERSION_UPSTREAM)
ZIP_ORIG = linux-board-support-package-r$(VERSION_UPSTREAM).zip

override_dh_auto_build:
	unzip -q $(ZIP_ORIG) "*/proprietary-linux/*" "*/LICENSE" "*/bootloaders-linux/*"
	cp $(DIR_ORIG)/LICENSE debian/copyright

override_dh_auto_clean:
	rm -rf $(DIR_ORIG)
	rm -f debian/copyright

# comaptibility with old and new Debian repos.
override_dh_installdeb:
	dh_installdeb
	if command -v dh_movetousr >/dev/null; then dh_movetousr; fi

%:
	dh $@
