# Maintainer: ImperatorS79 <fevrier.simon@gmail.com>

_realname=ffnvcodec-headers
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=11.0.10.1
pkgrel=1
pkgdesc='FFmpeg version of headers required to interface with Nvidias codec APIs'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url=https://git.videolan.org/?p=ffmpeg/nv-codec-headers.git
license=('MIT')
makedepends=("git")
_tag=315ad740ac77282c7cea67ba31f2e4b373132919
source=(git+https://git.videolan.org/git/ffmpeg/nv-codec-headers.git#tag=${_tag})
sha256sums=(SKIP)

pkgver() {
  cd nv-codec-headers

  git describe --tags | sed 's/^n//'
}

build() {
  make PREFIX=${MINGW_PREFIX} -C nv-codec-headers
  sed -n '4,25p' nv-codec-headers/include/ffnvcodec/nvEncodeAPI.h > LICENSE # Extract license
  sed -i '1,22s/^.\{,3\}//' LICENSE # Delete C comments
}

package() {
  make PREFIX=${MINGW_PREFIX} DESTDIR="${pkgdir}" -C nv-codec-headers install
  install -Dm 644 LICENSE -t "${pkgdir}${MINGW_PREFIX}"/share/licenses/ffnvcodec-headers/
}
