# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgbase=aom
pkgname=(
  aom
  aom-docs
)
pkgver=%version%
pkgrel=%release%
pkgdesc="Alliance for Open Media video codec"
url="https://aomedia.org/"
arch=(x86_64)
license=(BSD-3-Clause)
depends=(
  gcc-libs
)
makedepends=(
  cmake
  doxygen
  ninja
  yasm
)
source=(
  https://storage.googleapis.com/aom-releases/libaom-$pkgver.tar.gz{,.asc}
)
b2sums=('ec572567699740e8114c220051f84e85ee9f33fb3003ece3cb738435bc1436c03499a3c35e86fc8c7d0d905e5ca01dbad78180af7c526c0ed932b07745df76c6'
        'SKIP')
validpgpkeys=(
  B002F08B74A148DAA01F7123A48E86DB0B830498 # AOMedia release signing key <av1-discuss@aomedia.org>
)

prepare() {
  cd libaom-$pkgver
}

build() {
  local cmake_options=(
    # Upstream would like Release, adding -O3 and removing assertions
    # https://gitlab.archlinux.org/archlinux/packaging/packages/aom/-/issues/1
    -D CMAKE_BUILD_TYPE=Release

    -D CMAKE_INSTALL_PREFIX=/usr
    -D BUILD_SHARED_LIBS=1
    -D ENABLE_TESTS=0
  )

  cmake -S libaom-$pkgver -B build -G Ninja "${cmake_options[@]}"
  cmake --build build
}

package_aom() {
  provides=(libaom.so)

  DESTDIR="$pkgdir" cmake --install build

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 libaom-$pkgver/{LICENSE,PATENTS}
}

package_aom-docs() {
  pkgdesc+=" (documentation)"
  depends=()

  mkdir -p "$pkgdir/usr/share/doc"
  cp -r build/docs/html "$pkgdir/usr/share/doc/$pkgbase"

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 libaom-$pkgver/{LICENSE,PATENTS}
}

# vim:set sw=2 sts=-1 et:
