SUMMARY="Apache Portable Runtime Utility Library"
DESCRIPTION="The mission of the Apache Portable Runtime (APR) project is to \
create and maintain software libraries that provide a predictable and \
consistent interface to underlying platform-specific implementations. The \
primary goal is to provide an API to which software developers may code and be \
assured of predictable if not identical behaviour regardless of the platform \
on which their software is built, relieving them of the need to code special-\
case conditions to work around or take advantage of platform-specific \
deficiencies or features.

To give a brief overview, the primary core subsystems of APR 1.x include \
the following:

- atomic operations
- dynamic Shared Object loading
- file I/O
- locks (mutexes, condition variables, etc)
- memory management (high performance allocators)
- memory-mapped files
- multicast Sockets
- network I/O
- shared memory
- thread and Process management
- various data structures (tables, hashes, priority queues, etc)"
HOMEPAGE="http://apr.apache.org/"
COPYRIGHT="2010 The Apache Software Foundation."
LICENSE="Apache v2"
REVISION="4"
SOURCE_URI="http://archive.apache.org/dist/apr/apr-util-1.3.10.tar.gz"
CHECKSUM_SHA256="7c37ac40b2351bfc23000fb6b7b54a67e0872255df315c82eb60c821bcef4b23"
SOURCE_DIR="apr-util-$portVersion"
PATCHES="apr_util-1.3.10.patch"

ARCHITECTURES="x86_gcc2 ?x86"

PROVIDES="
	apr_util = $portVersion compat >= 1
	lib:libaprutil = $portVersion compat >= 1
	lib:libaprutil_1 = $portVersion compat >= 1
	"
REQUIRES="
	haiku
	apr >= 1.3.9
	expat >= 2.0
	"

BUILD_REQUIRES="
	$REQUIRES
	"
BUILD_PREREQUIRES="
	haiku_devel
	cmd:aclocal
	cmd:autoconf
	cmd:autoheader
	cmd:gcc
	cmd:ld
	cmd:libtoolize
	cmd:make
	"

BUILD()
{
	aprUtilPackageLinksDir=$(finddir B_PACKAGE_LINKS_DIRECTORY)/$portRevisionedName
	aprInstallDir=$aprUtilPackageLinksDir/apr
	expatInstallDir=$aprUtilPackageLinksDir/expat

	rm -rf aclocal.m4
	mkdir -p m4
	libtoolize -fci
	aclocal --install -I m4
	autoconf -f
	cd xml/expat
	mkdir -p m4
	echo 'AM_INIT_AUTOMAKE' >> configure.in
	libtoolize -fci
	aclocal --install -I m4
	autoconf --force
	autoheader
	touch libtool.m4
	cd ../..

	# TODO: fix this hack!
	cp /boot/common/bin/libtool .
	ln -sfn $sourceDir/libtool /libtool

    ./configure $configureDirArgs \
		--with-apr=$aprInstallDir \
		--with-expat=$expatInstallDir
	make
}

INSTALL()
{
	make install

	# prepare develop/lib
	prepareInstalledDevelLibs libaprutil-1
	fixPkgconfig
}
