SUMMARY="A lightweight video thumbnailer"
DESCRIPTION="FFmpegthumbnailer is a lightweight video thumbnailer that can be \
used by file managers to create thumbnails for your video files. The \
thumbnailer uses ffmpeg to decode frames from the video files, so supported \
videoformats depend on the configuration flags of ffmpeg.

This thumbnailer was designed to be as fast and lightweight as possible. The \
only dependencies are ffmpeg and libpng."
HOMEPAGE="https://github.com/dirkvdb/ffmpegthumbnailer"
COPYRIGHT="2008-2012 Dirk Vanden Boer"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="$HOMEPAGE/releases/download/$portVersion/ffmpegthumbnailer-$portVersion.tar.bz2"
CHECKSUM_SHA256="1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b"

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

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

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

PROVIDES="
	ffmpegthumbnailer$secondaryArchSuffix = $portVersion
	cmd:ffmpegthumbnailer$commandSuffix = $portVersion
	lib:libffmpegthumbnailer$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libavcodec$secondaryArchSuffix
	lib:libavfilter$secondaryArchSuffix
	lib:libavformat$secondaryArchSuffix
	lib:libavutil$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	ffmpegthumbnailer${secondaryArchSuffix}_devel = $portVersion
	devel:libffmpegthumbnailer$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	ffmpegthumbnailer$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libavcodec$secondaryArchSuffix
	devel:libavfilter$secondaryArchSuffix
	devel:libavformat$secondaryArchSuffix
	devel:libavutil$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cmake -B build -S . -DCMAKE_BUILD_TYPE=None \
		$cmakeDirArgs \
		-DCMAKE_INSTALL_BINDIR=$commandBinDir \
		-DENABLE_GIO=ON \
		-DENABLE_THUMBNAILER=ON
	make -C build $jobArgs
}

INSTALL()
{
	make -C build install

	prepareInstalledDevelLib libffmpegthumbnailer
	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}
