SUMMARY="3D OpenGL Billiard Game"
DESCRIPTION="FooBillard supports several kinds of billiard games: \
carom billiards (three-cushion billiards), snooker, and pool billiard \
(pocket billiards) in the eight-ball and nine-ball variant.

FooBillard has a realistic physics engine and a computer opponent AI. \
It features an optional red/green 3D stereo view (requires anaglyph 3D \
glasses), a free view mode and an animated cue."
HOMEPAGE="https://foobillardplus.sourceforge.net/"
COPYRIGHT="Florian Berger"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="https://github.com/threedeyes/FooBillardPlus/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="e7ccb5f100e82f139ee80edd4c3093a0b879727e67675383e4ef5d0c5bb38a0e"
SOURCE_DIR="FooBillardPlus-$portVersion"
ADDITIONAL_FILES="foobillardplus.rdef.in"

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

PROVIDES="
	foobillardplus$secondaryArchSuffix = $portVersion
	app:FooBillard++$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libSDL2_image_2.0${secondaryArchSuffix}
	lib:libSDL2_mixer_2.0${secondaryArchSuffix}
#	lib:libSDL2_net_2.0${secondaryArchSuffix}
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfreetype$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL2$secondaryArchSuffix
	devel:libSDL2_image$secondaryArchSuffix
	devel:libSDL2_mixer$secondaryArchSuffix
#	devel:libSDL2_net$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:autoheader
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	aclocal --force
	autoconf -f
	autoheader -f
	automake -a -c -f

#	LIBS="-lnetwork" \
	./configure \
		--disable-fastmath \
		--enable-nvidia=no \
		--enable-network=no \
		--enable-sdl2 \
		--without-x
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/FooBillard++

	cp src/foobillardplus $appsDir/FooBillard++/FooBillard++
	cp -rf data $appsDir/FooBillard++

	local APP_SIGNATURE="application/x-vnd.foobillardplus"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	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/foobillardplus.rdef.in > $sourceDir/foobillardplus.rdef

	addResourcesToBinaries  $sourceDir/foobillardplus.rdef $appsDir/FooBillard++/FooBillard++
	addAppDeskbarSymlink $appsDir/FooBillard++/FooBillard++
}
