#!/usr/bin/make -f

DH_VERBOSE := 1

pkg     := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
version := $(shell dpkg-parsechangelog -ldebian/changelog | grep Version: | cut -f2 -d' ' | cut -f1 -d- )
bindir  := $(CURDIR)/debian/$(pkg)/usr/bin
mandir  := $(CURDIR)/debian/$(pkg)/usr/share/man/man1

#UVER := $(shell LC_ALL=C dpkg-parsechangelog | awk '/^Version:/{print $$2;}' | sed -e 's,-[^-]*$$,,g')
#CYTHONVER := $(shell dpkg -l cython | awk '/^ii/{print $$3;}' || echo 0)
#MIN_CYTHONVER := 0.17~beta1-2
#NO_CYTHON := $(shell if dpkg --compare-versions $(CYTHONVER) lt $(MIN_CYTHONVER) ; then echo 0 ; else echo 1 ; fi)

%:
	dh $@ --with python2 # ,sphinxdoc

cythonize:
	python setup.py build_ext
	cp -a python-code/support-code/_sparsemat.cpp debian/cythonized-files
	echo "$(UVER)" >| debian/cythonized-files/VERSION

manpages:
	debian/create-manpages

override_dh_auto_clean:
	dh_auto_clean
	rm -rf python-code/support-code/_sparsemat.cpp

override_dh_install:
	dh_install
	# remove language extension
	rename 's/\.py$$//;' $(bindir)/*

get-orig-source:
	. debian/get-orig-source
