SUMMARY="Compiles executable finite state machines from regular languages"
DESCRIPTION="Ragel compiles executable finite state machines from regular \
languages. Ragel targets C, C++, Objective-C, C#, D, Java, Ruby, OCaml and Go.
Ragel state machines can not only recognize byte sequences as regular \
expression machines do, but can also execute code at arbitrary points in the \
recognition of a regular language.
Code embedding is done using inline operators that do not disrupt the regular \
language syntax."
HOMEPAGE="https://www.colm.net/open-source/ragel/"
COPYRIGHT="2001-2016 Adrian Thurston
	2007 Victor Hugo Borja
	2011 Josef Goettgens"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://www.colm.net/files/ragel/ragel-$portVersion.tar.gz"
CHECKSUM_SHA256="40562bcac66a22dbea8357a35745bbcb1ab596c262d8691145ee11aafa6f8dec"

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

commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
fi

binVersionCompat="$portVersion compat >= ${portVersion%.*.*}"
libVersion="0.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	ragel$secondaryArchSuffix = $portVersion
	cmd:ragel$secondaryArchSuffix = $binVersionCompat
	lib:libfsm$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	colm$secondaryArchSuffix
	"

PROVIDES_devel="
	ragel${secondaryArchSuffix}_devel = $portVersion
	devel:libfsm$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	ragel$secondaryArchSuffix == $portVersion base
	haiku${secondaryArchSuffix}_devel
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcolm$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:asciidoc
	cmd:autoreconf
	cmd:awk
	cmd:colm$commandSuffix
	cmd:grep
	cmd:g++$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:sed
	"

defineDebugInfoPackage ragel$secondaryArchSuffix \
	"$binDir"/ragel \
	$libDir/libfsm.so.$libVersion

BUILD()
{
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libfsm.la

	prepareInstalledDevelLib libfsm
	fixPkgconfig

	packageEntries devel $developDir
}

TEST()
{
	make check
}
