# Maintainer:  Dave Murphy <davem@devkitpro.org>

pkgname=switch-libtheora
pkgver=1.1.1
pkgrel=1
pkgdesc='Free and open video compression codec from the Xiph.org Foundation'
arch=('any')
url='https://www.theora.org/'
license=(Xiph.org)
options=(!strip libtool staticlibs)
source=("http://downloads.xiph.org/releases/theora/libtheora-${pkgver}.tar.bz2" "config.sub" "config.guess")
sha256sums=(
 'b6ae1ee2fa3d42ac489287d3ec34c5885730b1296f0801ae577a35193d3affbc'
 '72e02ea93447038f8ced24f296b31e0f397bbcc6b32abdcf9b38c80f153433fd'
 'fbc2337aa59a204f5d74743b82c8be7aab8b39853b4e54a888008f70430c4305'
)

makedepends=('switch-pkg-config' 'devkitpro-pkgbuild-helpers')
depends=('switch-libogg' 'switch-libvorbis' 'switch-libpng')
groups=('switch-portlibs')
build() {
  cd libtheora-$pkgver

  source /opt/devkitpro/devkita64.sh
  source /opt/devkitpro/switchvars.sh

  cp $srcdir/config.sub $srcdir/config.guess .

  ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \
    --disable-shared --enable-static \
    --disable-encode --disable-examples

  make
}

package() {
  cd libtheora-$pkgver

  source /opt/devkitpro/devkita64.sh
  source /opt/devkitpro/switchvars.sh

  make DESTDIR="$pkgdir" install

  install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING

  # remove useless documentation
  rm -r "$pkgdir"${PORTLIBS_PREFIX}/share/doc
}
