SUMMARY="A library for creating GUIs for games"
DESCRIPTION="MyGUI is a library for creating Graphical User Interfaces (GUIs) for \
games and 3D applications. The main goals of mygui are: speed, flexibility and easy \
of use. Speed We speed up our system by using our own batching subsystem which \
combines geometry. It is also possible for the more experienced developers to \
write their own render system or new subsystems Flexibility The library supports \
plugins that allows you to create dynamically loaded custom controls or subsystems. \
Most subsystems are expandable with plugins without the need to touch the core code. \
All resources and settings are described in XML files. It is possible to load \
resources like fonts, cursors, images, skins, etc. Forms (layouts) via dynamically \
by using XML files. Simplicity The user interface is easy to use and uses delegates \
(Signals and slots) for easy to use event handling."
HOMEPAGE="http://mygui.info/"
COPYRIGHT="Albert Semenov
	George Evmenov"
LICENSE="MIT"
REVISION="1"
srcGitRev="a021cc7e70b143c46688fcf29a0379571203beb4"
SOURCE_URI="https://github.com/MyGUI/mygui/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="4dfc6b696c834c0da1cf6d1f84b3e36c96e2873c69312ba4a2ada50e9cc6caa0"
SOURCE_FILENAME="MyGUI-$srcGitRev.tar.gz"
SOURCE_DIR="mygui-$srcGitRev"
PATCHES="mygui-$portVersion.patchset"
ADDITIONAL_FILES="
	skin_editor.rdef.in
	layout_editor.rdef.in
	image_editor.rdef.in
	font_editor.rdef.in
	"

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

PROVIDES="
	mygui$secondaryArchSuffix = $portVersion compat >= 3
	lib:libMyGUIEngine$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0$secondaryArchSuffix
	"

PROVIDES_devel="
	mygui${secondaryArchSuffix}_devel = $portVersion
	devel:libmygui.openglplatform$secondaryArchSuffix = $portVersion
	devel:libmyguiengine$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	mygui$secondaryArchSuffix == $portVersion base
	haiku$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfreetype$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libglew$secondaryArchSuffix
	devel:libGLU$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libSDL2_image_2.0$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build && cd build
	cmake .. \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DMYGUI_RENDERSYSTEM=4 \
		-DMYGUI_SAMPLES_INPUT=4 \
		-DMYGUI_BUILD_TOOLS=TRUE \
		-DMYGUI_BUILD_DEMOS=FALSE \
		-DMYGUI_DISABLE_PLUGINS=FALSE \
		-DMYGUI_INSTALL_TOOLS=TRUE \
		-DMYGUI_INSTALL_MEDIA=TRUE \
		-DMYGUI_USE_SYSTEM_GLEW=TRUE
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mkdir -p $includeDir
	mv $prefix/include/MYGUI $includeDir

	rm -rf $prefix/{include,lib}

	mkdir -p $libDir $developLibDir

	cp lib/libMyGUI.OpenGLPlatform.a $developLibDir
	cp lib/libMyGUIEngine.* $libDir
	cp -r pkgconfig $libDir

	mkdir -p $appsDir/MyGUI/lib
	cp lib/libEditorFramework.so $appsDir/MyGUI/lib
	cp bin/Plugin_StrangeButton.so $appsDir/MyGUI/lib
	cp bin/*Editor $appsDir/MyGUI
	cp bin/resources.xml $appsDir/MyGUI
	rm -rf $prefix/bin

	fixPkgconfig

	sed -i "s|libdir=.*|libdir=$developLibDir|" $developLibDir/pkgconfig/MYGUI.pc
	sed -i "s|includedir=.*|includedir=$includeDir|" $developLibDir/pkgconfig/MYGUI.pc

	mkdir -p ${dataDir}/deskbar/menu/Applications/MyGUI

	local APP_SIGNATURE="application/x-vnd.mygui-font-editor"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3 | cut -d~ -f1`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/font_editor.rdef.in > $sourceDir/build/font_editor.rdef
	addResourcesToBinaries  $sourceDir/build/font_editor.rdef $appsDir/MyGUI/FontEditor
	addAppDeskbarSymlink $appsDir/MyGUI/FontEditor "MyGUI/Font Editor"

	local APP_SIGNATURE="application/x-vnd.mygui-image-editor"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/image_editor.rdef.in > $sourceDir/build/image_editor.rdef
	addResourcesToBinaries  $sourceDir/build/image_editor.rdef $appsDir/MyGUI/ImageEditor
	addAppDeskbarSymlink $appsDir/MyGUI/ImageEditor "MyGUI/Image Editor"

	local APP_SIGNATURE="application/x-vnd.mygui-layout-editor"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/layout_editor.rdef.in > $sourceDir/build/layout_editor.rdef
	addResourcesToBinaries  $sourceDir/build/layout_editor.rdef $appsDir/MyGUI/LayoutEditor
	addAppDeskbarSymlink $appsDir/MyGUI/LayoutEditor "MyGUI/Layout Editor"

	local APP_SIGNATURE="application/x-vnd.mygui-skin-editor"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/skin_editor.rdef.in > $sourceDir/build/skin_editor.rdef
	addResourcesToBinaries  $sourceDir/build/skin_editor.rdef $appsDir/MyGUI/SkinEditor
	addAppDeskbarSymlink $appsDir/MyGUI/SkinEditor "MyGUI/Skin Editor"

	prepareInstalledDevelLib libMyGUIEngine

	packageEntries devel \
		$appsDir \
		$dataDir \
		$developDir
}
