SUMMARY="Emulator for various Nintendo, Sega, etc. consoles"
DESCRIPTION="Mednafen is a portable, utilizing OpenGL and SDL, \
argument-driven multi-system emulator. Mednafen has the ability to remap \
hotkey functions and virtual system inputs to a keyboard, a joystick, or \
both simultaneously. Save states are supported, as is real-time game \
rewinding. Screen snapshots may be taken, in the PNG file format, at the \
press of a button. Mednafen can record audiovisual movies in the QuickTime \
file format, with several different lossless codecs supported.

The following systems are supported (refer to the emulation module \
documentation for more details): \
 - Atari Lynx
 - Neo Geo Pocket (Color)
 - WonderSwan
 - GameBoy (Color)
 - GameBoy Advance
 - Nintendo Entertainment System
 - Super Nintendo Entertainment System/Super Famicom
 - Virtual Boy
 - PC Engine/TurboGrafx 16 (CD)
 - SuperGrafx
 - PC-FX
 - Sega Game Gear
 - Sega Genesis/Megadrive
 - Sega Master System
 - Sony PlayStation"
HOMEPAGE="http://mednafen.fobby.net/"
COPYRIGHT="2005-2015 Mednafen Team"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="http://mednafen.github.io/releases/files/mednafen-$portVersion.tar.xz"
CHECKSUM_SHA256="f5b502e9f2f615c8b69fa1e151da20ab387377c72748cd8e19deb75a432ecfd2"
SOURCE_DIR="mednafen"
PATCHES="mednafen-$portVersion.patchset"

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

PROVIDES="
	mednafen$secondaryArchSuffix = $portVersion
	cmd:mednafen$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:liblzo2$secondaryArchSuffix
	lib:libmpcdec$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	lib:libvorbisidec$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:libGL$secondaryArchSuffix
	devel:libGLU$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:liblzo2$secondaryArchSuffix
	devel:libmpcdec$secondaryArchSuffix
	devel:libsdl2$secondaryArchSuffix
	devel:libsndfile$secondaryArchSuffix
	devel:libvorbisidec$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:aclocal
	cmd:autoreconf
	cmd:awk
	cmd:bison
	cmd:gcc$secondaryArchSuffix
	cmd:gettext
	cmd:grep
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:msgfmt
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

PATCH()
{
	sed -i "s/socket\; do/network\; do/" configure
		# otherwise it won't find gethostbyname(), etc.
}

BUILD()
{
	autoreconf -vfi
	runConfigure ./configure \
		--with-external-mpcdec \
		--with-external-tremor \
		--with-external-lzo

	make $jobArgs
}

INSTALL()
{
	make install
}
