SUMMARY="A library to help create robust multi-platform software"
DESCRIPTION="S-Lang is a multi-platform library designed to allow a developer \
to create robust multi-platform software. It provides facilities required by \
interactive applications such as display/screen management, keyboard input, \
keymaps, and so on.
The most exciting feature of the library is the slang interpreter that may \
be easily embedded into a program to make it extensible.

While the emphasis has always been on the embedded nature of the interpreter, \
it may also be used in a stand-alone fashion through the use of slsh, which is \
part of the S-Lang distribution."
HOMEPAGE="http://www.jedsoft.org/slang/"
COPYRIGHT="2004-2016 John E. Davis"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="http://www.jedsoft.org/releases/slang/slang-$portVersion.tar.bz2"
CHECKSUM_SHA256="fc9e3b0fc4f67c3c1f6d43c90c16a5c42d117b8e28457c5b46831b8b5d3ae31a"
PATCHES="slang-${portVersion}.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

GLOBAL_WRITABLE_FILES="
        settings/slsh.rc keep-old
	"

PROVIDES="
	slang$secondaryArchSuffix = $portVersion compat >= 2.3
	cmd:slsh$secondaryArchSuffix = $portVersion compat >= 2.3
	lib:libslang$secondaryArchSuffix = $portVersion compat >= 2.3
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	slang${secondaryArchSuffix}_devel = $portVersion compat >= 2.3
	devel:libslang$secondaryArchSuffix = $portVersion compat >= 2.3
	"
REQUIRES_devel="
	slang$secondaryArchSuffix == $portVersion
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libpcre$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	# RUSAGE makes just problems...
	# HACK, FIXME!
	sed -i "s,HAVE_GETRUSAGE,DOESNT_HAVE_GETRUSAGE," src/config.hin

	export LDFLAGS="-lnetwork -lbsd"

	runConfigure ./configure \
	--with-pnglib=$libDir \
	--with-pnginc=$includeDir \
	--with-zlib=$libDir \
	--with-zinc=$includeDir \
	--with-iconvlib=$libDir \
	--with-iconvinc=$includeDir \
	--with-pcrelib=$libDir \
	--with-pcreinc=$includeDir
	#--with-oniglib=$libDir \
	#--with-oniginc=$includeDir

	make
}

INSTALL()
{
	make install

	fixPkgconfig

	prepareInstalledDevelLibs libslang

	packageEntries devel $developDir
}
