#!/usr/bin/make -f
export DH_VERBOSE=1

js-compressor := $(or $(notdir $(shell which uglifyjs)),yui-compressor)

%:
	dh $@

override_dh_auto_build: build_doc
	python3 tools/build.py -n
	python3 tools/build.py -tnode
	$(js-compressor) -o build_browser/highlight.min.js build_browser/highlight.pack.js
	mv build_browser/highlight.pack.js build_browser/highlight.js

override_dh_clean:
	dh_clean
	rm -rf build_browser/ build_node/
	rm -rf docs/_build/*

build_doc:
	$(MAKE) -C docs/ html
	$(MAKE) -C docs/ latexpdf

override_dh_installchangelogs:
	dh_installchangelogs CHANGES.md

# node-jsdom is not available in stretch, tests are not ppossible
#override_dh_auto_test:
#	$(RM) build && ln -sf build_node/ build
#	mocha test/
