#!/usr/bin/make -f
PYVERS :=  $(shell pyversions -r)

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

%:
	dh $@ --with python2,sphinxdoc

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=$(shell pwd) make -C doc/ html

override_dh_install:
	dh_install -X SOURCES.txt

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	set -ex; \
	for py in $(shell pyversion -r); do \
		PYTHONPATH=$(CURDIR) $$py -m pytest; \
	done
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -rf doc/_build

get-orig-source:
	gzip -cd '../grapefruit_$(UPSTREAM).orig.tar.gz' | tar --delete doc/_static/GrapeFruit.png | gzip > '../grapefruit_$(UPSTREAM)+dfsg.orig.tar.gz'
