# Maintainer: Lutz Bürkle <lutz.buerkle@web.de>

_realname=libebur128
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2.6
pkgrel=1
pkgdesc="A Library that implements the EBU R 128 standard for loudness normalisation (mingw-w64)"
url="https://github.com/jiixyj/libebur128/"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-cmake")
source=(https://github.com/jiixyj/${_realname}/archive/v${pkgver}.tar.gz
        "001-dont-link-m.patch")
sha256sums=('baa7fc293a3d4651e244d8022ad03ab797ca3c2ad8442c43199afe8059faa613'
            '2164ba3521820a2ef5cbb6ef163096b618ef01acfc0cb57d722c21100e149cb0')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}

  patch -p1 -i "${srcdir}/001-dont-link-m.patch"
}

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

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -GNinja \ \
    -DENABLE_INTERNAL_QUEUE_H=ON \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/cmake --build .
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --build . --target install
}
