SUMMARY="A port of MAME 2003 Plus, a MAME fork, to libretro"
DESCRIPTION="Based on a snapshot of the MAME codebase circa 2003 (v0.78), \
'MAME 2003-Plus' is compatible with MAME 2003-Plus latest ROM sets. \
Contributors have backported support for an additional 350 games that are \
not included in the standard v0.078 ROM set, as well as other functionality \
not originally present in the underlying codebase."
HOMEPAGE="https://github.com/libretro/mame2003-plus-libretro"
COPYRIGHT="2019-2021 the MAME 2003-Plus team, the libretro team"
LICENSE="MAME Non-Commercial"
REVISION="1"
srcGitRev="b14db73bef159e84a20338c405828a4098af9e76"
SOURCE_URI="https://github.com/libretro/mame2003-plus-libretro/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="b241c120ceb69adb948f3b321eff31ee7d89746d2598526593d4e9b991bf4ee8"
SOURCE_FILENAME="mame2003-plus-libretro-${portVersion/_/-}-$srcGitRev.tar.gz"
SOURCE_DIR="mame2003-plus-libretro-$srcGitRev"
ADDITIONAL_FILES="mame2003_plus_libretro.info.in"

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

PROVIDES="
	mame2003_plus_libretro$secondaryArchSuffix = $portVersion
	addon:mame2003_plus_libretro$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	retroarch$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	sed -e "s/@DISPLAY_VERSION@/v${portVersion/_/-}/" \
		$portDir/additional-files/mame2003_plus_libretro.info.in \
		> mame2003_plus_libretro.info
	make $jobArgs
}

INSTALL()
{
	install -m 0755 -d "$docDir"
	install -m 0644 -t "$docDir" LICENSE.md CHANGELOG.md README.md
	install -m 0755 -d "$addOnsDir"/libretro
	install -m 0644 -t "$addOnsDir"/libretro \
		mame2003_plus_libretro.info \
		mame2003_plus_libretro.so
}
