#!/usr/bin/make -f
# -*- makefile -*-

PYVERS=$(shell pyversions -vr)
PYLIBPATH := $(shell python -c "from distutils.command.build import build ; from distutils.core import Distribution ; b = build(Distribution()) ; b.finalize_options() ; print b.build_platlib")

%:
	dh $@

override_dh_auto_build:
	set -e ; \
	for py in $(PYVERS); do \
		python$$py setup.py build ; \
		python$$py-dbg setup.py build ; \
	done
	# build doc
	PYTHONPATH=$(PYLIBPATH) ./gendoc.sh Levenshtein

override_dh_auto_clean:
	rm -f Levenshtein.html NEWS.xhtml
	dh_auto_clean

override_dh_auto_install:
	set -e ; \
	for py in $(PYVERS); do \
		python$$py setup.py install --root $(CURDIR)/debian/python-levenshtein --install-layout=deb ; \
		python$$py-dbg setup.py install --root $(CURDIR)/debian/python-levenshtein-dbg --install-layout=deb ; \
	done
	find $(CURDIR)/debian/python-levenshtein-dbg -type f -name "*.egg-info" -delete

override_dh_installdocs:
	dh_installdocs README NEWS Levenshtein.html

override_dh_installexamples:
	dh_installexamples StringMatcher.py

override_dh_strip:
ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
	dh_strip --dbg-package=python-levenshtein-dbg
	# fix python-debug-in-wrong-location lintian warning
	cd debian/*-dbg/usr/lib/debug/usr/lib && mv pyshared pymodules
endif
