SUMMARY="A cross-platform media development library"
DESCRIPTION="Simple Direct Media Layer (SDL) is a cross-platform development library \
designed to provide low level access to audio, keyboard, mouse, joystick, and \
graphics via OpenGL."
HOMEPAGE="http://www.libsdl.org/"
LICENSE="GNU LGPL v2.1"
REVISION="8"

ARCHITECTURES="x86_gcc2 x86 x86_64"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

SOURCE_URI="http://www.libsdl.org/release/SDL-1.2.15.tar.gz"
CHECKSUM_SHA256="d6d316a793e5e348155f0dd93b979798933fb98aa1edebcc108829d6474aad00"
COPYRIGHT="1997-2012 Sam Lantinga"
SOURCE_DIR="SDL-$portVersion"
PATCHES="libsdl-1.2.15.patchset"

PROVIDES="
	libsdl$secondaryArchSuffix = $portVersion
	lib:libSDL$secondaryArchSuffix = 1.2_0.11.4 compat >= 1.2_0
	lib:libSDL_1.2$secondaryArchSuffix = 0.11.4 compat >= 0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	REQUIRES+="
		lib:libgcc_s$secondaryArchSuffix
	"
fi

PROVIDES_devel="
	libsdl${secondaryArchSuffix}_devel = 1.2.15 compat >= 1.2
	cmd:sdl_config$secondaryArchSuffix = $portVersion compat >= 1.2
	devel:libSDL$secondaryArchSuffix = 1.2_0.11.4 compat >= 1.2_0
	devel:libSDLmain$secondaryArchSuffix = 1.2_0.11.4 compat >= 1.2_0
	devel:libSDL_1.2$secondaryArchSuffix = 0.11.4 compat >= 0
	"
REQUIRES_devel="
	libsdl${secondaryArchSuffix} == $portVersion base
	devel:libGL$secondaryArchSuffix
	"
BUILD_REQUIRES="
	devel:libGL$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:autoconf
	cmd:libtool
	cmd:aclocal
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:nasm
	"

BUILD()
{
	libtoolize --force --copy --install
	aclocal -I acinclude
	autoconf
	runConfigure ./configure --includedir=$includeDir
	make $jobArgs
}

INSTALL()
{
	make install

	# devel package
	prepareInstalledDevelLibs \
		libSDL libSDL-1.2 \
		libSDLmain
	
	fixPkgconfig
	fixDevelopLibDirReferences $binDir/sdl-config
	
	packageEntries devel \
		$developDir $binDir/sdl-config \
		$dataDir \
		$documentationDir
}

TEST()
{
	cd test
	runConfigure ./configure
	make $jobArgs
	echo testvidoinfo
	testvidinfo
	echo testgl
	testgl
	echo testwm
	testwm
	echo testhread
	testhread
	echo testsprite
	testsprite
	echo testdyngl
	testdyngl
	echo testoverlay
	testoverlay
	echo testoverlay2
	testoverlay2
	echo threadwin
	threadwin
	echo testalpha
	testalpha
	echo testiconv
	testiconv
	echo testtimer
	testtimer
	echo graywin
	graywin
	echo testerror
	testerror
	echo torturethread
	torturethread
	echo testbitmap
	testbitmap
	echo testjoystick
	testjoystick
	echo testver
	testver
	echo testfile
	testfile
	echo testpalette
	testpalette
	echo loopwave
	loopwave
	echo testblitspeed
	testblitspeed
	echo testkeys
	testkeys
	echo testcursor
	testcursor
	echo checkkeys
	checkkeys
	echo testgamma
	testgamma
	echo testplatform
	testplatform
	echo testcdrom
	testcdrom
	echo testloadso
	testloadso
	echo testwim
	testwin
	echo testsem
	testsem
	echo testlock
	testlock
}
