#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DEB_PYTHON_SYSTEM=pysupport

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/python-distutils.mk

# Prepare support  for python 3.x  (need to add  Build-Depends against
# python3-all-dev in debian/control).
# cdbs_python_supported_versions += $(shell dpkg-query -W -f='$${Depends}' python3-all-dev | sed 's/.*python\(3\.[0-9]\)-dev.*/\1/')

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
common-post-build-arch common-post-build-indep:: debian/check-stamp
debian/check-stamp:
	for buildver in $(cdbs_python_build_versions); do \
	    echo Running testsuite for python$$buildver; \
	    PATH=$(CURDIR)/build/scripts-$$buildver:$$PATH \
	        PYTHONPATH=$(CURDIR)/`ls -d build/lib.*-$$buildver` \
	        python$$buildver \
	            cheetah/Tests/Test.py || true; \
	done
	>$@

clean::
	rm -f debian/check-stamp
endif

# Install egg-info directories
DEB_PYTHON_INSTALL_ARGS_ALL += --single-version-externally-managed

install/$(DEB_PYTHON_MODULE_PACKAGES)::
	sed -i 's#\#!/usr/bin/python[0-9].[0-9]#\#!/usr/bin/python#' \
		$(cdbs_python_destdir)usr/bin/*
