SUMMARY="A set of database routines"
DESCRIPTION="GNU dbm is a set of database routines that use extendible \
hashing andworks similar to the standard UNIX dbm routines. The library \
provides also an optional compatibility layer for UNIX-like \
dbm and ndbm calls."
HOMEPAGE="https://www.gnu.org.ua/software/gdbm/"
COPYRIGHT="2011, 2016-2017 Free Software Foundation, Inc."
LICENSE="GNU GPL v3"
REVISION="4"
SOURCE_URI="ftp://ftp.gnu.org/gnu/gdbm/gdbm-$portVersion.tar.gz"
CHECKSUM_SHA256="9d252cbd7d793f7b12bcceaddda98d257c14f4d1890d851c386c37207000a253"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86"

libVersion="4.0.0"
libVersionCompat="$libVersion compat >= 4"

PROVIDES="
	gdbm$secondaryArchSuffix = $portVersion
	cmd:gdbm_dump$secondaryArchSuffix
	cmd:gdbm_load$secondaryArchSuffix
	cmd:gdbmtool$secondaryArchSuffix
	lib:libgdbm$secondaryArchSuffix = $libVersionCompat
	lib:libgdbm_compat$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	"

PROVIDES_devel="
	gdbm${secondaryArchSuffix}_devel = $portVersion
	devel:libgdbm$secondaryArchSuffix = $libVersion
	devel:libgdbm_compat$secondaryArchSuffix = $libVersion
	"
REQUIRES_devel="
	gdbm$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix >= 8
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage gdbm$secondaryArchSuffix  \
	$binDir/gdbm_dump \
	$binDir/gdbm_load \
	$binDir/gdbmtool \
	$libDir/libgdbm.so.$libVersion \
	$libDir/libgdbm_compat.so.$libVersion

BUILD()
{
	autoreconf -vfi
	runConfigure ./configure --enable-libgdbm-compat
	make $jobArgs
}

INSTALL()
{
	make install

	#remove libtool files
	rm -r $libDir/*.la

	# prepare develop/lib
	prepareInstalledDevelLibs libgdbm libgdbm_compat

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

	# devel package
	packageEntries devel \
		$developDir \
		$maybe_manDir

	rm -r $documentationDir
}

TEST()
{
	make check
}
