SUMMARY="Libevent - an event notification library"
DESCRIPTION="The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Furthermore, libevent also support callbacks due to signals or regular timeouts.
libevent is meant to replace the event loop found in event driven network servers. An application just needs to call event_dispatch() and then add or remove events dynamically without having to change the event loop."
HOMEPAGE="http://www.libevent.org/"
SOURCE_URI="http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz"
CHECKSUM_SHA256="afa61b476a222ba43fc7cca2d24849ab0bbd940124400cb699915d3c60e46301"
LICENSE="BSD (3-clause)"
COPYRIGHT="2000-2007 Niels Provos, 2005 Nick Mathewson, and other contributors."

REVISION="1"

ARCHITECTURES="x86_gcc2 x86"

SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	cmd:event_rpcgen.py
	lib:libevent_1.4$secondaryArchSuffix = 2.2.0 compat >= 2
	lib:libevent_core_1.4$secondaryArchSuffix = 2.2.0 compat >= 2
	lib:libevent_extra_1.4$secondaryArchSuffix = 2.2.0 compat >= 2
	lib:libevent$secondaryArchSuffix = 2.2.0 compat >= 2
	lib:libevent_core$secondaryArchSuffix = 2.2.0 compat >= 2
	lib:libevent_extra$secondaryArchSuffix = 2.2.0 compat >= 2
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"
BUILD_REQUIRES="
	"

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	"
SOURCE_DIR="libevent-${portVersion}-stable"

PATCHES="libevent-1.4.14b.patch"

BUILD()
{
	sed -i 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/g' configure.in
	sed -i 's/TESTS = $(top_srcdir)/TESTS = {$sourceDir}/g' test/Makefile.am

	libtoolize --force --copy --install
	aclocal
	autoconf
	automake --add-missing
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{		
	make install
	
# TODO: replace /packages/libevent-1.4.14b-1/.self/ with an alias	
	mv /packages/libevent-1.4.14b-1/.self/lib/libevent.a \
		/packages/libevent-1.4.14b-1/.self/lib/libevent.la \
		/packages/libevent-1.4.14b-1/.self/lib/libevent_core.a \
		/packages/libevent-1.4.14b-1/.self/lib/libevent_core.la \
		/packages/libevent-1.4.14b-1/.self/lib/libevent_extra.a \
		/packages/libevent-1.4.14b-1/.self/lib/libevent_extra.la \
		$developDir

	prepareInstalledDevelLibs \
		libevent-1.4 \
		libevent_core-1.4 \
		libevent_extra-1.4

	fixPkgconfig

	# devel package

	packageEntries devel \
		$developDir
}

# ----- devel package -------------------------------------------------------

PROVIDES_devel="
	cmd:event_rpcgen.py	
	lib:libevent_1.4$secondaryArchSuffix = 2.2.0 compat >= 2
	lib:libevent_core_1.4$secondaryArchSuffix = 2.2.0 compat >= 2
	lib:libevent_extra_1.4$secondaryArchSuffix = 2.2.0 compat >= 2
	lib:libevent$secondaryArchSuffix = 2.2.0 compat >= 2
	lib:libevent_core$secondaryArchSuffix = 2.2.0 compat >= 2
	lib:libevent_extra$secondaryArchSuffix = 2.2.0 compat >= 2	
	devel:libevent_1.4$secondaryArchSuffix = 2.2.0 compat >= 2
	devel:libevent_core_1.4$secondaryArchSuffix = 2.2.0 compat >= 2
	devel:libevent_extra_1.4$secondaryArchSuffix = 2.2.0 compat >= 2
	devel:libevent_core$secondaryArchSuffix = 2.2.0 compat >= 2
	devel:libevent_extra$secondaryArchSuffix = 2.2.0 compat >= 2
	"

REQUIRES_devel="
	libevent$secondaryArchSuffix  == $portVersion base
	"
