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="1"
SOURCE_URI="https://stian.cubic.org/ocp/ocp-$portVersion.tar.bz2"
CHECKSUM_SHA256="619f395893fafa6b0f24d98ebc7016eef6e6be53a5e6c63a3481964c1e4f14c9"

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_sdl2 = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libFLAC$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libmad$secondaryArchSuffix >= 0.2.1
	lib:libogg$secondaryArchSuffix >= 0.8.0
	lib:libpng$secondaryArchSuffix
	lib:libsdl2_2.0$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix >= 0.4.5
	lib:libvorbisfile$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	unifont
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libFLAC$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libmad$secondaryArchSuffix >= 0.2.1
	devel:libogg$secondaryArchSuffix >= 0.8.0
	devel:libpng$secondaryArchSuffix
	devel:libsdl2_2.0$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix >= 0.4.5
	devel:libvorbisfile$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	unifont
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:gettext$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:hexdump
	cmd:make
	cmd:makeinfo
	cmd:libtoolize$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	cmd:sdl_config$secondaryArchSuffix
	cmd:xa
	"

BUILD()
{
	libtoolize -vfi
	chmod +x configure
	runConfigure --omit-dirs binDir ./configure --bindir=$commandBinDir \
		--with-unifontdir=/system/data/fonts/ttfonts
	make $jobArgs
}

INSTALL()
{
	make install
}
