#!/usr/bin/make -f

export PYBUILD_DESTDIR=debian/vdirsyncer
export PYBUILD_AFTER_INSTALL=rm -rf '{destdir}/{install_dir}/.hypothesis'
export PYBUILD_NAME=vdirsyncer
export PYBUILD_TEST_ARGS = -k 'not test_fuzzing'

execute_after_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
	# 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 \
	dh_auto_test --buildsystem=pybuild

execute_after_dh_auto_install:
	find debian -type f -name .coverage -delete

override_dh_installchangelogs:
	dh_installchangelogs CHANGELOG.rst

override_dh_installsystemduser:
	dh_installsystemduser --no-enable

%:
	dh $@ --buildsystem=pybuild
