SUMMARY="A tool to display technical information of audio and video files"
DESCRIPTION="MediaInfo is a convenient unified display of the most relevant \
technical and tag data for video and audio files.

MediaInfo analyticals include:

- Container: MPEG-4, QuickTime, Matroska, AVI, MPEG-PS (including unprotected \
DVD), MPEG-TS (including unprotected Blu-ray), MXF, GXF, LXF, WMV, FLV, Real...
- Tags: Id3v1, Id3v2, Vorbis comments, APE tags...
- Video: MPEG-1/2 Video, H.263, MPEG-4 Visual (including DivX, XviD), \
H.264/AVC, Dirac...
- Audio: MPEG Audio (including MP3), AC3, DTS, AAC, Dolby E, AES3, FLAC...
- Subtitles: CEA-608, CEA-708, DTVCC, SCTE-20, SCTE-128, ATSC/53, CDP, DVB \
Subtitle, Teletext, SRT, SSA, ASS, SAMI..."
HOMEPAGE="http://mediainfo.sourceforge.net/"
COPYRIGHT="2002-2021 MediaArea.net SARL"
LICENSE="GNU LGPL v2.1
	BSD (2-clause)"
REVISION="1"
SOURCE_URI="http://mediaarea.net/download/binary/mediainfo/$portVersion/MediaInfo_CLI_${portVersion}_GNU_FromSource.tar.bz2"
CHECKSUM_SHA256="75adafad4f1bd3259354a50ae491de6929649c14c71998cf5a2ed176d298b011"
SOURCE_DIR="MediaInfo_CLI_GNU_FromSource"
PATCHES="mediainfo-$portVersion.patchset"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="0.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	mediainfo$secondaryArchSuffix = $portVersion
	cmd:mediainfo$commandSuffix = $portVersion
	lib:libmediainfo$secondaryArchSuffix = $libVersionCompat
	lib:libzen$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libtinyxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	mediainfo${secondaryArchSuffix}_devel = $portVersion
	devel:libmediainfo$secondaryArchSuffix = $libVersionCompat
	devel:libzen$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	mediainfo$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcurl$secondaryArchSuffix
	devel:libtinyxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cd ZenLib/Project/GNU/Library
	autoreconf -vfi
	cd $sourceDir
	CFLAGS="-D_BSD_SOURCE" CXXFLAGS="-D_BSD_SOURCE" \
	LDFLAGS="-ltinyxml2" ./CLI_Compile.sh \
		--with-libcurl \
		--with-libtinyxml2 \
		--enable-shared \
		--prefix=$prefix \
		--libdir=$libDir \
		--includedir=$includeDir \
		--bindir=$commandBinDir
}

INSTALL()
{
	cd $sourceDir/MediaInfoLib/Project/GNU/Library
	make install
	cd $sourceDir/MediaInfo/Project/GNU/CLI
	make install
	cd $sourceDir/ZenLib/Project/GNU/Library
	make install

	rm -rf $libDir/*.la

	prepareInstalledDevelLibs libmediainfo libzen

	fixPkgconfig

	packageEntries devel \
		$developDir
}
