SUMMARY="Cross-platform asynchronous I/O"
DESCRIPTION="libuv is a multi-platform support library with a focus on \
asynchronous I/O. It was primarily developed for use by Node.js, but it's also \
used by Luvit, Julia, pyuv, and others."
HOMEPAGE="https://libuv.org/"
COPYRIGHT="2015-present libuv project contributors"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/libuv/libuv/archive/v$portVersion/libuv-$portVersion.tar.gz"
CHECKSUM_SHA256="371e5419708f6aaeb8656671f89400b92a9bba6443369af1bb70bcd6e4b3c764"
PATCHES="libuv-$portVersion.patchset"

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

libVersion="1.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	libuv$secondaryArchSuffix = $portVersion
	lib:libuv$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libuv${secondaryArchSuffix}_devel = $portVersion
	devel:libuv$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libuv$secondaryArchSuffix == $portVersion
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libuv$secondaryArchSuffix \
	"$libDir"/libuv.so.$libVersion

BUILD()
{
	./autogen.sh

	LDFLAGS="-lnetwork" runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	# remove libtool file and static library
	rm -f $libDir/libuv.la $libDir/libuv.a

	prepareInstalledDevelLib libuv

	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
