#!/usr/bin/make -f

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

%:
	dh $@ --with python2

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	set -e \
	;LIBPATH=$$(dirname $$(find build -type f -name lz4.so -print0)) \
	;for python in $(shell pyversions -r); do \
	    for test in $(wildcard ./tests/t*.py); do \
	        PYTHONPATH="$${LIBPATH}:$(PYTHONPATH)" \
	        $$python $${test} \
	    ;done \
	;done
endif

DPATH := $(abspath $(dir $(MAKEFILE_LIST)))
VER ?= $(shell dpkg-parsechangelog -l$(DPATH)/changelog -SVersion | perl -ne 'print $$1 if m{([\d\.]+)}')
.PHONY: get-orig-source
## http://wiki.debian.org/onlyjob/get-orig-source
get-orig-source:  $(info I: $(VER))
	@echo "# Downloading..."
	uscan --noconf --verbose --rename \
              --destdir=$(CURDIR) --check-dirname-level=0 \
              --force-download --download-version $(VER) $(DPATH) \
              --repack --compression xz
	mv -v python-lz4_$(VER).orig.tar.xz python-lz4_$(VER)+dfsg.orig.tar.xz
