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

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

VERSION := $(shell dpkg-parsechangelog | grep '^Version: ' | awk '{print $$2}')

%.py: %.py.in
	sed -e 's/__CHANGELOG_VERSION__/$(VERSION)/' < $< > $@

build: build-stamp
build-stamp: setup.py
	dh_testdir

	# Add here commands to compile the package.
	python setup.py build
	
	# run the tests
	cd tests && \
		for f in deb822 debfile debtags; do \
			./test_$$f.py ; \
		done 

	#python debian_bundle/python_support.py
	debian_bundle/doc-debtags > README.debtags

	touch $@

clean: setup.py
	dh_testdir
	dh_testroot
	rm -f build-stamp

	# Add here commands to clean up after the build process.
	python setup.py clean
	rm -rf build/
	rm -f README.debtags
	rm -f setup.py

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs

	# Add here commands to install the package into debian/tmp
	python setup.py install --root="$(CURDIR)/debian/python-debian" --no-compile


# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_installexamples
	# TODO: Enrico would like to keep wxssearch out of the package
	# but so far, he has no better place for it
	#rm "$(CURDIR)/debian/python-debian/usr/share/doc/python-debian/examples/wxssearch"
	rm "$(CURDIR)/debian/python-debian/usr/share/doc/python-debian/examples/debtags/wxssearch"
#	dh_install
	dh_compress -Xexamples
	dh_fixperms
	dh_pysupport -d
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
