#!/usr/bin/make -f
# Based on the multi2 sample debian/rules file:
# ---
# Sample debian/rules that uses debhelper.
# This file is public domain software, originally written by Joey Hess.

#export DH_VERBOSE=1
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
#include /usr/share/cdbs/1/rules/simple-patchsys.mk

# where sources are
DEB_SRCDIR = .

# in which directory to build
DEB_BUILDDIR = .

# in which directory to install the sofware(must be full path! CURDIR does this)
DEB_DESTDIR = $(CURDIR)/debian/tmp

#CDBS automatically handles common flags to pass to the configure script,
#but it is possible to give some extra parameters :
DEB_CONFIGURE_EXTRA_FLAGS := --enable-rpathhack
COMMON_CONFIGURE_FLAGS := --prefix=/usr
DEB_INSTALL_DOCS_ALL =

post-patches::
	@rm -f $(CURDIR)/deb_srcdir
	@ln -s $(DEB_SRCDIR) $(CURDIR)/deb_srcdir
	@test -x $(DEB_SRCDIR)/configure && echo "allready autoreconf" || (cd $(DEB_SRCDIR) && autoreconf -i)

makebuilddir::
	# This rule is meant for the parent debian/rules to be able to call
	# us, and give us the location of a pre-built libbarry to
	# insert into our DESTDIR, to avoid needing to install
	# libbarry-dev to build this package.
	# If TREE_BUILD_DIR is empty, nothing happens.
	(if [ -n "$(TREE_BUILD_DIR)" ] ; then \
		cd $(TREE_BUILD_DIR) && \
		make DESTDIR=$(DEB_DESTDIR) install && \
		rm -f `find $(DEB_DESTDIR) -name "*.la"` && \
		cp $(TREE_BUILD_DIR)/debian/libbarry*/DEBIAN/shlibs \
			$(CURDIR)/debian/shlibs.local ; \
	fi)

clean::
	-@rm -f $(CURDIR)/deb_srcdir

