# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer : Daniel Bermond <dbermond@archlinux.org>
# Contributor: drakkan <nicola.murino at gmail dot com>

pkgname=openh264
pkgver=2.4.1
pkgrel=1.1
_gtestver=1.8.1
pkgdesc='H.264 encoder and decoder'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url='https://www.openh264.org/'
license=('BSD')
depends=('gcc-libs')
makedepends_x86_64=('nasm')
provides=('libopenh264.so')
source=("https://github.com/cisco/openh264/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz"
        "https://github.com/google/googletest/archive/release-${_gtestver}/googletest-${_gtestver}.tar.gz")
sha256sums=('8ffbe944e74043d0d3fb53d4a2a14c94de71f58dbea6a06d0dc92369542958ea'
            '9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c')

prepare() {
    ln -sf "../googletest-release-${_gtestver}" "${pkgname}-${pkgver}/gtest"
}

build() {
    make -C "${pkgname}-${pkgver}"
}

check() {
    make -C "${pkgname}-${pkgver}" test
    cd "${pkgname}-${pkgver}/testbin"
    ./CmdLineExample.sh
}

package() {
    make -C "${pkgname}-${pkgver}" DESTDIR="$pkgdir" PREFIX='/usr' install-shared
    install -D -m755 "${pkgname}-${pkgver}"/h264{dec,enc} -t "${pkgdir}/usr/bin"
    install -D -m644 "${pkgname}-${pkgver}/LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
