#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

PY3VERS := $(shell py3versions -s)

# For running tests, we need UTF-8 charset
# See #604706 for references about this method
LOCALE_PATH	:= debian/tmpdir/usr/lib/locale
LOCALE_NAME	:= en_US
LOCALE_CHARSET	:= UTF-8

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_test:
ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
	# configure a local charset dir, for testing purposes
	mkdir -p $(LOCALE_PATH)
	localedef -i $(LOCALE_NAME) -c -f $(LOCALE_CHARSET) \
		-A /usr/share/locale/locale.alias --quiet \
		$(LOCALE_PATH)/$(LOCALE_NAME).$(LOCALE_CHARSET)
	set -e ; \
	for python in $(PY3VERS); do \
		PYTHONPATH=. LOCPATH=$(LOCALE_PATH) LC_ALL=$(LOCALE_NAME).$(LOCALE_CHARSET) $$python setup.py test ; \
	done
endif

override_dh_installdocs:
	dh_installdocs -A README
