#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
include /usr/share/dpkg/default.mk
PYVERS = $(shell py3versions -rv)

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

# test suite is broken.
override_dh_auto_test:
#ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
#	set -e -x;\
#	for py in $(PYVERS); do \
#  TOXPYTHON=python$$py \
#  PYTHONPATH=$(CURDIR)/build/lib.*-$$py  python$$py ./setup.py test ;\
#  done
#endif

override_dh_auto_build:
	set -ex; for py in $(PYVERS); do \
	python$$py setup.py build; \
	done

execute_after_dh_auto_install:
# docs in just one place, /usr/share/doc/duplicity.
	rm -r --verbose debian/duplicity/usr/share/doc/duplicity-*
	(cd debian/duplicity/usr					\
	 && mkdir -p share/doc/duplicity				\
	 && mv --verbose						\
		lib/python*/dist-packages/duplicity/backends/README	\
		share/doc/duplicity/README.backends)

execute_after_dh_clean:
# the test suite leaves a mess behind
	rm -f testing/gnupg/random_seed duplicity/_librsync*.so
	rm -rf .cache .eggs testing/testfiles build report.xml
