#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk

SUPP := $(shell ./parseversions --all --long)

clean::
	rm -f debhelper/dh_pysupport.1 *.pyc

check:
	dh_testdir
	cd tests && PATH=$(CURDIR):$$PATH ./testparseversions.py

maybe_check = $(if $(findstring nocheck,$(DEB_BUILD_OPTIONS)),,check)

build/python-support::
	cd debhelper && pod2man -c "python-support" -r "$(DEB_VERSION)" dh_pysupport dh_pysupport.1

binary-install/python-support:: $(maybe_check)
	for ver in $(SUPP); do \
	  subdir=dist-packages; \
	  if dpkg --compare-versions $$ver lt python2.6; then \
	    subdir=site-packages; \
	  fi; \
	  mkdir -p debian/python-support/usr/lib/$$ver/$$subdir; \
	  ln -s ../../pymodules/$$ver/.path debian/python-support/usr/lib/$$ver/$$subdir/python-support.pth; \
	done

