SUMMARY="A framework to make 2D games in Lua"
DESCRIPTION="LÖVE is a framework to make 2D games in Lua.
It's free, open-source, and works also on Windows, Mac OS X and Linux."
HOMEPAGE="http://love2d.org/"
COPYRIGHT="2010-2018 Löve"
LICENSE="Zlib"
REVISION="3"
SOURCE_URI="https://bitbucket.org/rude/love/downloads/love-$portVersion-linux-src.tar.gz"
CHECKSUM_SHA256="6aaf8104fc35bb8bbd7865986b98079e7564ffdb374ea4d33604b46b458444f6"
PATCHES="love-$portVersion.patchset"
ADDITIONAL_FILES="love.rdef.in"

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

PROVIDES="
	love$secondaryArchSuffix = $portVersion
	cmd:love$secondaryArchSuffix = $portVersion
	lib:liblove_11.2$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libIL$secondaryArchSuffix
	lib:libjasper$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libluajit_5.1$secondaryArchSuffix
	lib:libmng$secondaryArchSuffix
	lib:libmodplug$secondaryArchSuffix
	lib:libmpg123$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libopenal$secondaryArchSuffix
	lib:libphysfs$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libtheora$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	lib:libvorbisfile$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	love${secondaryArchSuffix}_devel = $portVersion
	devel:liblove$secondaryArchSuffix = $portVersion
	devel:liblove_11.2$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	love$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libIL$secondaryArchSuffix
	devel:libjasper$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libluajit_5.1$secondaryArchSuffix
	devel:libmng$secondaryArchSuffix
	devel:libmodplug$secondaryArchSuffix
	devel:libmpg123$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
	devel:libopenal$secondaryArchSuffix
	devel:libphysfs$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libtheora$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	devel:libvorbisfile$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:awk
	cmd:cmp
	cmd:dd
	cmd:diff
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	autoreconf -fi
	runConfigure ./configure

	make $jobArgs
}

INSTALL()
{
	make install

	# remove libtool file *.la
	rm -f $libDir/*.la

	# remove not relevant files
	rm -rf $dataDir/{applications,icons,pixmaps}

	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="0"
	sed \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/love.rdef.in > love.rdef

	addResourcesToBinaries love.rdef $binDir/love

	prepareInstalledDevelLibs liblove-11.2 liblove

	packageEntries devel \
		$developDir
}

TEST()
{
	make test
}
