#!/usr/bin/make -f

export PYBUILD_DESTDIR_python2=debian/python-cherrypy3/
export PYBUILD_DESTDIR_python3=debian/python3-cherrypy3/
export PYBUILD_BEFORE_TEST=cp cherrypy/cherryd {build_dir}/cherrypy

include /usr/share/dpkg/default.mk

%:
	dh $@ --buildsystem pybuild --with python2,python3

override_dh_clean:
	-rm -rf api
	-rm -rf CherryPy.egg-info/
	-rm -f debian/cherryd.1
	dh_clean

override_dh_auto_build:
	PYTHONPATH=. help2man -n cherryd -s 1 -o debian/cherryd.1 --version-string=$(DEB_VERSION_UPSTREAM)  ./cherrypy/cherryd
	env PYTHONPATH=`pwd` epydoc --name CherryPy3 --url http://www.cherrypy.org/ -o api cherrypy
	dh_auto_build --buildsystem pybuild

#Testsuite hangs and wasn't run before
override_dh_auto_test:

override_dh_install:
	find debian/python*-cherrypy3/ -name LICENSE.txt -exec rm {} \;
	dh_install
	# Make python 2&3 cherrypy3 co-installable
	mv debian/python-cherrypy3/usr/bin/cherryd debian/python-cherrypy3/usr/sbin
	mkdir -p debian/python3-cherrypy3/usr/sbin/
	mv debian/python3-cherrypy3/usr/bin/cherryd debian/python3-cherrypy3/usr/sbin/cherryd3

override_dh_compress:
	dh_compress -X.py -X.pdf
