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

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

PYTHON3=$(shell py3versions -r)

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

override_dh_clean:
	dh_clean
	rm -rf Features.html build/ Python?/unicodedata_db.h

override_dh_auto_build:
	dh_auto_build
	set -e; \
	for python in $(PYTHON3); do \
		$$python setup.py build ; \
	done
	rst2html docs/Features.rst > Features.html

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	for python in $(PYTHON3); do \
		echo "-- running tests for "$$python" plain --" ; \
		LIB=$$($$python -c "from distutils.command.build import build ; from distutils.core import Distribution ; b = build(Distribution()) ; b.finalize_options() ; print(b.build_platlib)"); \
		cp regex_3/test_regex.py $$LIB ; \
		cd $$LIB ; \
		PYTHONPATH=. $$python test_regex.py; \
		rm test_regex.py ; \
		cd - ; \
	done
endif

override_dh_install:
	set -e; \
	for python in $(PYTHON3); do \
		$$python setup.py install --install-layout=deb --root=$(CURDIR)/debian/python3-regex; \
	done

override_dh_installdocs:
	dh_installdocs -A README.rst docs/UnicodeProperties.rst docs/Features.rst Features.html
