#!/usr/bin/make -f

# This file was automatically generated by stdeb 0.8.5 at
# Wed, 07 Dec 2016 10:38:33 -0800
export PYBUILD_NAME=distributed

# Get version from changelog as well as lsb_release
# to compute unique build version (useful for repo mirroring systems doing file pooling)
PKG_VERSION  := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f2 -d' ')
DIST_NAME    := $(shell lsb_release -si)
DIST_RELEASE := $(shell lsb_release -sc)
DIST_VERSION := $(shell lsb_release -sr)
PKG_VERSION_TAG := $(PKG_VERSION)+$(DIST_NAME).$(DIST_RELEASE).$(DIST_VERSION)
SUBSTVARS_BINARY_VERSION := -Vbinary:Version="$(PKG_VERSION_TAG)"
SUBSTVARS_SOURCE_VERSION := -Vsource:Version="$(PKG_VERSION_TAG)"

DEB_BUILD_OPTIONS += $(filter nodoc,$(DEB_BUILD_PROFILES))
%:
	dh $@ --with python3,sphinxdoc --buildsystem=pybuild

override_dh_auto_build: export http_proxy=127.0.0.1:9
override_dh_auto_build: export https_proxy=127.0.0.1:9
override_dh_auto_build:
	cd distributed/dashboard/ && coffee -c export_tool.coffee
	chmod a-x distributed/tests/test_utils_test.py
	dh_auto_build
#	ln -s /usr/share/javascript/mathjax docs/source/_static
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	PYTHONPATH=. python3 -m sphinx -N -bhtml docs/source build/html # HTML generator
endif

override_dh_compress:
	dh_compress -Xchangelog.html

override_dh_install:
	dh_install
	dh_installchangelogs docs/source/changelog.rst

override_dh_auto_clean:
	dh_auto_clean
	-rm distributed/dashboard/export_tool.js
	-chmod 755 distributed/tests/test_utils_test.py
#	-rm docs/source/_static/mathjax

override_dh_auto_test:
	-dh_auto_test

override_dh_gencontrol:
	dh_gencontrol -- -v"$(PKG_VERSION_TAG)" $(SUBSTVARS_BINARY_VERSION) $(SUBSTVARS_SOURCE_VERSION)
