SUMMARY="A minimalistic C client library for the Redis"
DESCRIPTION="Hiredis is a minimalistic C client library for the Redis database.

It is minimalistic because it just adds minimal support for the protocol, but \
at the same time it uses a high level printf-alike API in order to make it \
much higher level than otherwise suggested by its minimal code base and the \
lack of explicit bindings for every Redis command."
HOMEPAGE="https://github.com/redis/hiredis"
COPYRIGHT="2009-2011, Salvatore Sanfilippo
	2010-2011, Pieter Noordhuis"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="$HOMEPAGE/archive/refs/tags/v$portVersion.tar.gz"
CHECKSUM_SHA256="e0ab696e2f07deb4252dda45b703d09854e53b9703c7d52182ce5a22616c3819"
SOURCE_FILENAME="hiredis-v$portVersion.tar.gz"
PATCHES="hiredis-$portVersion.patchset"

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

PROVIDES="
	hiredis$secondaryArchSuffix = $portVersion
	lib:libhiredis$secondaryArchSuffix = 1.0.0
	lib:libhiredis_ssl$secondaryArchSuffix = 1.0.0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	"

PROVIDES_devel="
	hiredis${secondaryArchSuffix}_devel = $portVersion
	devel:libhiredis$secondaryArchSuffix = 1.0.0
	devel:libhiredis_ssl$secondaryArchSuffix = 1.0.0
	"
REQUIRES_devel="
	hiredis$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libssl$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:make
	cmd:gcc$secondaryArchSuffix
	"

BUILD()
{
	cmake -B build -S . \
		$cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release \
		-DENABLE_SSL=ON \
		-DCMAKE_CONF_INSTALL_DIR=$libDir/cmake -L # this doesn't seem to work
	make -C build
}

TEST_REQUIRES="
	cmd:redis_server
	"

INSTALL()
{
	make -C build install

	# move cmake files to the correct directory
	mkdir -p $libDir/cmake
	mv $prefix/share/* $libDir/cmake/
	rm -rf $prefix/share

	prepareInstalledDevelLibs libhiredis libhiredis_ssl
	fixPkgconfig

	packageEntries devel \
		$developDir \
		$libDir/cmake
}

TEST()
{
	make -C build test
}
