SUMMARY="An embedded SSL implementation"
DESCRIPTION="The wolfSSL embedded SSL library (formerly CyaSSL) is a \
lightweight SSL/TLS library written in ANSI C and targeted for embedded, \
RTOS, and resource-constrained environments - primarily because of its \
small size, speed, and feature set."
HOMEPAGE="https://www.wolfssl.com/"
COPYRIGHT="2006-2018 Sawtooth Consulting Ltd."
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/wolfSSL/wolfssl/archive/v$portVersion-stable.tar.gz"
CHECKSUM_SHA256="2b98d9ddac2a3188210de720051bed58f91910ee028a4b0a6dd6fd3c9ddb6fec"
SOURCE_FILENAME="wolfssl-$portVersion.tar.gz"
SOURCE_DIR="wolfssl-$portVersion-stable"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
 	commandSuffix=
 	commandBinDir=$prefix/bin
fi

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

PROVIDES="
	wolfssl$secondaryArchSuffix = $portVersion
	cmd:wolfssl_config$commandSuffix
	lib:libwolfssl$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	wolfssl${secondaryArchSuffix}_devel
	devel:libwolfssl$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	wolfssl$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoreconf
	cmd:dos2unix
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage wolfssl$secondaryArchSuffix \
	"$libDir"/libwolfssl.so.$libVersion

BUILD()
{
	autoreconf -vfi
	runConfigure --omit-dirs binDir ./configure \
		--bindir="$commandBinDir" \
		--enable-shared
	make $jobArgs
}

INSTALL()
{
	make install

	rm "$libDir"/*.la

	prepareInstalledDevelLib libwolfssl
	fixPkgconfig

	packageEntries devel \
		"$developDir"
}

TEST()
{
	make check
	#cd testsuite
	#testsuite
}
