#! /usr/bin/make -f

#export DH_VERBOSE=1
export DH_COMPAT=4
export DH_OPTIONS

DEB_BUILD_ARCH   ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
PKG_SRC_DIR="debian/tmp"

DEB_SECTION=

CONFIGURE_FLAGS=--with-python-config=/usr/bin/python2.5-config

ifeq ($(DEB_BUILD_ARCH),armel)
DEB_SECTION=user\/
endif

switch-arch:
	pwd

build: build-stamp
build-stamp: configure-stamp
	dh_testdir
	touch $@

configure: configure-stamp
configure-stamp:
	dh_testdir
	#cp /usr/share/misc/config.sub .
	#cp /usr/share/misc/config.guess .
	./configure 
	touch $@

clean:
	dh_testdir
	-$(MAKE) distclean
	rm -f build-stamp configure-stamp
	dh_clean

install: DH_OPTIONS=
install: build
	dh_testdir
	dh_testroot
	dh_clean
	#dh_installdirs
	$(MAKE) install \
		INSTALL='/usr/bin/install -c -o root -g root' \
		DESTDIR=`pwd`/debian/tmp
	# HACK, I have no idea how to solve it
	mkdir -p $(PKG_SRC_DIR)/usr/lib/python2.4/site-packages
	mkdir -p $(PKG_SRC_DIR)/usr/lib/python2.5/site-packages	
	#cp $(PKG_SRC_DIR)/usr/lib/python2.3/site-packages/*midgard* $(PKG_SRC_DIR)/usr/lib/python2.4/site-packages/
	#cp $(PKG_SRC_DIR)/usr/lib/python2.3/site-packages/*midgard* $(PKG_SRC_DIR)/usr/lib/python2.5/site-packages/
	dh_install --sourcedir=debian/tmp
	
# nothing to do
binary-indep: DH_OPTIONS=-i
binary-indep:

binary-indep: DH_OPTIONS=-a
binary-arch: install
	dh_testdir
	dh_testroot
	dh_installdocs	
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_makeshlibs
	dh_shlibdeps -L libmidgard9.3
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary:	switch-arch binary-indep binary-arch 
.PHONY: switch-arch binary binary-arch binary-indep clean configure build
