#! /usr/bin/make -f

export PYTHONWARNINGS=d
export PYBUILD_NAME=can

export PYTEST_ADDOPTS=--ignore=test/test_interface_canalystii.py \
	-k 'not BasicTestUdpMulticastBusIP' \
	--tb=short

include /usr/share/dpkg/default.mk
export DEB_VERSION_UPSTREAM

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_clean:
	rm -f test.asc test.csv
	rm -rf .pytest_cache/

execute_after_dh_auto_build:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS) $(DEB_BUILD_PROFILES)))
	PYTHONPATH=$(CURDIR) python3 -m sphinx \
		   -E -T -b html \
		   doc $(CURDIR)/.pybuild/docs/html/
endif

execute_after_dh_auto_install:
	-for f in debian/*/usr/bin/*.py; do mv $$f $${f%.py}; done
	-find debian/python3-can -name test.trc -delete

override_dh_installdocs:
	dh_installdocs --doc-main-package=python3-can -p python-can-doc
	dh_installdocs --remaining-packages

manpages=debian/can_logger.1 debian/can_player.1 debian/can_viewer.1 debian/can_logconvert.1 debian/can_bridge.1

$(manpages): debian/helper2man
	cp $^ $(@:.1=)
	help2man -N -o $@ ./$(@:.1=)
	-rm $(@:.1=)

.PHONY: manpages
manpages: $(manpages)
