#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2002,2003 Colin Walters <walters@debian.org>

DEB_PYTHON_SYSTEM = pysupport

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

DEB_INSTALL_EXAMPLES_python-webut := examples/*

DEB_DH_ALWAYS_EXCLUDE := .git

docdir = debian/$(1)/usr/share/doc/$(1)
binary-post-install/%::
	awk '/^# See the file .*/ {while (getline l <"LICENSE") {print l}; getline}; {print}' \
		<'$(call docdir,$*)/copyright' \
		>'$(call docdir,$*)/copyright.tmp'
	mv \
		'$(call docdir,$*)/copyright.tmp' \
		'$(call docdir,$*)/copyright'


ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
TRIAL=trial$(cdbs_python_ver)
TOPMODULES:=webut
$(patsubst %,binary-post-install/%,$(DEB_PYTHON_REAL_LIB_PACKAGES)):: binary-post-install/%:
	PYTHONPATH='debian/$(cdbs_curpkg)/usr/lib/python$(cdbs_python_ver)/site-packages/' \
		'$(TRIAL)' --tbformat=emacs --reporter=bwverbose $(TOPMODULES)

	# Importing the modules generates .pyc files, and dh_python (which
	# normally cleans them) has already been run. Remove them manually.
	find 'debian/$(cdbs_curpkg)' -name '*.py[co]' -print0 \
	| xargs -0 rm -f --
endif

clean::
	rm -rf _trial_temp


# distutils is sloppy and only cleans with the default python version,
# leaving all the other stuff still in build
clean::
	rm -rf build
