SUMMARY="Low-level cryptographic library"
DESCRIPTION="Nettle is a cryptographic library that is designed to fit easily \
in more or less any context: In crypto toolkits for object-oriented languages \
(C++, Python, Pike, ...), in applications like LSH or GNUPG, or even in kernel \
space."
HOMEPAGE="https://www.lysator.liu.se/~nisse/nettle/"
COPYRIGHT="2001-2016 Niels Möller"
LICENSE="GNU GPL v2
	GNU GPL v3
	GNU LGPL v3"
REVISION="1"
SOURCE_URI="https://ftp.gnu.org/gnu/nettle/nettle-$portVersion.tar.gz"
CHECKSUM_SHA256="f001f64eb444bf13dd91bceccbc20acbc60c4311d6e2b20878452eb9a9cec75a"

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

PROVIDES="
	nettle$secondaryArchSuffix = $portVersion
	lib:libnettle$secondaryArchSuffix = 8.1 compat >= 8
	lib:libhogweed$secondaryArchSuffix = 6.1 compat >= 6
	"
if [ -z "$secondaryArchSuffix" ]; then
	PROVIDES="$PROVIDES
		cmd:nettle_hash
		cmd:nettle_lfib_stream
		cmd:nettle_pbkdf2
		cmd:pkcs1_conv
		cmd:sexp_conv
		"
fi

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgmp$secondaryArchSuffix
	"

PROVIDES_devel="
	nettle${secondaryArchSuffix}_devel = $portVersion
	devel:libnettle$secondaryArchSuffix = 8.1 compat >= 8
	devel:libhogweed$secondaryArchSuffix = 6.1 compat >= 6
	"
REQUIRES_devel="
	nettle$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgmp$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:automake
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	runConfigure ./configure
	make desdata
	make $jobArgs
}

INSTALL()
{
	make install

	rm -f $libDir/lib*.a

	prepareInstalledDevelLibs libnettle libhogweed

	fixPkgconfig

	packageEntries devel $developDir

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $binDir
		rm -rf $documentationDir
	fi
}

TEST()
{
	LIBRARY_PATH="$sourceDir/.lib:$LIBRARY_PATH" make check
}
