#!/usr/bin/make -f

include /usr/share/quilt/quilt.make
include /usr/share/dpkg/default.mk

PY_DEFAULT = $(strip $(shell pyversions -d))
export PYBUILD_DESTDIR_python2=debian/python-cherrypy3/

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

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

override_dh_auto_build:
	chmod +x cherrypy/cherryd
	chmod -x cherrypy/cherryd
	dh_auto_build --buildsystem pybuild

override_dh_auto_test:

override_dh_install:
	dh_install

	# the 'daemonization' helper should be made available properly
	mv debian/python-cherrypy3/usr/lib/$(PY_DEFAULT)/*/cherrypy/cherryd \
		debian/python-cherrypy3/usr/sbin/
	chmod a+x debian/python-cherrypy3/usr/sbin/cherryd
	rm -f debian/python-cherrypy3/usr/lib/*/*/cherrypy/cherryd

	# no additional licensing files wanted =)
	find debian/python-cherrypy3/ -name LICENSE.txt -exec rm {} \;

override_dh_compress:
	dh_compress -X.py -X.pdf
