SUMMARY="A library for IM communication"
DESCRIPTION="libpurple is a library for IM communication used by many open \
source IM clients. It implements a variety of protocols, for example IRC, \
Jabber or ICQ."
HOMEPAGE="https://pidgin.im/"
LICENSE="GNU GPL v2"
REVISION="1"

ARCHITECTURES="x86 ?x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

SOURCE_URI="http://downloads.sourceforge.net/project/pidgin/Pidgin/$portVersion/pidgin-$portVersion.tar.bz2"
CHECKSUM_SHA256="f2ae211341fc77efb9945d40e9932aa535cdf3a6c8993fe7919fca8cc1c04007"
COPYRIGHT="1998-2015 Rob Flynn et al."
SOURCE_DIR="pidgin-$portVersion"

PROVIDES="
	libpurple$secondaryArchSuffix = $portVersion
	lib:libpurple$secondaryArchSuffix = $portVersion
	lib:libgnt$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libgobject_2.0$secondaryArchSuffix
	lib:libgmodule_2.0$secondaryArchSuffix
	lib:libgthread_2.0$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libidn$secondaryArchSuffix
	lib:libnss3$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libnspr4$secondaryArchSuffix
	lib:libfreebl3$secondaryArchSuffix
	lib:libnss3$secondaryArchSuffix
	lib:libnssckbi$secondaryArchSuffix
	lib:libnssdbm3$secondaryArchSuffix
	lib:libnssutil3$secondaryArchSuffix
	lib:libsmime3$secondaryArchSuffix
	lib:libsoftokn3$secondaryArchSuffix
	lib:libssl3$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libffi$secondaryArchSuffix
	lib:libpanelw$secondaryArchSuffix
	lib:libncursesw$secondaryArchSuffix
	"
PROVIDES_devel="
	libpurple${secondaryArchSuffix}_devel = $portVersion
	devel:libpurple$secondaryArchSuffix = $portVersion
	devel:libgnt$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	haiku${secondaryArchSuffix}_devel
	libpurple$secondaryArchSuffix == $portVersion base
	"
PROVIDES_finch="
	libpurple${secondaryArchSuffix}_finch = $portVersion
	cmd:finch$secondaryArchSuffix
	"
REQUIRES_finch="
	haiku${secondaryArchSuffix}
	libpurple$secondaryArchSuffix == $portVersion base
	lib:libffi$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libgmodule_2.0$secondaryArchSuffix
	lib:libgobject_2.0$secondaryArchSuffix
	lib:libgthread_2.0$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libidn$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libncurses${secondaryArchSuffix}
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	glib2${secondaryArchSuffix}_devel
	devel:libglib_2.0$secondaryArchSuffix
	devel:libgobject_2.0$secondaryArchSuffix
	devel:libgmodule_2.0$secondaryArchSuffix
	devel:libgthread_2.0$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libidn$secondaryArchSuffix
	devel:libnss3$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libnspr4$secondaryArchSuffix
	devel:libfreebl3${secondaryArchSuffix}
	devel:libnss3${secondaryArchSuffix}
	devel:libnssckbi${secondaryArchSuffix}
	devel:libnssdbm3${secondaryArchSuffix}
	devel:libnssutil3${secondaryArchSuffix}
	devel:libsmime3${secondaryArchSuffix}
	devel:libsoftokn3${secondaryArchSuffix}
	devel:libssl3${secondaryArchSuffix}
	devel:libncurses${secondaryArchSuffix}
	"
BUILD_PREREQUIRES="
	makefile_engine
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	cmd:awk
	cmd:gettext
	cmd:intltool_update
	cmd:intltool_merge
	cmd:intltool_extract
	cmd:libtoolize
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	"

PATCH()
{
	sed -i 's/-lresolv/-lnetwork/g' configure
}

BUILD()
{
	libtoolize --force --copy --install
	CFLAGS="-D__SVR4 -D__sun -D_XPG5" \
	LDFLAGS="-lbsd" \
	runConfigure ./configure \
		--disable-gtkui --disable-screensaver \
		--disable-meanwhile --disable-dbus --disable-gstreamer --disable-vv \
		--disable-avahi --disable-gnutls --disable-tcl -enable-textui \
		--with-nspr-includes=$(finddir B_SYSTEM_HEADERS_DIRECTORY)/${secondaryArchSubDir} \
		--with-nspr-libs=$(finddir B_SYSTEM_LIB_DIRECTORY)/${secondaryArchSubDir} \
		--with-nss-includes=$(finddir B_SYSTEM_HEADERS_DIRECTORY)/${secondaryArchSubDir}/nss \
		--with-nss-libs=$(finddir B_SYSTEM_LIB_DIRECTORY)/${secondaryArchSubDir} \
		--with-ncurses-headers=$(finddir B_SYSTEM_HEADERS_DIRECTORY)/${secondaryArchSubDir}
	make $jobArgs
}

INSTALL()
{
	make install
	rm -rf $prefix/share

	packageEntries finch $binDir

	prepareInstalledDevelLib libpurple
	prepareInstalledDevelLib libgnt
	packageEntries devel $developDir
}
