SUMMARY="An MPEG decoding library"
DESCRIPTION="SMPEG is short for the SDL MPEG library originally developed \
by Loki Software. SMPEG uses MPEG-1 standard as a video display library, \
rather than MPEG-2, since only the MPEG-1 standard is unencumbered with \
software patents in the United States."
HOMEPAGE="http://www.icculus.org/smpeg"
COPYRIGHT="1999-2004 Sam Lantinga, Joe Tennies."
LICENSE="GNU LGPL v2"
REVISION="4"
SOURCE_URI="https://www.libsdl.org/projects/smpeg/release/smpeg2-$portVersion.tar.gz"
CHECKSUM_SHA256="979a65b211744a44fa641a9b6e4d64e64a12ff703ae776bafe3c4c4cd85494b3"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	smpeg2$secondaryArchSuffix = 2.0.0 compat >= 2
	cmd:plaympeg$secondaryArchSuffix = 2.0.0 compat >= 2
	cmd:smpeg2 = 2.0.0 compat >= 2
	lib:libsmpeg2$secondaryArchSuffix = 2.0_0.0.0 compat >= 2.0_0
	lib:libsmpeg2_2.0$secondaryArchSuffix = 2.0.0 compat >= 2
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgl$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	lib:libsdl2_2.0$secondaryArchSuffix
	"

PROVIDES_devel="
	smpeg2${secondaryArchSuffix}_devel = $portVersion
	cmd:smpeg2_config$secondaryArchSuffix
	devel:libsmpeg2$secondaryArchSuffix = 2.0_0.0.0 compat >= 2.0_0
	devel:libsmpeg2_2.0$secondaryArchSuffix = 2.0.0 compat >= 2
	"
REQUIRES_devel="
	smpeg2$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	#devel:libgl$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libsdl2_2.0$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	rm -f acinclude.m4
	rm -f aclocal.m4
	echo "AC_CONFIG_MACRO_DIR([acinclude]) > configure.in"
	libtoolize --copy --force --install
	aclocal --install -I acinclude
	automake --foreign --add-missing
	autoconf
	chmod +x configure

	runConfigure ./configure

	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libsmpeg2.la

	prepareInstalledDevelLibs libsmpeg2 \
					libsmpeg2-2.0
	fixDevelopLibDirReferences $binDir/smpeg2-config
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir $binDir/smpeg2-config \
		$dataDir
}
