SUMMARY="A very basic terminfo library"
DESCRIPTION="Unibilium doesn't depend on curses or any other library. It \
also doesn't use global variables, so it should be thread-safe."
HOMEPAGE="https://github.com/mauke/unibilium"
COPYRIGHT="2008-2015 Lukas Mai
	2011-2015 unibilium Developers"
LICENSE="GNU LGPL v3"
REVISION="1"
SOURCE_URI="https://github.com/mauke/unibilium/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="78997d38d4c8177c60d3d0c1aa8c53fd0806eb21825b7b335b1768d7116bc1c1"

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

PROVIDES="
	unibilium$secondaryArchSuffix = $portVersion
	lib:libunibilium$secondaryArchSuffix = 4.0.0 compat >= 4
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	unibilium${secondaryArchSuffix}_devel = $portVersion
	devel:libunibilium$secondaryArchSuffix = 4.0.0 compat >= 4
	"
REQUIRES_devel="
	unibilium$secondaryArchSuffix == $portVersion
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

PATCH()
{
	# Stack Protector fix
	sed -i 's/-fstack-protector-all/-fno-stack-protector/g' maint.mk
	# Sanitize build-fix
	sed -i 's/-fsanitize=address -fsanitize=undefined//g' maint.mk
	# Terminfo folder
	sed -i 's/TERMINFO_DIRS=\"/TERMINFO_DIRS="`finddir B_SYSTEM_DATA_DIRECTORY`\/terminfo\:/g' Makefile
}

BUILD()
{
	make PREFIX=$prefix LIBDIR=$libDir INCDIR=$includeDir MANDIR=$manDir \
		$jobArgs
}

INSTALL()
{
	make install PREFIX=$prefix LIBDIR=$libDir INCDIR=$includeDir \
		MANDIR=$manDir $jobArgs

	rm -rf $libDir/libunibilium.la $libDir/libunibilium.a

	prepareInstalledDevelLib libunibilium
	fixPkgconfig

	packageEntries devel $developDir $manDir
}

TEST()
{
	make test
}
