# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libmfx
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.25
pkgrel=1
pkgdesc="Intel Media SDK dispatcher library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/lu-zero/mfx_dispatch/"
license=("BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/lu-zero/mfx_dispatch/archive/${pkgver}.tar.gz")
sha256sums=('853c4555c800a262fedacc580d06c234c520a919e4497b50e555291d87579a42')

prepare() {
  cd "${srcdir}/mfx_dispatch-${pkgver}"
  autoreconf -fiv
}
build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../mfx_dispatch-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

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