SUMMARY="IRC to IM gateway that support multiple IM protocols"
DESCRIPTION="BitlBee brings IM (instant messaging) to IRC clients. It's a \
great solution for people who have an IRC client running all the time and \
don't want to run an additional MSN/AIM/whatever client.
BitlBee currently supports the following IM networks/protocols: XMPP/Jabber \
(including Google Talk and Hipchat), MSN/Skype, Yahoo! Messenger, AIM and \
ICQ, the Twitter microblogging network (plus all other Twitter API \
compatible services like status.net)"
HOMEPAGE="https://www.bitlbee.org/"
COPYRIGHT="2002-2017 Wilmer van der Gaast and others"
LICENSE="GNU GPL v2
	BSD (2-clause)
	GNU LGPL v2.1
	GNU FDL v1.1"
REVISION="1"
SOURCE_URI="https://github.com/bitlbee/bitlbee/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="741c139ed65c92227401bed344a03c8674536426cd4fdfc12e6406b8622a7c29"
SOURCE_FILENAME="bitlbee-$portVersion.tar.gz"
PATCHES="bitlbee-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	bitlbee$secondaryArchSuffix = $portVersion
	cmd:bitlbee$commandSuffix = $portVersion

	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgcrypt$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libgmodule_2.0$secondaryArchSuffix
	lib:libgnutls$secondaryArchSuffix
	lib:libgpg_error$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libldap$secondaryArchSuffix
	lib:libpam$secondaryArchSuffix
	lib:libpurple$secondaryArchSuffix
	"

PROVIDES_devel="
	bitlbee${secondaryArchSuffix}_devel = $portVersion
	"
REQUIRES_devel="
	bitlbee$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgcrypt$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libgmodule_2.0$secondaryArchSuffix
	devel:libgnutls$secondaryArchSuffix
	devel:libgpg_error$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libldap$secondaryArchSuffix
	devel:libpam$secondaryArchSuffix
	devel:libpurple$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python2
	"

GLOBAL_WRITABLE_FILES="
	settings/bitlbee/bitlbee.conf keep-old
	settings/bitlbee/motd.txt keep-old
	"

defineDebugInfoPackage bitlbee$secondaryArchSuffix \
	$commandBinDir/bitlbee

BUILD()
{
	export CFLAGS="-D_BSD_SOURCE -DB_USE_POSITIVE_POSIX_ERRORS"
	export LDFLAGS="-lnetwork -lposix_error_mapper -lbsd"
	runConfigure --omit-dirs "binDir sbinDir" ./configure \
		--bindir=$commandBinDir \
		--sbindir=$commandBinDir \
		--etcdir=$sysconfDir/bitlbee \
		--config=$sharedStateDir/bitlbee \
		--pidfile=$localStateDir/bitlbee.pid \
		--pcdir=$libDir/pkgconfig \
		--plugindir=$addOnsDir/bitlbee \
		--purple=1 \
		--doc=1 \
		--debug=1 \
		--strip=0 \
		--plugins=1 \
		--otr=auto \
		--pam=1 \
		--ldap=1

	make $jobArgs
}

INSTALL()
{
	make install
	make install-etc
	make install-dev

	# prepare develop/lib
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir \
		$libDir
}

TEST()
{
	make check
}
