#!/usr/bin/make -f

export PYBUILD_DESTDIR_python3=debian/vdirsyncer
export PYBUILD_AFTER_INSTALL=rm -rf '{destdir}/{install_dir}/.hypothesis'
export PYBUILD_NAME=vdirsyncer
%:
	dh $@ --with python3,sphinxdoc --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=$(CURDIR) make -C docs man SPHINXBUILD=/usr/share/sphinx/scripts/python3/sphinx-build

override_dh_sphinxdoc:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=. /usr/share/sphinx/scripts/python3/sphinx-build -b html docs $(CURDIR)/debian/vdirsyncer-doc/usr/share/doc/vdirsyncer-doc/html
	dh_sphinxdoc -O--buildsystem=python_distutils
	# Remove unwanted license file, we already reference d/copyright
	rm -f $(CURDIR)/debian/vdirsyncer-doc/usr/share/doc/vdirsyncer-doc/html/_sources/license.txt
	rm -f $(CURDIR)/debian/vdirsyncer-doc/usr/share/doc/vdirsyncer-doc/html/_sources/license.rst.txt
endif

override_dh_auto_test:
	LC_ALL=C.UTF-8 \
	DETERMINISTIC_TESTS=false \
	CI=false \
	REMOTESTORAGE_SERVER=skip \
	DAV_SERVER=skip \
	RADICALE_BACNEND=filesystem \
	dh_auto_test

override_dh_installchangelogs:
	dh_installchangelogs CHANGELOG.rst
