# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer:
# Contributor: Ronald van Haren <ronald.archlinux.org>
# Contributor: boromil@gmail.com

pkgname=ffmpegthumbnailer
pkgver=2.2.2
pkgrel=6
pkgdesc="Lightweight video thumbnailer that can be used by file managers"
url="https://github.com/dirkvdb/ffmpegthumbnailer"
license=('GPL2')
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
depends=('ffmpeg' 'libjpeg' 'libpng')
makedepends=('cmake')
optdepends=('gvfs: support for gio uris')
source=(https://github.com/dirkvdb/$pkgname/archive/$pkgver/$pkgname-$pkgver.tar.gz
        ffmpegthumbnailer-ffmpeg5.patch::https://patch-diff.githubusercontent.com/raw/dirkvdb/ffmpegthumbnailer/pull/198.patch
        https://github.com/dirkvdb/ffmpegthumbnailer/commit/efb5b618.patch)
sha256sums=('8c4c42ab68144a9e2349710d42c0248407a87e7dc0ba4366891905322b331f92'
            '300d3208fca6de6f7a90fbabbb8e58b9cf0cc4a4c9b1d2df0cd53ece1736646a'
            'c266d1c7cab2fa26dfee2410ea6864ab81a57e8784eda6574cd8237750b9e0e1')

prepare() {
  patch -d $pkgname-$pkgver -p1 < ffmpegthumbnailer-ffmpeg5.patch # Fix build with FFmpeg 5
  patch -d $pkgname-$pkgver -p1 < efb5b618.patch # Fix build with FFmpeg 5
}

build() {
  cmake -B build -S $pkgname-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DENABLE_GIO=ON \
    -DENABLE_THUMBNAILER=ON
  cmake --build build
}

package() {
  DESTDIR="${pkgdir}" cmake --install build
}
