pkgname=clownaudio-git
pkgver=r430.4a508d0
pkgrel=1
pkgdesc='Stereo audio engine supporting various formats'
arch=('any')
url='https://github.com/Clownacy/clownaudio'
license=('zlib', 'MIT', 'LGPL2', 'custom')
depends=(
  'libvorbis'
  'flac'
  'opus'
)
makedepends=('cmake')
source=("git+https://github.com/Clownacy/clownaudio.git")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/clownaudio"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  mkdir -p "${srcdir}/clownaudio/build"
}

build() {
  cd "${srcdir}/clownaudio/build"

  cmake .. \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_SHARED_LIBS=ON \
    -DCLOWNAUDIO_LIBVORBIS=ON \
    -DCLOWNAUDIO_STB_VORBIS=OFF \
    -DCLOWNAUDIO_DR_MP3=ON \
    -DCLOWNAUDIO_LIBOPUS=ON \
    -DCLOWNAUDIO_LIBFLAC=ON \
    -DCLOWNAUDIO_DR_FLAC=OFF \
    -DCLOWNAUDIO_DR_WAV=ON \
    -DCLOWNAUDIO_LIBSNDFILE=OFF \
    -DCLOWNAUDIO_LIBOPENMPT=OFF \
    -DCLOWNAUDIO_LIBXMPLITE=ON \
    -DCLOWNAUDIO_PXTONE=ON \
    -DCLOWNAUDIO_SNES_SPC=ON \
    -DCLOWNAUDIO_BACKEND=miniaudio

  make
}

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