SUMMARY="An interface library for image editors"
DESCRIPTION="SageBrush is an interface library for image editors. It provides \
a kit to build image editors easily without starting from scratch."
HOMEPAGE="https://github.com/HaikuArchives/SageBrush"
COPYRIGHT="2012 Vladislav Burundukov"
LICENSE="MIT"
REVISION="1"
srcGitRev="d9b3945cb78c7070aa8b48d2e0bc6a2007fa3601"
SOURCE_URI="https://github.com/HaikuArchives/SageBrush/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="d152e0d572a8eb0b8fc39a531cc1466827a9b96526bc5669dd181ef77ed32940"
SOURCE_FILENAME="SageBrush-$portVersion-$srcGitRev.tar.gz"
SOURCE_DIR="SageBrush-$srcGitRev"

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

PROVIDES="
	sagebrush$secondaryArchSuffix = $portVersion
	lib:libsagebrush$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	sagebrush${secondaryArchSuffix}_devel
	devel:libsagebrush$secondaryArchSuffix
	"
REQUIRES_devel="
	sagebrush$secondaryArchSuffix == $portVersion base
	"

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

BUILD()
{
	gcc -fPIC -shared -o libsagebrush.so -Isupport -Iinterface \
		support/*.cpp interface/*.cpp
}

INSTALL()
{
	install -d $libDir $includeDir/sagebrush
	install -t $libDir libsagebrush.so
	install -t $includeDir/sagebrush support/*.h interface/*.h

	prepareInstalledDevelLib libsagebrush
	packageEntries devel $developDir
}

TEST()
{
	export LIBRARY_PATH="$sourceDir${LIBRARY_PATH:+:$LIBRARY_PATH}"
	gcc "tools/Property Editor"/*.cpp -Iinterface -Isupport -L$sourceDir -lbe -lsagebrush
	./PropertyWindow
	rm -rf test/TitledListItem	   #Cannot be build: missing header
	cd test
	for dir in *; do
		if [ -d $dir ]; then
			cd $dir
			gcc main.cpp -I.. -I${sourceDir}/support -I${sourceDir}/interface \
				-lbe -ltranslation -L${sourceDir} -lsagebrush
			./main
			cd ..
		fi
	done
}
