#!/usr/bin/make -f

#export DH_VERBOSE=1

GCC_SSSE3_ARCH  = amd64 i386 kfreebsd-i386 kfreebsd-amd64 hurd-i386 x32
DEB_HOST_ARCH  ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)


-include /usr/share/python/python.mk

PYVERS := $(shell pyversions -sv)

export CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
export CFLAGS   := $(shell dpkg-buildflags --get CFLAGS)
export LDFLAGS  := $(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed

%:
	dh $@ --with python2 --parallel

ifeq (,$(findstring $(DEB_HOST_ARCH),$(GCC_SSSE3_ARCH)))
override_dh_auto_build:
	dh_auto_build -- --without-ssse3
endif

override_dh_auto_test:
	-for PY in $(PYVERS); do \
	  py_path="$(CURDIR)/build/lib.`python$${PY} -c 'from distutils import util; print util.get_platform();'`-$$PY/" ; \
	  (cd tests; PYTHONPATH=$$py_path python$$PY unit2 discover); \
	done
