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

_realname=libmfx
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.35.1
pkgrel=1
pkgdesc="Intel Media SDK dispatcher library (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/lu-zero/mfx_dispatch/"
msys2_references=(
  'archlinux: '
  'aur: '
)
license=("spdx:BSD-3-Clause")
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://github.com/lu-zero/mfx_dispatch/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('673636da98a4fd5c3e3dc5267da5429e986f53089ed6c33cdca5751f56d9416b')

prepare() {
  cd "${srcdir}/mfx_dispatch-${pkgver}"
  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  export lt_cv_deplibs_check_method='pass_all'

  ../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-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
