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="89f05a423dd66a25e5b38308097e2386e640d1cf835160d19a5c75350071d94c"
PATCHES="libgcrypt-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

libVersion=20.1.10
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
portVersionCompat="$portVersion compat >= 1.6"

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

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

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

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

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

INSTALL()
{
	make install

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

	prepareInstalledDevelLib libgcrypt

	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()
{
	make check
}
