SUMMARY="The Lemon LALR(1) Parser Generator"
DESCRIPTION="The SQL language parser for SQLite is generated using a \
code-generator program called \"Lemon\". The Lemon program reads a grammar \
of the input language and emits C-code to implement a parser for that language."
HOMEPAGE="https://www.sqlite.org/lemon.html"
COPYRIGHT="Public Domain"
LICENSE="SQLite"
REVISION="1"
SOURCE_URI="https://sqlite.org/src/raw/tool/lemon.c?name=33892e2a243865f73e6c6e7cecce3c6eb4bb95db4a3d9d86d146c8064feb92fd#noarchive"
SOURCE_FILENAME="lemon.c"
CHECKSUM_SHA256="573ef688d5a18fc0cfff2a3d6efcfc693e4d059328da631dabbfcdfa742ba6ee"
SOURCE_URI_2="https://sqlite.org/src/doc/trunk/doc/lemon.html#noarchive"
SOURCE_FILENAME_2="lemon.html"
CHECKSUM_SHA256_2="91fdc5a8178c401d6ebf358c661609fbce0c5617e0edb19af4e4f47c29f9ef29"
SOURCE_URI_3="https://sqlite.org/src/raw/tool/lempar.c?name=bf7db78e7213f1d51516710483eab506fd52bf632c7abfb3e2e9b885c90c03e1#noarchive"
SOURCE_FILENAME_3="lempar.c"
CHECKSUM_SHA256_3="16cffecd770fe7c1f5bc576f45471181d5e28f92134d451300c6e2b8356633ad"

SOURCE_DIR=""
SOURCE_DIR_2=""
SOURCE_DIR_3=""

ARCHITECTURES="all !x86_gcc2"
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
fi

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandBinDir=$prefix/bin
fi

PROVIDES="
	lemon$secondaryArchSuffix = $portVersion
	cmd:lemon = 1.0 compat >= 1
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	gcc$secondaryArchSuffix
	"

BUILD()
{
	cp -f $sourceDir2/lemon.html $sourceDir
	#not sure where this template should be installed (lempar.c)
	cp -f $sourceDir3/lempar.c $sourceDir
	gcc lemon.c -o lemon
}

INSTALL()
{
	install -d -m 755 "$prefix/bin" "$prefix/documentation/packages/lemon"
	install -m 755 -t "$prefix/bin" lemon
	install -m 644 -t "$prefix/documentation/packages/lemon" lemon.html
}
