# Maintainer: Marcin Sielski <marcin.sielski@motorolasolutions.com>

_realname=openh264
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.1.1
pkgrel=1
pkgdesc="Library for encoding/decoding H264/AVC video streams (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://www.openh264.org/"
license=("BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-nasm")
depends=()
options=('strip' 'staticlibs')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/cisco/openh264/archive/v${pkgver}.tar.gz")
sha256sums=('af173e90fce65f80722fa894e1af0d6b07572292e76de7b65273df4c0a8be678')

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  cp -rf "$srcdir/${_realname}-${pkgver}" "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  if [[ "${MINGW_CHOST}" == "i686-w64-mingw32" ]]; then
    _arch="i686"
  else
    _arch="x86_64"
  fi
  make ARCH=${_arch} AR=ar OS=mingw_nt
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" PREFIX=${MINGW_PREFIX} install
}
