#!/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

# Don't compress .py files
DEB_COMPRESS_EXCLUDE := .py .txt .cfg .js

# Install egg-info directories
DEB_PYTHON_INSTALL_ARGS_ALL += --single-version-externally-managed
DEB_DESTDIR=debian/python-genshi

# Enable the C extension
DEB_PYTHON_SETUP_CMD += --with-speedups

binary-install/python-genshi::
	PYTHONPATH=$(cdbs_python_destdir)/usr/lib/pyshared/python$(cdbs_python_current_version) python setup.py test || exit 1

clean::
	-rm -rf $(CURDIR)/Genshi.egg-info

## SVN snapshot (changelog entry with a version: a.b.c~svnREVISION-d)
## Get the source  from the SVN upstream repository,  then generate the
## documentation (which is  in the release tarballs but  not in the SVN
## repository and requires  python-docutils and python-epydoc packages)
## and finally create the tarball
#SVN_URL := https://svn.edgewall.org/repos/genshi/trunk
#SVN_REVISION := $(shell echo $(DEB_UPSTREAM_VERSION)|sed 's/.*~svn\([0-9]*\)/\1/')
#SVN_DEB_TARBALL_DIR := $(CURDIR)/debian/$(DEB_SOURCE_PACKAGE)-$(DEB_UPSTREAM_VERSION)
#SVN_DEB_TARBALL :=  $(CURDIR)/../$(DEB_SOURCE_PACKAGE)_$(DEB_UPSTREAM_VERSION).orig.tar.gz
#
## Adapted to CDBS and Genshi from:
##  http://wiki.debian.org/SandroTosi/Svn_get-orig-source
#get-orig-source:
#	-rm -rf $(SVN_DEB_TARBALL_DIR) $(SVN_DEB_TARBALL)
#
#	svn export -r $(SVN_REVISION) $(SVN_URL) $(SVN_DEB_TARBALL_DIR)
#
#	( cd $(SVN_DEB_TARBALL_DIR) && python setup.py build_doc )
#
#	# Get rid of byte-compile files created when building the
#	# documentation
#	find $(SVN_DEB_TARBALL_DIR) -name '*.pyc' -exec rm '{}' \;
#
#	GZIP='--best --no-name' tar czf $(SVN_DEB_TARBALL) -C $(SVN_DEB_TARBALL_DIR)/../ \
#		$(DEB_SOURCE_PACKAGE)-$(DEB_UPSTREAM_VERSION)
#
#	-rm -rf $(SVN_DEB_TARBALL_DIR)
#
#	echo "Created: $(SVN_DEB_TARBALL)"
#
#.PHONY: get-orig-source
