#!/usr/bin/make -f
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
export DEB_HOST_MULTIARCH
DEB_DEBIAN_DIR=$(dir $(firstword $(MAKEFILE_LIST)))
VER=$(shell dpkg-parsechangelog -l$(DEB_DEBIAN_DIR)/changelog \
              | sed -rne 's,^Version: ([^-]+).*,\1,p')
GITREV=$(shell echo $(VER) | sed -rne 's,[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.([0-9]+),\1,p')

%:
	dh $@ --with python2

override_dh_auto_configure:
	dh_auto_configure -- -DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)" -DPythonLibs_FIND_VERSION:STRING="2.7" -DPythonInterp_FIND_VERSION:STRING="2.7"

override_dh_python2:
	dh_python2 --no-guessing-versions --no-guessing-deps -V 2.7 --package=gr-osmosdr --no-package=libgnuradio-osmosdr0.0.0

override_dh_auto_install:
	dh_auto_install
	rm -f debian/gr-osmosdr/usr/lib/python2.7/dist-packages/osmosdr/*pyc
	rm -f debian/gr-osmosdr/usr/lib/python2.7/dist-packages/osmosdr/*pyo

version-to-get:
	echo $(VER) is $(GITREV)

get-orig-source: version-to-get
	git clone git://git.osmocom.org/gr-osmosdr
	cd gr-osmosdr && git archive --format=tar --prefix=gr-osmosdr-$(VER)/  $(GITREV) | gzip > ../gr-osmosdr_$(VER).orig.tar.gz
	rm -rf gr-osmosdr
