SUMMARY="Simple Direct Media Layer 2.0"
DESCRIPTION="Simple DirectMedia Layer is a cross-platform development library \
designed to provide low level access to audio, keyboard, mouse, joystick, and \
graphics hardware via OpenGL and Direct3D. It is used by video playback \
software, emulators, and popular games."
HOMEPAGE="https://www.libsdl.org/"
COPYRIGHT="1997-2021 Sam Lantinga"
LICENSE="Zlib"
REVISION="6"
SOURCE_URI="https://www.libsdl.org/release/SDL2-$portVersion.tar.gz"
CHECKSUM_SHA256="d8215b571a581be1332d2106f8036fcb03d12a70bae01e20f424976d275432bc"
SOURCE_DIR="SDL2-$portVersion"
PATCHES="libsdl2-$portVersion.patchset"

ARCHITECTURES="all ?x86"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	libsdl2$secondaryArchSuffix = $portVersion compat >= 2.0
	lib:libSDL2_2.0$secondaryArchSuffix = 0.14.0 compat >= 0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	"

PROVIDES_devel="
	libsdl2${secondaryArchSuffix}_devel = $portVersion compat >= 2.0
	cmd:sdl2_config$secondaryArchSuffix = $portVersion compat >= 2.0
	devel:libSDL2$secondaryArchSuffix = 0.14.0 compat >= 0
	devel:libSDL2_2.0$secondaryArchSuffix = 0.14.0 compat >= 0
	"
REQUIRES_devel="
	libsdl2$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgl$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:ninja
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cmake . -Bbuild -GNinja $cmakeDirArgs \
		-DSDL_STATIC=OFF -DRPATH=OFF
	ninja -C build
}

INSTALL()
{
	ninja -C build install

	# devel package
	prepareInstalledDevelLibs \
		libSDL2 \
		libSDL2-2.0

	fixPkgconfig
	fixDevelopLibDirReferences $binDir/sdl2-config

	packageEntries devel \
		$developDir $binDir/sdl2-config $dataDir $libDir/cmake
}
