SUMMARY="Open Cubic Player"
DESCRIPTION="ocp - Open Cubic Player, a music player ported from DOS."
HOMEPAGE="https://stian.cubic.org/project-ocp.php"
COPYRIGHT="1994-2016 Niklas Beisert, Stian Skjelstad and others"
LICENSE="GNU GPL v2"
REVISION="2"
srcGitRev="835bf803f590512848282bbf74986ebfaec17da3"
SOURCE_URI="https://sourceforge.net/code-snapshots/git/o/op/opencubicplayer/code.git/opencubicplayer-code-$srcGitRev.zip"
CHECKSUM_SHA256="8691b9fa9f512c98307c6e4fb2723c10a4a8f212da8a3af1b9d15d2fe32764fb"
SOURCE_DIR="opencubicplayer-code-$srcGitRev"

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

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	ocp$secondaryArchSuffix = $portVersion
	cmd:ocp$commandSuffix = $portVersion
	cmd:ocp_${portVersion#~*}$commandSuffix = $portVersion
	cmd:ocp_curses = $portVersion
	cmd:ocp_sdl = $portVersion
	cmd:ultrafix.sh = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libFLAC$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libmad$secondaryArchSuffix >= 0.2.1
	lib:libogg$secondaryArchSuffix >= 0.8.0
	lib:libSDL_1.2$secondaryArchSuffix >= 0.11.4
	lib:libvorbis$secondaryArchSuffix >= 0.4.5
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libFLAC$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libmad$secondaryArchSuffix >= 0.2.1
	devel:libogg$secondaryArchSuffix >= 0.8.0
	devel:libSDL_1.2$secondaryArchSuffix >= 0.11.4
	devel:libvorbis$secondaryArchSuffix >= 0.4.5
	devel:libz$secondaryArchSuffix >= 1.2.8
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:gettext$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:makeinfo
	cmd:libtoolize$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	cmd:sdl_config$secondaryArchSuffix
	"

PATCH()
{
	# Broken, missing headers
	sed -i '/playgmi TOPDIR/d' Makefile.in
}

BUILD()
{
	libtoolize -vfi
	chmod +x configure
	runConfigure --omit-dirs binDir ./configure --bindir=$commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install
	chmod +x $commandBinDir/{ocp-curses,ocp-sdl,ultrafix.sh}
}
