#!/usr/bin/make -f

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

export DH_ALWAYS_EXCLUDE=__pycache__

export DH_VERBOSE = 1
export PYBUILD_VERBOSE=1

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

export PYBUILD_NAME=yotta
export PYBUILD_DESTDIR_python3=debian/$(PYBUILD_NAME)

export PYBUILD_INSTALL_ARGS=--install-lib=/usr/share/yotta/ --install-scripts=/usr/share/yotta/

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

override_dh_auto_clean:
	dh_auto_clean
	rm -rf docs/_site

override_dh_auto_build:
	dh_auto_build
	# build custom manpage
	@echo DEB_VERSION_UPSTREAM $(DEB_VERSION_UPSTREAM)
	sed -e "s/__VERSION__/$(DEB_VERSION_UPSTREAM)/g" \
				< debian/yotta.1.md.in > debian/yotta.1.md
	pandoc debian/yotta.1.md -s -f markdown -t man -o debian/yotta.1
	# build documentation
	jekyll build --source ./docs --destination ./docs/_site/html --config ./docs/_config.yml --safe --drafts

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	python3 setup.py egg_info
	HOME=/tmp/ PYTHONPATH=$(CURDIR) nosetests3 -s -v \
				--where=yotta/test \
				--exclude=test_git_access.py \
				--exclude=test_github_access.py \
				--exclude=test_hg_access.py \
				--exclude=test_vcs.py \
				--exclude=test_account.py \
				--exclude=test_build.py \
				--exclude=test_debug.py \
				--exclude=test_install.py \
				--exclude=test_link.py \
				--exclude=test_minversion.py \
				--exclude=test_outdated.py \
				--exclude=test_owners.py \
				--exclude=test_publish.py \
				--exclude=test_search.py \
				--exclude=test_shrinkwrap.py \
				--exclude=test_start.py \
				--exclude=test_target.py \
				--exclude=test_test.py \
				--exclude=test_update.py \
				--exclude=test_version.py \
				--exclude=test_versions.py
endif
