SUMMARY="GNU's basic cryptographic library"
DESCRIPTION="Libgcrypt is a general purpose crypto library based on the code \
used in GnuPG."
HOMEPAGE="https://gnupg.org/related_software/libgcrypt/"
COPYRIGHT="2000-2018 Free Software Foundation, Inc."
LICENSE="GNU LGPL v3"
REVISION="1"
SOURCE_URI="https://gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-$portVersion.tar.bz2"
CHECKSUM_SHA256="3b4a2a94cb637eff5bdebbcaf46f4d95c4f25206f459809339cdada0eb577ac3"
PATCHES="libgcrypt-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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

PROVIDES="
	libgcrypt$secondaryArchSuffix = $portVersion
	lib:libgcrypt$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgpg_error$secondaryArchSuffix
	"

PROVIDES_devel="
	libgcrypt${secondaryArchSuffix}_devel = $portVersion
	cmd:dumpsexp$secondaryArchSuffix = $portVersion
	cmd:hmac256$secondaryArchSuffix = $portVersion
	cmd:libgcrypt_config$secondaryArchSuffix = $portVersion
	cmd:mpicalc$secondaryArchSuffix = $portVersion
	devel:libgcrypt$secondaryArchSuffix = $libVersion
	"
REQUIRES_devel="
	haiku$secondaryArchSuffix
	libgcrypt$secondaryArchSuffix == $portVersion base
	devel:libgpg_error$secondaryArchSuffix
	lib:libgpg_error$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgpg_error$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage libgcrypt$secondaryArchSuffix \
	$libDir/libgcrypt.so.$libVersion

BUILD()
{
	runConfigure ./configure \
		--disable-jent-support \

	make $jobArgs
}

INSTALL()
{
	make install

	#remove libtool file
	rm -f $libDir/*.la

	prepareInstalledDevelLib libgcrypt
	fixPkgconfig

	if [ -z "$secondaryArchSuffix" ]; then
		maybe_infoDir=$infoDir
		maybe_manDir=$manDir
	else
		maybe_infoDir=
		maybe_manDir=
		rm -rf $documentationDir
	fi

	packageEntries devel \
		$developDir \
		$binDir \
		$dataDir \
		$maybe_infoDir \
		$maybe_manDir
}

TEST()
{
	LIBRARY_PATH="$sourceDir/src/.libs${LIBRARY_PATH:+:$LIBRARY_PATH}" \
	make check
}
