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

DEB_PYTHON_SYSTEM = pycentral

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

DEB_INSTALL_EXAMPLES_python-nevow := examples/*
DEB_DH_ALWAYS_EXCLUDE := .svn
DEB_COMPRESS_EXCLUDE := .py .tac words

binary-post-install/python-nevow::
	# Clean up stuff
	find debian/$(cdbs_curpkg) -type d -name .svn -print0 | xargs -0 rm -rf
	find debian/$(cdbs_curpkg)/usr/share -type f -print0 | xargs -0 chmod -x

TOPMODULES:=nevow formless
install/python-nevow::
	# CDBS and setuptools seems not to be friends with Python 2.6. Move plugins by hand.
	[ ! -d debian/$(cdbs_curpkg)/usr/twisted ] || \
		mv debian/$(cdbs_curpkg)/usr/twisted \
			debian/$(cdbs_curpkg)/usr/lib/$(shell pyversions -d)/site-packages
	# Remove nevow.canvas (see bug #591198)
	rm debian/$(cdbs_curpkg)/usr/lib/$(shell pyversions -d)/site-packages/nevow/Canvas.swf
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	# Run tests
	ln -s ../../../doc \
		debian/$(cdbs_curpkg)/usr/lib/$(shell pyversions -d)/site-packages/doc
	$(call cdbs_python_binary,$(shell pyversions -d)) \
		debian/runtrial.py debian/$(cdbs_curpkg) $(TOPMODULES)
	rm debian/$(cdbs_curpkg)/usr/lib/$(shell pyversions -d)/site-packages/doc
	find debian/$(cdbs_curpkg)/usr -name dropin.cache -print0 | xargs -0 rm
endif
	# Generate documentation
	cd debian/$(cdbs_curpkg)/usr/doc/howto ; lore *.xhtml */*.xhtml */*/*.xhtml
	find debian/$(cdbs_curpkg)/usr/doc/howto -name '*.xhtml' -print0 | xargs -0 rm
	mkdir -p debian/$(cdbs_curpkg)/usr/share/doc/$(cdbs_curpkg)
	mv debian/$(cdbs_curpkg)/usr/doc/howto debian/$(cdbs_curpkg)/usr/share/doc/$(cdbs_curpkg)
	rm -rf debian/$(cdbs_curpkg)/usr/doc
	# Remove nit
	rm debian/$(cdbs_curpkg)/usr/bin/nit

clean::
	rm -rf _trial_temp
	rm -f setupcommon.pyc
