# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=ffms2
pkgver=5.0
pkgrel=3
pkgdesc='A libav/ffmpeg based source library and Avisynth plugin for easy frame accurate access'
arch=(x86_64)
url=https://github.com/FFMS/ffms2
license=(GPL)
depends=(ffmpeg)
makedepends=(
  avisynthplus
  git
)
optdepends=(
  'avisynthplus: AviSynth plugin'
  'vapoursynth: VapourSynth plugin'
)
provides=(
  avisynth-plugin-ffms2
  libffms2.so
  vapoursynth-plugin-ffms2
)
_tag=7ed5e4d039ca9a6236bd2ebdfdd656c4304fbe04
source=(git+https://github.com/FFMS/ffms2.git#tag=${_tag})
sha256sums=('29a3d6c8532d2fbcdf6f0ba49da4de08e675898cb43cedae0b0f7c56cbbae418')

prepare() {
  cd ffms2
  mkdir -p src/config
  autoreconf -fiv
}

pkgver() {
  cd ffms2
  git describe --tags | sed 's/-//'
}

build() {
  cd ffms2
  export CXXFLAGS="$CXXFLAGS $(pkg-config --cflags avisynth) -fpermissive"
  ./configure \
    --prefix=/usr \
    --enable-avisynth \
    --enable-shared \
    --disable-static
  make
}

package() {
  make DESTDIR="${pkgdir}" -C ffms2 install
  for s in {avi,vapour}synth; do
    install -dm 755 "${pkgdir}"/usr/lib/$s
    ln -s ../libffms2.so "${pkgdir}"/usr/lib/$s/
  done
}

# vim: ts=2 sw=2 et:
