# Maintainer: Márcio Silva <coadde@hyperbola.info>

pkgname=libav
pkgver=9.10
pkgrel=1
pkgdesc="Complete and free Internet live audio and video broadcasting solution for GNU/Linux"
arch=(
  x86_64
  i686
)
url=http://$pkgname.org/
license=(GPL3)
depends=(
  alsa-lib
  bzip2
  freetype2
  gnutls
  gsm
  lame
  libpulse
  libtheora
  libva
  libvorbis
  libvpx
  opencore-amr
  #openjpeg
  opus
  rtmpdump
  schroedinger
  sdl
  speex
  x264
  xvidcore
  zlib
)
makedepends=(
  yasm
  libvdpau
)
source=(http://$pkgname.org/releases/$pkgname-$pkgver.tar.gz)
sha512sums=(88bbe82fc3edfde17339cbd5fbae5ab074e750ad750fafcabc2c1fa408f352e38f32d8c0df0ff6c926d449bff29c725fc2c219d8b6e0398e3b93d43f086c9f10)

build() {
  cd $pkgname-$pkgver
  if [[ $CARCH == x86_64 ]]; then
    _asm='--disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vis --disable-altivec\
          --enable-amd3dnow --enable-mmx --enable-mmxext --enable-amd3dnow --enable-amd3dnowext --enable-sse --enable-sse2 --enable-sse3\
          --enable-avx --enable-fma4 --enable-sse3 --enable-ssse3 --enable-sse4 --enable-sse42'
  elif [[ $CARCH == i686 ]]; then
    _asm='--disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vis --disable-altivec\
          --enable-amd3dnow --enable-mmx --enable-mmxext --enable-amd3dnow --enable-amd3dnowext --enable-sse --enable-sse2 --enable-sse3\
          --disable-avx --disable-fma4 --disable-sse3 --disable-ssse3 --disable-sse4 --disable-sse42'
  else
    _asm='--disable-asm'
  fi
  ./configure\
    $_asm\
    --prefix=/usr\
    --bindir=/opt/$pkgname/bin\
    --incdir=/opt/$pkgname/include\
    --libdir=/opt/$pkgname/lib\
    --shlibdir=/opt/$pkgname/lib\
    --disable-avserver\
    --disable-debug\
    --disable-static\
    --enable-avresample\
    --enable-dxva2\
    --enable-gnutls\
    --enable-gpl\
    --enable-libfreetype\
    --enable-libgsm\
    --enable-libmp3lame\
    --enable-libopencore-amrnb\
    --enable-libopencore-amrwb\
    --disable-libopenjpeg\
    --enable-libopus\
    --enable-libpulse\
    --enable-librtmp\
    --enable-libschroedinger\
    --enable-libspeex\
    --enable-libtheora\
    --enable-libvorbis\
    --enable-libvpx\
    --enable-libx264\
    --enable-libxvid\
    --enable-pic\
    --enable-runtime-cpudetect\
    --enable-shared\
    --enable-vdpau\
    --enable-version3\
    --enable-x11grab
  make
  make tools/qt-faststart
  make doc/av{conv,play}.1
}

package() {
  cd $pkgname-$pkgver

  make DESTDIR=$pkgdir install install-man
  install -vD tools/qt-faststart $pkgdir/usr/bin/qt-faststart-$pkgname

  for _bin in conv play probe; do
    echo -e "#!/usr/bin/env bash\nLD_LIBRARY_PATH=/opt/$pkgname/lib /opt/$pkgname/bin/av$_bin \$@" > $pkgdir/usr/bin/av$_bin
  done
  chmod -v +x $pkgdir/usr/bin/*
}

# vim:set ts=2 sw=2 et: