#!/usr/bin/make -f

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


override_dh_installchangelogs:
	if [ -e $(CURDIR)/debian/CHANGELOG ] ; then \
		dh_installchangelogs $(CURDIR)/debian/CHANGELOG ; \
	else \
		dh_installchangelogs ; \
	fi

override_dh_sphinxdoc:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	python3 -m sphinx -b man docs/source docs/build/man
	sed -i 's/.TH "PATHTOOLS" "1"/.TH "PATHTOOLS" "3"/g' docs/build/man/pathtools.1
	cp docs/build/man/pathtools.1 docs/build/man/pathtools3.1

endif

override_dh_installman:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	dh_installman
endif

override_dh_clean:
	dh_clean
	rm -rf build
	rm -rf docs/build
