SUMMARY="The GNU Readline library"
DESCRIPTION="The GNU Readline library provides a set of functions for use by \
applications that allow users to edit command lines as they are typed in. \
Both Emacs and vi editing modes are available. The Readline library includes \
additional functions to maintain a list of previously-entered command lines, \
to recall and perhaps reedit those lines, and perform csh-like history \
expansion on previous commands.
The history facilities are also placed into a separate library, the History \
library, as part of the build process. The History library may be used without \
Readline in applications which desire its capabilities."
HOMEPAGE="http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html"
COPYRIGHT="1989-2011 Free Software Foundation, Inc."
LICENSE="GNU GPL v3"
REVISION="3"
SOURCE_URI="ftp://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz"
CHECKSUM_SHA256="56ba6071b9462f980c5a72ab0023893b65ba6debb4eeb475d7a563dc65cafd43"
SOURCE_DIR="readline-6.3"
for i in {001..008}; do
	eval "SOURCE_URI_$i=\"https://ftp.gnu.org/gnu/readline/readline-6.3-patches/readline63-$i#noarchive\""
done
CHECKSUM_SHA256_001="1a79bbb6eaee750e0d6f7f3d059b30a45fc54e8e388a8e05e9c3ae598590146f"
CHECKSUM_SHA256_002="39e304c7a526888f9e112e733848215736fb7b9d540729b9e31f3347b7a1e0a5"
CHECKSUM_SHA256_003="ec41bdd8b00fd884e847708513df41d51b1243cecb680189e31b7173d01ca52f"
CHECKSUM_SHA256_004="4547b906fb2570866c21887807de5dee19838a60a1afb66385b272155e4355cc"
CHECKSUM_SHA256_005="877788f9228d1a9907a4bcfe3d6dd0439c08d728949458b41208d9bf9060274b"
CHECKSUM_SHA256_006="5c237ab3c6c97c23cf52b2a118adc265b7fb411b57c93a5f7c221d50fafbe556"
CHECKSUM_SHA256_007="4d79b5a2adec3c2e8114cbd3d63c1771f7c6cf64035368624903d257014f5bea"
CHECKSUM_SHA256_008="3bc093cf526ceac23eb80256b0ec87fa1735540d659742107b6284d635c43787"
PATCHES="readline-6.3.patch"

ARCHITECTURES="?all x86"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	readline6$secondaryArchSuffix = $portVersion compat >= 6
	lib:libhistory$secondaryArchSuffix = $portVersion compat >= 6
	lib:libreadline$secondaryArchSuffix = $portVersion compat >= 6
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	"

PROVIDES_devel="
	readline6${secondaryArchSuffix}_devel = $portVersion
	devel:libhistory$secondaryArchSuffix = $portVersion compat >= 6
	devel:libreadline$secondaryArchSuffix = $portVersion compat >= 6
	"
REQUIRES_devel="
	readline6$secondaryArchSuffix == $portVersion base
	"
CONFLICTS_devel="
	readline${secondaryArchSuffix}_devel
	"

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

defineDebugInfoPackage readline6$secondaryArchSuffix \
	$libDir/libhistory.so.6.3 \
	$libDir/libreadline.so.6.3

PATCH()
{
	for i in {001..008}; do
		echo "Applying patch $i..."
		sed -e "s/\.\.\/readline-6.3\///" ../../sources-$i/readline63-$i \
			| patch -p0
	done
}

BUILD()
{
	libtoolize --force --copy --install
	aclocal
	autoconf
	runConfigure ./configure \
		--with-curses
	make $jobArgs SHLIB_LIBS=-lncurses
}

INSTALL()
{
	make install

	prepareInstalledDevelLibs libhistory libreadline
	rmdir $binDir

	# devel package
	packageEntries devel \
		$dataDir \
		$developDir \
		$documentationDir
}
