#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

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

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

# Include dpatch stuff
include /usr/share/dpatch/dpatch.make
# Include pkg-gnome stuff.
include /usr/share/gnome-pkg-tools/1/rules/uploaders.mk

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -g
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

PYVERS=2.5

.PRECIOUS: build-%/configure-stamp

build-%/configure-stamp: configure
	dh_testdir
	mkdir -p build-$*
	cd build-$* && PYTHON=/usr/bin/python$* ../configure    \
		--host=$(DEB_HOST_GNU_TYPE)	     \
		--build=$(DEB_BUILD_GNU_TYPE)	   \
		--prefix=/usr \
		--with-gtkmozembed=any
	touch $@

build-%/build-stamp: build-%/configure-stamp
	dh_testdir
	$(MAKE) -C build-$*
	touch $@

build: patch $(PYVERS:%=build-%/build-stamp)

clean:: unpatch
	dh_testdir
	dh_testroot
	rm -rf build-* debian/tmp-*
	dh_clean

install-clean:
	dh_testdir
	dh_testroot
	dh_clean -k

install-%: build-%/build-stamp
	dh_testdir
	dh_testroot
	$(MAKE) -C build-$* install DESTDIR=$(CURDIR)/debian/tmp-$*
	dh_install --sourcedir=debian/tmp-$*

install: build install-clean $(PYVERS:%=install-%)
	dh_installdirs

# Build architecture-independent files here.
binary-indep:
	dh_testdir -i
	dh_testroot -i
	dh_installdocs -i
	dh_installexamples -i
	dh_installmenu -i
	dh_installcron -i
	dh_installinfo -i
	dh_installchangelogs ChangeLog -i
	dh_link -i
	dh_compress -i
	dh_fixperms -i
	dh_pysupport -i
	dh_python -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir -a
	dh_testroot -a
	dh_installdocs -a
	dh_installexamples -a
	dh_installmenu -a
	dh_installman -a
	dh_installinfo -a
	dh_installchangelogs ChangeLog -a
	dh_link -a
	dh_pysupport -a
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

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