#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export DH_VERBOSE = 1
export PYBUILD_VERBOSE=1

export LANG=C.UTF-8
export LC_ALL=C.UTF-8

export PYBUILD_NAME=mbed-host-tests

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_clean:
	rm -rf html/

execute_after_dh_auto_build:
	# build custom manpages
	@echo DEB_VERSION_UPSTREAM $(DEB_VERSION_UPSTREAM)
	# i) mbedhtrun
	sed -e "s/__VERSION__/$(DEB_VERSION_UPSTREAM)/g" < debian/mbedhtrun.1.md.in > debian/mbedhtrun.1.md
	pandoc debian/mbedhtrun.1.md -s -f markdown -t man -o debian/mbedhtrun.1
	# ii) mbedflsh
	sed -e "s/__VERSION__/$(DEB_VERSION_UPSTREAM)/g" < debian/mbedflsh.1.md.in > debian/mbedflsh.1.md
	pandoc debian/mbedflsh.1.md -s -f markdown -t man -o debian/mbedflsh.1
	#  build library documentation
	doxygen doxygen.cfg
	$(RM) html/jquery.js

execute_after_dh_installdocs:
	dh_doxygen

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	python3 setup.py egg_info
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="{interpreter} -m unittest discover -v -s test -p \"*.py\" -t {dir}" \
	dh_auto_test
endif
