#!/usr/bin/make -f

#export DH_VERBOSE=1

# The command 'sphinx-build' refers to the python2 version;
# currently there is no easier way to refer to the python3 version.
SPHINXBUILD=/usr/share/sphinx/scripts/python3/sphinx-build

# Use buildflags for the Cython sources
# FIXME: Using hardeninge=+pie breaks the build.
export DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie
DPKG_EXPORT_BUILDFLAGS=1
include /usr/share/dpkg/buildflags.mk

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

override_dh_installdocs:
	python3 setup.py build_ext --inplace
	$(MAKE) -C docs html SPHINXBUILD=$(SPHINXBUILD)
	dh_installdocs

override_dh_installman:
	python3 setup.py build_ext --inplace
	$(MAKE) -C docs man SPHINXBUILD=$(SPHINXBUILD)
	cp docs/_build/man/borg-deduplicatingarchiver.1 debian/borg.1
	dh_installman

# Do not compress .ico file (affects html documentation)
override_dh_compress:
	dh_compress -X.ico
