#!/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
DEB_DESTDIR = $(CURDIR)/debian/tmp
#To register a debug library package libfoo-dbg for libfoo (which needs unstripped '.so') in compat mode 4:
DEB_DH_STRIP_ARGS := --dbg-package=libbarry0 --dbg-package=libbarry-dev --dbg-package=barry-util --dbg-package=barrybackup-gui --dbg-package=libopensync-plugin-barry
#CDBS automatically handles common flags to pass to the configure script, 
#but it is possible to give some extra parameters : 
DEB_CONFIGURE_EXTRA_FLAGS := --with-boost=/usr --enable-gui --enable-opensync-plugin
COMMON_CONFIGURE_FLAGS := --prefix=/usr
DEB_INSTALL_DOCS_ALL =

install/barry-util::
	# Install udev rules for the barry-util package
	install -d $(CURDIR)/debian/barry-util/etc/udev/rules.d
	install -m 0644 $(CURDIR)/udev/10-blackberry.rules.Debian $(CURDIR)/debian/barry-util/etc/udev/rules.d/10-blackberry.rules
	# Install modprobe blacklist file for bcharge, into barry-util package
	install -d $(CURDIR)/debian/barry-util/etc/modprobe.d
	install -m 0644 $(CURDIR)/modprobe/blacklist-berry_charge $(CURDIR)/debian/barry-util/etc/modprobe.d/blacklist-berry_charge
	# Install default ppp options and chat scripts
	install -d $(CURDIR)/debian/barry-util/etc/ppp/peers
	install -m 0644 $(CURDIR)/ppp/barry-rogers $(CURDIR)/ppp/barry-verizon $(CURDIR)/ppp/barry-sprint $(CURDIR)/ppp/barry-o2ireland $(CURDIR)/ppp/barry-tmobileus $(CURDIR)/ppp/barry-att_cingular $(CURDIR)/debian/barry-util/etc/ppp/peers
	install -d $(CURDIR)/debian/barry-util/etc/chatscripts
	install -m 0640 $(CURDIR)/ppp/barry-rogers.chat $(CURDIR)/ppp/barry-verizon.chat $(CURDIR)/ppp/barry-sprint.chat $(CURDIR)/ppp/barry-o2ireland.chat $(CURDIR)/ppp/barry-tmobileus.chat $(CURDIR)/ppp/barry-att_cingular.chat $(CURDIR)/debian/barry-util/etc/chatscripts
	# Install hal fdi config
	install -d $(CURDIR)/debian/barry-util/usr/share/hal/fdi/information/10freedesktop
	install -m 0644 $(CURDIR)/hal/10-blackberry.fdi $(CURDIR)/debian/barry-util/usr/share/hal/fdi/information/10freedesktop
	# Install hal support script
	install -d $(CURDIR)/debian/barry-util/usr/bin
	install -m 0755 $(CURDIR)/hal/hal-blackberry $(CURDIR)/debian/barry-util/usr/bin

post-patches::
	@test -x $(DEB_SRCDIR)/configure && echo "allready autoreconf" || (cd $(DEB_SRCDIR) && autoreconf -i)

clean::
	-@rm -f $(DEB_SRCDIR)/config.guess $(DEB_SRCDIR)/config.sub $(DEB_SRCDIR)/ltmain.sh $(DEB_SRCDIR)/aclocal.m4 
	-@rm -f $(DEB_SRCDIR)/config.h.in $(DEB_SRCDIR)/mkinstalldirs $(DEB_SRCDIR)/install-sh
	-@rm -f $(DEB_SRCDIR)/missing $(DEB_SRCDIR)/depcomp $(DEB_SRCDIR)/configure $(DEB_SRCDIR)/subdirs
	-@rm -rf build/ $(DEB_SRCDIR)/configure.files $(DEB_SRCDIR)/stamp-h.in
	-@rm `find . -type f -name "Makefile.in" -print`

