#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-

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

DEB_COMPRESS_EXCLUDE := .py .js
DEB_DH_INSTALL_SOURCEDIR := debian/python2.3-ldaptor
DEB_DH_ALWAYS_EXCLUDE := .svn

# see http://bugs.debian.org/295906
cdbs_python_ver = $(filter-out -%,$(subst -, -,$(patsubst python%,%,$(cdbs_curpkg))))

$(patsubst %,binary-post-install/%,$(DEB_PYTHON_REAL_LIB_PACKAGES)):: binary-post-install/python%-ldaptor:
	PYTHONPATH='debian/$(cdbs_curpkg)/usr/lib/python$(cdbs_python_ver)/site-packages' \
		'trial$(cdbs_python_ver)' --tbformat=emacs --reporter=text ldaptor

build/ldaptor-doc::
	make -C doc

binary-post-install/ldaptor-utils::
	rm -rf debian/ldaptor-utils/usr/bin/ldaptor-webui

binary-post-install/python%-ldaptor:: binary-install/ldaptor-utils binary-install/ldaptor-webui binary-install/ldaptor-common
	rm -rf \
		debian/python$*-ldaptor/usr/bin \
		debian/python$*-ldaptor/usr/lib/python$*/site-packages/ldaptor/apps/webui \
		debian/python$*-ldaptor/usr/lib/python$*/site-packages/ldaptor/test/test_webui.py \
		debian/python$*-ldaptor/usr/share/locale

binary-post-install/ldaptor-common::
	find debian/ldaptor-common/usr/share/locale \
		-name '*.mo' \
		-a \! -name 'ldaptor.mo' \
		-print0 \
	| xargs -0 --no-run-if-empty rm --

binary-post-install/ldaptor-webui::
	find debian/ldaptor-webui/usr/share/locale \
		-name '*.mo' \
		-a \! -name 'ldaptor-webui.mo' \
		-print0 \
	| xargs -0 --no-run-if-empty rm --

clean::
	find . -type f -name '*.pyc' -print0 \
	| xargs -0 --no-run-if-empty rm --
	make -C doc clean
	rm -rf _trial_temp
