SUMMARY="An easy to understand, use, integrate, and expand SSL library"
DESCRIPTION="
PolarSSL is a official continuation fork of the XySSL SSL library. \
XySSL was created by the french white hat hacker Christophe Devine \
and was first released on November 1, 2006 under the GPL and BSD \
licenses. The core SSL library is written in C without external \
dependencies.
"
HOMEPAGE="https://www.polarssl.org"
SOURCE_URI="https://polarssl.org/download/polarssl-${portVersion}-gpl.tgz"
CHECKSUM_SHA256="6beef0281160bf07fefefd6b412dd1ce4c39261cf5300835aef442253f0400e5"
LICENSE="GNU GPL v2"
COPYRIGHT="
	2008-2014 Offspark B.V.
	"
REVISION="1"
ARCHITECTURES="?x86_gcc2 x86 x86_64 arm"
SECONDARY_ARCHITECTURES="?x86_gcc2 x86"

PATCHES="polarssl-$portVersion.patchset"

PROVIDES="
	polarssl$secondaryArchSuffix = $portVersion compat >= 6
	lib:libpolarssl$secondaryArchSuffix = $portVersion compat >= 6
	"

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libz$secondaryArchSuffix >= 1.2.3
	"
BUILD_REQUIRES="
	devel:libz$secondaryArchSuffix >= 1.2.3
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:gcc${secondaryArchSuffix}
	cmd:ld${secondaryArchSuffix}
	cmd:cmake
	cmd:make
	cmd:perl >= 5
	cmd:sed
	"

BUILD()
{
	# enable static and shared PolarSSL libraries
	cmake -DCMAKE_INSTALL_PREFIX:PATH=$prefix -DENABLE_PROGRAMS=0 \
		-DUSE_SHARED_POLARSSL_LIBRARY=1 -DUSE_STATIC_POLARSSL_LIBRARY=1 .

	make ${jobArgs}
}

INSTALL()
{
	make install

	# move include dir to correct location
	mkdir -p $(dirname $includeDir)
	mv $prefix/include $includeDir

	# prepare develop/lib
	prepareInstalledDevelLibs libpolarssl
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make test
}

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

PROVIDES_devel="
	polarssl${secondaryArchSuffix}_devel = $portVersion
	devel:libpolarssl${secondaryArchSuffix} = $portVersion compat >= 6
	"
REQUIRES_devel="
	polarssl${secondaryArchSuffix} == $portVersion base
	"
