SUMMARY="A free source code editing component"
DESCRIPTION="Scintilla is a free source code editing component. It comes with \
complete source code and a license that permits use in any free project or \
commercial product.
As well as features found in standard text editing components, \
Scintilla includes features especially useful when editing and debugging \
source code. These include support for syntax styling, error indicators, code \
completion and call tips. The selection margin can contain markers like those \
used in debuggers to indicate breakpoints and the current line. Styling \
choices are more open than with many editors, allowing the use of \
proportional fonts, bold and italics, multiple foreground and background \
colours and multiple fonts."
HOMEPAGE="https://scintilla.org"
COPYRIGHT="1998-2020 Neil Hodgson"
LICENSE="Scintilla"
REVISION="1"
SOURCE_URI="https://prdownloads.sf.net/scintilla/scintilla${portVersion//\./}.tgz"
CHECKSUM_SHA256="3061386bbb66a4829c7563aa987fb0bca25758a20794f617d5cb64d400d51a35"
SOURCE_DIR="scintilla"
SOURCE_URI_2="https://prdownloads.sf.net/scintilla/scintillahaiku${portVersion//\./}.tgz"
CHECKSUM_SHA256_2="2dfe0fae8a168ed1a88c780159eb65f7b1d1e1fa5f6a82544b2a6eb0cb405dab"
srcGitRev3="0018aab724122168b4818c8ead2882f83fbc6848"
SOURCE_URI_3="https://github.com/KapiX/scintilla-haiku-lexers/archive/$srcGitRev3.tar.gz"
CHECKSUM_SHA256_3="901cb864942c329a6ba98ecdb24c80bbbbfc1ec4e29060f2a963ba31de6d0861"
SOURCE_DIR_3="scintilla-haiku-lexers-$srcGitRev3"

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

PROVIDES="
	scintilla$secondaryArchSuffix = $portVersion
	lib:libscintilla$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	scintilla${secondaryArchSuffix}_devel = $portVersion
	devel:libscintilla$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	scintilla$secondaryArchSuffix == $portVersion base
	"

PROVIDES_lexers="
	scintilla${secondaryArchSuffix}_lexers = $portVersion
	"
REQUIRES_lexers="
	scintilla$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	makefile_engine
	cmd:ar
	cmd:g++$secondaryArchSuffix
	cmd:make
	"

PATCH()
{
	sed -i -e 's#SymbolValue() noexcept = #SymbolValue() = #' \
		$sourceDir/lexers/LexCPP.cxx
}

BUILD()
{
	mkdir -p haiku
	cp -R $sourceDir2/haiku/ .
	cd haiku
	make $jobArgs

	cd $sourceDir3
	cp -R $sourceDir/lexlib/ .
	make all OBJ_DIR=objects SYSTEM_INCLUDE_PATHS=$sourceDir/include
	rm -rf objects/*.d objects/*.o

	cd $sourceDir/lexilla/src
	make $jobArgs
}

INSTALL()
{
	INCLUDE_DIR=$includeDir/scintilla
	LEXERS_DIR=$dataDir/scintilla/lexers

	mkdir -p $libDir
	mkdir -p $INCLUDE_DIR
	mkdir -p $LEXERS_DIR

	cp -a bin/libscintilla.so $libDir/libscintilla.so
	cp -a bin/lexilla.so $libDir/lexilla.so
	cp include/ILoader.h $INCLUDE_DIR
	cp include/*Lexer.h $INCLUDE_DIR
	cp include/Sci_Position.h $INCLUDE_DIR
	cp include/Scintilla.h $INCLUDE_DIR
	cp haiku/ScintillaView.h $INCLUDE_DIR

	cp $sourceDir3/objects/Lex* $LEXERS_DIR

	prepareInstalledDevelLibs libscintilla lexilla
	packageEntries devel $developDir
	packageEntries lexers $LEXERS_DIR
}
