SUMMARY="A simple, Unicode-aware word processor that runs on the console"
DESCRIPTION="WordGrinder is designed to get out of your way and let you write; \
it does very little, but what it does it does it well. It supports basic \
paragraph styles, basic character styles, basic screen markup, a menu \
interface that means you don't have to remember complex key sequences, HTML \
import and export, and some other useful features."
HOMEPAGE="http://cowlark.com/wordgrinder/"
COPYRIGHT="2007-2020 David Given"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/davidgiven/wordgrinder/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="856cbed2b4ccd5127f61c4997a30e642d414247970f69932f25b4b5a81b18d3f"

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

commandBinDir=$binDir
commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]
then
	commandBinDir=$prefix/bin
	commandSuffix=
fi

PROVIDES="
	wordgrinder$secondaryArchSuffix = $portVersion
	cmd:wordgrinder$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:liblua$secondaryArchSuffix >= 5.3
	lib:libncurses$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfreetype$secondaryArchSuffix
	devel:liblua$secondaryArchSuffix >= 5.3
	devel:libncurses$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cc$secondaryArchSuffix
	cmd:make
	cmd:ninja
	cmd:pkg_config$secondaryArchSuffix
	cmd:xxd
	"

defineDebugInfoPackage wordgrinder$secondaryArchSuffix \
	$commandBinDir/wordgrinder

BUILD()
{
	make PREFIX=$prefix BINDIR=$commandBinDir DOCDIR=$docDir \
		MANDIR=$manDir HOME="`finddir B_USER_DIRECTORY`" \
		LUA_PACKAGE=lua5.3
}

INSTALL()
{
	make install PREFIX=$prefix BINDIR=$commandBinDir DOCDIR=$docDir \
		MANDIR=$manDir HOME="`finddir B_USER_DIRECTORY`" \
		LUA_PACKAGE=lua5.3
	mv $docDir/wordgrinder/README.wg $docDir
	rmdir $docDir/wordgrinder
	rm -rf $prefix/share
}
