#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

PYVERS = $(shell pyversions -r -v)

# For svn-orig-source.sh
PKGDIR = $(dir $(firstword $(MAKEFILE_LIST)))
UPNAME = $(shell dpkg-parsechangelog -l$(PKGDIR)/changelog | \
		sed -nre 's,^Source:\s+(.*),\1,p')
UPVER = $(shell dpkg-parsechangelog -l$(PKGDIR)/changelog | \
		sed -nre 's,^Version:\s+(.*)\+svn([0-9]+)-.*,\1,p')
SVNREV = $(shell dpkg-parsechangelog -l$(PKGDIR)/changelog | \
		sed -nre 's,^Version:\s+(.*)\+svn([0-9]+)-.*,\2,p')
SVNURL = http://keyczar.googlecode.com/svn/trunk/python/
export UPNAME UPVER SVNURL SVNREV

%:
	dh $@

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	set -e ; \
	cd tests/keyczar/; \
	for py in $(PYVERS); do  \
		if [ "$$py" \< "2.6" ]; then \
			PYTHONPATH=$(CURDIR)/build/lib python$$py alltests.py; \
		else \
			PYTHONPATH=$(CURDIR)/build/lib.$(shell python -c 'import distutils.util as d; print d.get_platform()')-$$py python$$py alltests.py; \
    		fi; \
	done
endif

.PHONY: get-orig-source
get-orig-source:
	sh $(PKGDIR)/svn-orig-source.sh
