#!/usr/bin/make -f

export DEB_BUILD_HARDENING=1

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


# Build into a separate directory
DEB_BUILDDIR = $(DEB_SRCDIR)/build

LDFLAGS = -Wl,--as-needed
DEB_CONFIGURE_EXTRA_FLAGS = --disable-gevolution \
	    --enable-cap --with-system-ssl-certs=/etc/ssl/certs \
	    --enable-perl --with-zephyr=/usr --enable-dbus --enable-gnutls=no \
	    --enable-nss=yes --enable-cyrus-sasl --enable-vv \
	    --enable-tcl --enable-tk \
	    --with-dynamic-prpls=bonjour,gg,irc,jabber,msn,myspace,mxit,novell,oscar,sametime,simple,yahoo,zephyr # disable silc
ifeq ($(DEB_BUILD_ARCH_OS),linux)
  DEB_CONFIGURE_EXTRA_FLAGS += --enable-nm
else
  DEB_CONFIGURE_EXTRA_FLAGS += --disable-nm
endif


DEB_INSTALL_DOCS_ALL := -XAUTHORS -XNEWS -XREADME

DEB_DH_MAKESHLIBS_ARGS_pidgin := -V -X/usr/lib/pidgin
DEB_DH_SHLIBDEPS_ARGS_pidgin := -X/usr/lib/pidgin/cap.so -- -dSuggests debian/pidgin/usr/lib/pidgin/cap.so -dDepends
DEB_PERL_INCLUDE_pidgin := -d /usr/lib/pidgin/perl

# finch package
DEB_DH_MAKESHLIBS_ARGS_finch := -V -X/usr/lib/finch
DEB_DH_SHLIBDEPS_ARGS_finch := -X/usr/lib/finch/gntclipboard.so -X/usr/lib/finch/gntgf.so -- -dSuggests debian/finch/usr/lib/finch/gntclipboard.so debian/finch/usr/lib/finch/gntgf.so -dDepends

# libpurple package
DEB_DH_MAKESHLIBS_ARGS_libpurple0 := -X/usr/lib/purple-2
DEB_DH_SHLIBDEPS_ARGS_libpurple0 := -X/usr/lib/purple-2/tcl.so -- -dSuggests debian/libpurple0/usr/lib/purple-2/tcl.so -dDepends
DEB_PERL_INCLUDE_libpurple0 := -d /usr/lib/purple-2/perl

# for pidgin-dev, extra documentation is installed manually below
DEB_INSTALL_MANPAGES_pidgin-dev := debian/dh_pidgin.1

clean::
	rm -f debian/copyright

makebuilddir/pidgin::
	touch configure # We don't want to regenerate autotools files

common-install-impl::
	rm -f debian/tmp/usr/lib/pidgin/relnot.so # release notification plugin
	rm -f debian/tmp/usr/bin/nullclient # examples
	rm -f debian/tmp/usr/bin/purple-client-example # examples
	find debian/tmp/usr/lib -name '*.la' -print0 | xargs -0 rm
	# Include author lists in copyright file
	sed -e '/@PIDGIN_COPYRIGHT@/r COPYRIGHT' \
		-e '/@PIDGIN_COPYRIGHT@/d' \
		-e '/@OSCAR_AUTHORS@/r libpurple/protocols/oscar/AUTHORS' \
		-e '/@OSCAR_AUTHORS@/d' \
	debian/copyright.in > debian/copyright

cleanbuilddir/pidgin::
	rm -rf $(DEB_SRCDIR)/build

build/pidgin-dev::
	pod2man debian/dh_pidgin > debian/dh_pidgin.1
	cd build; make docs

binary-install/pidgin-dev::
	dh_installdocs -ppidgin-dev debian/README.Debian.dev

cleanbuilddir/pidgin-dev::
	rm -f debian/dh_pidgin.1
