SUMMARY="Audio and Video Tools for Motion JPEG and MPEG"
DESCRIPTION="
Programs for MJPEG recording and playback and simple cut-and-paste \
editting and MPEG compression of audio and video.
"
HOMEPAGE="http://mjpeg.sourceforge.net"
LICENSE="
	GNU GPL v2
	"
COPYRIGHT="
	2000-2003 Fabrice Bellard
	2003-2012 the FFmpeg developers
	"
SOURCE_URI="https://downloads.sourceforge.net/sourceforge/mjpeg/mjpegtools-$portVersion.tar.bz2"
CHECKSUM_SHA256="a84349839471052db1ef691134aacf905b314dfce8762d47e10edcc9ab5f97d8"
REVISION="1"
PATCHES="mjpegtools-$portVersion.patchset"

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

PROVIDES="
	mjpegtools$secondaryArchSuffix = $portVersion compat >= 2
	lib:liblavfile_2.2$secondaryArchSuffix = 0.0.0 compat >= 0
	lib:liblavjpeg_2.2$secondaryArchSuffix = 0.0.0 compat >= 0
	lib:libmjpegutils_2.2$secondaryArchSuffix = 0.0.0 compat >= 0
	lib:libmpeg2encpp_2.2$secondaryArchSuffix = 0.0.0 compat >= 0
	lib:libmplex2_2.2$secondaryArchSuffix = 0.0.0 compat >= 0
	"
if [ -z "$secondaryArchSuffix" ]; then
	PROVIDES="$PROVIDES
		cmd:anytovcd.sh = $portVersion compat >= 2
		cmd:jpeg2yuv = $portVersion compat >= 2
		cmd:lav2avi.sh = $portVersion compat >= 2
		cmd:lav2mpeg = $portVersion compat >= 2
		cmd:lav2wav = $portVersion compat >= 2
		cmd:lav2yuv = $portVersion compat >= 2
		cmd:lavaddwav = $portVersion compat >= 2
		cmd:lavinfo = $portVersion compat >= 2
		cmd:lavpipe = $portVersion compat >= 2
		cmd:lavtc.sh = $portVersion compat >= 2
		cmd:lavtrans = $portVersion compat >= 2
		cmd:matteblend.flt = $portVersion compat >= 2
		cmd:mjpeg_simd_helper = $portVersion compat >= 2
		cmd:mp2enc = $portVersion compat >= 2
		cmd:mpeg2enc = $portVersion compat >= 2
		cmd:mpegtranscode = $portVersion compat >= 2
		cmd:mplex = $portVersion compat >= 2
		cmd:multiblend.flt = $portVersion compat >= 2
		cmd:pgmtoy4m = $portVersion compat >= 2
		cmd:png2yuv = $portVersion compat >= 2
		cmd:pnmtoy4m = $portVersion compat >= 2
		cmd:ppmtoy4m = $portVersion compat >= 2
		cmd:transist.flt = $portVersion compat >= 2
		cmd:y4mblack = $portVersion compat >= 2
		cmd:y4mcolorbars = $portVersion compat >= 2
		cmd:y4mdenoise = $portVersion compat >= 2
		cmd:y4mhist = $portVersion compat >= 2
		cmd:y4minterlace = $portVersion compat >= 2
		cmd:y4mivtc = $portVersion compat >= 2
		cmd:y4mscaler = $portVersion compat >= 2
		cmd:y4mshift = $portVersion compat >= 2
		cmd:y4mspatialfilter = $portVersion compat >= 2
		cmd:y4mstabilizer = $portVersion compat >= 2
		cmd:y4mtopnm = $portVersion compat >= 2
		cmd:y4mtoppm = $portVersion compat >= 2
		cmd:y4mtoyuv = $portVersion compat >= 2
		cmd:y4munsharp = $portVersion compat >= 2
		cmd:ypipe = $portVersion compat >= 2
		cmd:yuv2lav = $portVersion compat >= 2
		cmd:yuv4mpeg = $portVersion compat >= 2
		cmd:yuvcorrect = $portVersion compat >= 2
		cmd:yuvcorrect_tune = $portVersion compat >= 2
		cmd:yuvdeinterlace = $portVersion compat >= 2
		cmd:yuvdenoise = $portVersion compat >= 2
		cmd:yuvfps = $portVersion compat >= 2
		cmd:yuvinactive = $portVersion compat >= 2
		cmd:yuvkineco = $portVersion compat >= 2
		cmd:yuvmedianfilter = $portVersion compat >= 2
		cmd:yuvscaler = $portVersion compat >= 2
		cmd:yuvycsnoise = $portVersion compat >= 2
		cmd:yuyvtoy4m = $portVersion compat >= 2
		"
fi

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	mjpegtools${secondaryArchSuffix}_devel = $portVersion compat >= 2
	devel:liblavfile_2.2$secondaryArchSuffix = 0.0.0 compat >= 0
	devel:liblavjpeg_2.2$secondaryArchSuffix = 0.0.0 compat >= 0
	devel:libmjpegutils_2.2$secondaryArchSuffix = 0.0.0 compat >= 0
	devel:libmpeg2encpp_2.2$secondaryArchSuffix = 0.0.0 compat >= 0
	devel:libmplex2_2.2$secondaryArchSuffix = 0.0.0 compat >= 0
	"
REQUIRES_devel="
	mjpegtools$secondaryArchSuffix == $portVersion
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libjpeg$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:nasm
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

BUILD()
{
	autoreconf -fi
	runConfigure ./configure --disable-dependency-tracking
	make $jobArgs
}

INSTALL()
{
	make install

	rm -f $libDir/lib*.la $libDir/lib*.a
	mv $libDir/libmjpegutils.so $libDir/libmjpegutils-2.2.so
	mv $libDir/liblavfile.so $libDir/liblavfile-2.2.so
	mv $libDir/liblavjpeg.so $libDir/liblavjpeg-2.2.so
	mv $libDir/libmpeg2encpp.so $libDir/libmpeg2encpp-2.2.so
	mv $libDir/libmplex2.so $libDir/libmplex2-2.2.so

	prepareInstalledDevelLibs \
		libmjpegutils-2.2 liblavfile-2.2 liblavjpeg-2.2 \
		libmpeg2encpp-2.2 libmplex2-2.2
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir

	# Remove stuff we don't need in the secondary architecture base package.
	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $prefix/bin
		rm -rf $documentationDir
	fi
}
