# Maintainer: Greg Williamson <cheeseboy16@gmail.com>

_realname=alure
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2
pkgrel=5
pkgdesc='Utility library to help manage common tasks with OpenAL applications (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url='https://kcat.tomasu.net/alure.html'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-openal")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-libsndfile"
             "${MINGW_PACKAGE_PREFIX}-libvorbis"
             "${MINGW_PACKAGE_PREFIX}-flac"
             "${MINGW_PACKAGE_PREFIX}-mpg123"
             "${MINGW_PACKAGE_PREFIX}-dumb"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-fluidsynth")
optdepends=("${MINGW_PACKAGE_PREFIX}-libsndfile: for uncompressed audio support"
            "${MINGW_PACKAGE_PREFIX}-libvorbis: for OGG Vorbis support"
            "${MINGW_PACKAGE_PREFIX}-flac: for FLAC support"
            "${MINGW_PACKAGE_PREFIX}-mpg123: for MPEG support"
            "${MINGW_PACKAGE_PREFIX}-dumb: for IT, XM, S3M and MOD support"
            "${MINGW_PACKAGE_PREFIX}-fluidsynth: for SoundFont 2 support")
source=("https://kcat.tomasu.net/alure-releases/${_realname}-${pkgver}.tar.bz2"
        build.patch
        mingw-build.patch)
sha256sums=('465e6adae68927be3a023903764662d64404e40c4c152d160e3a8838b1d70f71'
            '21029cfc8900b8270f6c7a79235e09a05d45d0b03b221d9d856a27e98cc0931b'
            '0a4968b9d5452521d3572b140510c90941daa11e851c19cd1d1d162d263abadd')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/build.patch"
  patch -p1 -i "${srcdir}/mingw-build.patch"
}

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

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G "Ninja" \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    ../${_realname}-${pkgver}

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

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

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

  install -Dm0644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
