#!/usr/bin/make -f

DEB_PYTHON_SYSTEM=pysupport

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/class/python-module.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk
include /usr/share/python/python.mk

DEB_CONFIGURE_EXTRA_FLAGS := --enable-python \
			  --with-perl=/usr/bin/perl \
			  --disable-ruby \
			  --disable-csharp \
			  --disable-apache \
			  --enable-gettext

CFLAGS += -fPIC

PERL_ARCHLIB := $(shell perl -MConfig -e 'print $$Config{vendorarch}')

# retrieve supported python versions (2.3 and 2.4 as of June 02006)
PYVERS=$(shell pyversions -vr debian/control)

DEB_MAKE_INSTALL_TARGET := install DESTDIR=$(CURDIR)/debian/tmp
DEB_SHLIBDEPS_INCLUDE_libclearsilver-perl := debian/libclearsilver-perl$(PERL_ARCHLIB)
DEB_SHLIBDEPS_INCLUDE_python-clearsilver := $(patsubst %,debian/python-clearsilver/usr/lib/python-%/$(call py_sitename, %),$(PYVERS))

build/python-clearsilver:: $(PYVERS:%=build-python-%)

build-python-%:
	install -d debian/tmp/usr/lib/python$*/$(call py_sitename, $*)
	make -C $(DEB_BUILDDIR)/python distclean
	make -C $(DEB_BUILDDIR)/python \
		PYTHON=/usr/bin/python$* PYTHON_INC=-I/usr/include/python$*
	install -m644 $(DEB_BUILDDIR)/python/neo_cgi.so \
    	    debian/tmp/usr/lib/python$*/$(call py_sitename, $*)/neo_cgi.so

