#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

CLI_SCRIPT=bin/expyriment-cli

override_dh_auto_build: $(CLI_SCRIPT) manpage
	make --directory=documentation/sphinx rst html latexpdf
	#make --directory=documentation/api html
	rm -f documentation/sphinx/_build/html/_static/jquery.js 
	rm -f documentation/sphinx/_build/html/_static/underscore.js
	dh_auto_build

override_dh_install:
	dh_install

override_dh_clean:
	make --directory=documentation/sphinx clean
	make --directory=documentation/api clean
	rm -rf bin man
	rm documentation/api/_build -rf
	dh_clean

override_dh_installchangelogs:
	dh_installchangelogs CHANGES.md

override_dh_compress:
	dh_compress -X.py -X.pdf

$(CLI_SCRIPT):
	mkdir -p bin
	echo "#!/bin/sh" > $(CLI_SCRIPT)
	echo "set -e" >> $(CLI_SCRIPT)
	echo -n "python -m expyriment.cli \$$* |" >> $(CLI_SCRIPT) 
	echo "sed 's/ python -m expyriment.cli / expyriment-cli /g'" >> $(CLI_SCRIPT)
	chmod 755 $(CLI_SCRIPT)

manpage: $(CLI_SCRIPT)
	mkdir -p man
	help2man --no-info --name="command line interface for Expyriment, a Python library for cognitive and neuroscientific experiments" $(CLI_SCRIPT) > man/expyriment-cli.1

%:
	dh $@ --with python2
