SUMMARY="A BSD licensed replacement for the GNU readline library"
DESCRIPTION="This is an autotool- and libtoolized port of the NetBSD Editline library \
(libedit). This Berkeley-style licensed command line editor library provides \
generic line editing, history, and tokenization functions, similar to those \
found in GNU Readline."
HOMEPAGE="http://thrysoee.dk/editline/"
COPYRIGHT="1992-2018 The NetBSD Foundation, Inc."
LICENSE="BSD (3-clause)"
REVISION="2"
SOURCE_URI="http://thrysoee.dk/editline/libedit-${portVersion/_/-}.tar.gz"
CHECKSUM_SHA256="c41bea8fd140fb57ba67a98ec1d8ae0b8ffa82f4aba9c35a87e5a9499e653116"
SOURCE_DIR="libedit-${portVersion/_/-}"
PATCHES="libedit-${portVersion/_/-}.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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

PROVIDES="
	libedit$secondaryArchSuffix = $portVersion
	lib:libedit$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libncurses$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoreconf
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:m4
	cmd:make
	cmd:sed
	"

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

BUILD()
{
	autoreconf --force --install
	runConfigure ./configure --enable-examples=no
	make $jobArgs
}

INSTALL()
{
	make install

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

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf "$documentationDir"
		maybe_manDir_man3=
	else
		maybe_manDir_man3="$manDir"/man3
	fi

	prepareInstalledDevelLib libedit
	fixPkgconfig

	# devel package
	packageEntries devel \
		"$developDir" \
		${maybe_manDir_man3:+"$maybe_manDir_man3"}
}

TEST()
{
	make check
}
