SUMMARY="Message Digest functions from BSD systems"
DESCRIPTION="This library provides message digest functions found on BSD \
systems either on their libc libraries and lacking on others like GNU systems.

The currently provided message digest algorithms are:
- MD2
- MD4
- MD5
- RIPEMD-160
- SHA-1
- SHA-2 (SHA-256, SHA-384 and SHA-512)"
HOMEPAGE="https://www.hadrons.org/software/libmd/"
COPYRIGHT="2009, 2011, 2018 Guillem Jover
	2000-2001 Aaron D. Gifford
	2001 Markus Friedl
	2001 The NetBSD Foundation
	1997, 2003, 2004 Todd C. Miller
	Poul-Henning Kamp
	Colin Plumb
	Steve Reid"
LICENSE="BSD (3-clause)
	Beerware
	BSD (2-clause)
	BSD (2-clause) NetBSD
	ISC
	Public Domain"
REVISION="2"
SOURCE_URI="https://libbsd.freedesktop.org/releases/libmd-$portVersion.tar.xz"
CHECKSUM_SHA256="e14eeb931cf85330f95ff822262d3033125488dfb2f867441e36e2d2c4a34c71"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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

PROVIDES="
	libmd$secondaryArchSuffix = $portVersion
	lib:libmd$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:awk
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:grep
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:sed
	"

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

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

INSTALL()
{
	make install

	rm -f "$libDir"/libmd.la

	prepareInstalledDevelLib libmd
	fixPkgconfig

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf "$manDir"
		maybe_manDir=
	else
		maybe_manDir=$manDir
	fi

	packageEntries devel \
		"$developDir" \
		${maybe_manDir:+"$maybe_manDir"}
}

TEST()
{
	make check
}
