#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog \
    | grep ^Version: | cut -d ' ' -f 2 | cut -d '-' -f 1)

PYVERS=$(shell pyversions -vr)

clean:
	dh_testdir
	dh_testroot
	rm -f build-*
	rm -rf build
	find . -name *\.py[co] -exec rm {} \;
	-rm -rf dist
	-rm -rf pida.egg-info
	-rm -f moo/moo-pygtk.c moo/moomarshals.[ch] moo/stock-moo.h 
	dh_clean

build:

build-arch: build

build-indep: build

install: $(PYVERS:%=install-python%)
	# override the setup.py-installed binaries with canonical versions,
	# so we always call the default python interpreter
	cp $(CURDIR)/bin/pida $(CURDIR)/debian/pida/usr/bin/
	cp $(CURDIR)/bin/pida-remote $(CURDIR)/debian/pida/usr/bin/

install-python%:
	@echo "----------- BUILDING FOR $* ------------"
	# Fix executable png from source tarball
	chmod 644 pida/resources/pixmaps/pida-icon.png
	python$* setup.py install \
		--root $(CURDIR)/debian/pida \
		--prefix=/usr
		#--install-lib $(CURDIR)/debian/pida/usr/share/pida \
		#--install-data $(CURDIR)/debian/pida/usr/share/pida \
		#--install-scripts $(CURDIR)/debian/pida/usr/bin

# Build architecture-independent files here.
binary-indep:

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs CHANGELOG
	dh_installdirs
	dh_install
	dh_installdocs
#       dh_installexamples examples/*
	dh_installman
	dh_installmenu
	dh_python2
	dh_strip
	dh_compress -X.py
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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

