#!/usr/bin/make -f
# debian/rules for libiptcdata package
# Copyright (C) 2006-2007 Sylvain Le Gall <gildor at-stmp-server debian.org>
# Copyright (C) 2006-2007 Ian Wienand <ianw at-stmp-server debian.org>
# Copyright (C) 2006 Hubert Figuiere <hub at-smtp-server figuiere.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.

# Generate debian/control using
# fakeroot debian/rules debian/control DEB_AUTO_UPDATE_DEBIAN_CONTROL:=yes

PATH := $(PATH):$(CURDIR)/debian/bin
export PATH

DEB_DH_INSTALL_SOURCEDIR = $(CURDIR)/debian/tmp

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/autoreconf.mk
include /usr/share/cdbs/1/rules/utils.mk

PY_VERSIONS = $(shell pyversions --requested debian/control)

DEB_BUILDDIR := build

DEB_CONFIGURE_EXTRA_FLAGS := --enable-python --enable-gtk-doc --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)

configure-stamp-%:
	mkdir build-$*
	cd build-$* && PYTHON=`which $*` $(DEB_CONFIGURE_SCRIPT_ENV) \
	    $(DEB_CONFIGURE_SCRIPT) \
		$(DEB_CONFIGURE_NORMAL_ARGS) \
		--disable-maintainer-mode \
		$(cdbs_configure_flags) \
		$(DEB_CONFIGURE_EXTRA_FLAGS) \
		$(DEB_CONFIGURE_USER_FLAGS)
	touch $@


configure/python-iptcdata:: $(addprefix configure-stamp-, $(PY_VERSIONS))

build-stamp-%:
	make -C build-$*
	touch $@

build/python-iptcdata:: $(addprefix build-stamp-, $(PY_VERSIONS))

build/libiptcdata-bin::

install-stamp-%:
	make -C build-$* install DESTDIR=$(CURDIR)/debian/tmp
	touch $@

install/python-iptcdata:: $(addprefix install-stamp-, $(PY_VERSIONS))

binary-install/python-iptcdata::
	dh_python2

DEB_INSTALL_MANPAGES_libiptcdata-bin := debian/iptc.1

clean::
	-$(RM) -r $(DEB_BUILDDIR)
	-$(RM) -r $(addprefix $(CURDIR)/build-, $(PY_VERSIONS))
	-$(RM) -r $(addprefix $(CURDIR)/configure-stamp-, $(PY_VERSIONS))
	-$(RM) -r $(addprefix $(CURDIR)/build-stamp-, $(PY_VERSIONS))
	-$(RM) -r $(addprefix $(CURDIR)/install-stamp-, $(PY_VERSIONS))

