#!/usr/bin/make -f

%:
	dh $* --with python2 --buildsystem=python_distutils

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
CONCURRENCY = BZR_CONCURRENCY=$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	$(CONCURRENCY) BZR_PLUGINS_AT=stats@$(CURDIR) /usr/bin/bzr selftest -s bp.stats \
	    -v --parallel=fork
endif

PACKAGE = bzr-stats
SRC_VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')
BZR_REVISION := $(shell echo $(SRC_VERSION) | awk -F"+" '{ print $$2 }' | sed 's/bzr//' )
TARBALL = $(PACKAGE)_$(SRC_VERSION).orig.tar.bz2
.PHONY: get-orig-source
get-orig-source:
	bzr export $(TARBALL) -r $(BZR_REVISION) "lp:bzr-stats"
	echo "  "$(TARBALL)" created; move it to the right destination to build the package"
