SUMMARY="Crazy Eddie's GUI System"
DESCRIPTION="This is Crazy Eddie's GUI System Mk-2; a free library providing \
windowing and widgets for graphics APIs and engines where such functionality \
is not natively available or is severely lacking. The library is written in \
C++, is object orientated, and is primarily targeted at games developers who \
should be spending their time creating great games, not building GUI \
sub-systems..."
HOMEPAGE="http://www.cegui.org.uk/"
COPYRIGHT="2004-2015 Paul D. Turner and The CEGUI Development Team"
LICENSE="GNU LGPL v2.1"
REVISION="2"
SOURCE_URI="http://prdownloads.sourceforge.net/crayzedsgui/cegui-$portVersion.tar.bz2"
CHECKSUM_SHA256="b351e8957716d9c170612c13559e49530ef911ae4bac2feeb2dacd70b430e518"

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

libVersion="2.4.2"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	cegui$secondaryArchSuffix = $portVersion
#	since samples are disabled the cmd won't be installed either
#	cmd:ceguisampleframework_0.8 = $portVersion
	lib:libCEGUIBase_0$secondaryArchSuffix = libVersionCompat
	lib:libCEGUICommonDialogs_0$secondaryArchSuffix = $libVersionCompat
	lib:libCEGUIIrrlichtRenderer_0$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libepoxy$secondaryArchSuffix
	lib:libexpat$secondaryArchSuffix
	lib:libfreeimage$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libfribidi$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libil$secondaryArchSuffix
	lib:libIrrlicht$secondaryArchSuffix
	lib:liblua$secondaryArchSuffix
	lib:libminizip$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffix
	lib:libpython3.7m$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0$secondaryArchSuffix
	lib:libtinyxml$secondaryArchSuffix
#	lib:libtoluapp$secondaryArchSuffix
#	lib:libxerces_c_3.2$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	cegui${secondaryArchSuffix}_devel = $portVersion
	devel:libCEGUIBase_0$secondaryArchSuffix = $libVersionCompat
	devel:libCEGUICommonDialogs_0$secondaryArchSuffix = $libVersionCompat
	devel:libCEGUIIrrlichtRenderer_0$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	cegui${secondaryArchSuffix}_devel == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:lua5.3$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libepoxy$secondaryArchSuffix
	devel:libexpat$secondaryArchSuffix
	devel:libfreeimage$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libfribidi$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libglew$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libil$secondaryArchSuffix
	devel:libIrrlicht$secondaryArchSuffix
	devel:liblua$secondaryArchSuffix
	devel:libminizip$secondaryArchSuffix
	devel:libpcre$secondaryArchSuffix
	devel:libpython3.7m$secondaryArchSuffix
	devel:libSDL2$secondaryArchSuffix
	devel:libSDL2_image$secondaryArchSuffix
	devel:libtinyxml$secondaryArchSuffix
#	devel:libxerces_c_3.2$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake .. \
		-DCMAKE_INSTALL_PREFIX:PATH=$prefix \
		-DSDL2_H_PATH="$portPackageLinksDir/devel~libsdl2_2.0/$relativeIncludeDir/SDL2" \
		-DSDL2IMAGE_H_PATH="$portPackageLinksDir/devel~libsdl2_2.0/$relativeIncludeDir/SDL2" \
		-DCEGUI_SAMPLES_ENABLED:BOOL=OFF
	make $jobArgs
}

INSTALL()
{
	cd build
	make install
	mkdir -p $includeDir $dataDir
	mv $prefix/include/* $includeDir
	rmdir $prefix/include
	mv $prefix/share/* $dataDir
	rmdir $prefix/share

	if [ -n "$secondaryArchSuffix" ]; then
		mv $prefix/lib $prefix/lib2
		mkdir -p $libDir
		mv $prefix/lib2/* $libDir/
		rmdir $prefix/lib2
	fi

	prepareInstalledDevelLibs \
		libCEGUIBase-0 libCEGUICommonDialogs-0 	libCEGUIIrrlichtRenderer-0
	fixPkgconfig

	packageEntries devel \
		$developDir

}
