# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: speps <speps at aur dot archlinux dot org>
# Contributor: Dany Martineau <dany.luc.martineau@gmail.com>

pkgname=drumstick
pkgver=2.4.0
pkgrel=1
pkgdesc="MIDI libraries for Qt5/C++"
arch=('x86_64')
url="https://drumstick.sourceforge.io/"
license=('GPL2')
depends=('gcc-libs' 'glibc' 'hicolor-icon-theme' 'qt5-base')
makedepends=('alsa-lib' 'cmake' 'doxygen' 'docbook-xsl' 'fluidsynth' 'graphviz'
'libpulse' 'qt5-tools')
provides=('libdrumstick-alsa.so' 'libdrumstick-file.so' 'libdrumstick-rt.so'
'libdrumstick-widgets.so')
source=("https://downloads.sourceforge.net/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.bz2")
sha512sums=('d6b1d7488e673f9d0e6652bb9d72f5f15eb2c2ce552ce802f2389970cec045a98ba4cf86b770376a857a476db5b7ec0f61a0467e82f749e0292fd097d5e316d6')
b2sums=('f6940f84ba08dea1498e3b6770974f35e0b74d054ec42d06a66b52130d26b121114a4455a3dd57db07020901ba437af063f619956b4acfa5473ff98461f01fab')

build() {
  cd "${pkgname}-${pkgver}"
  cmake -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE='None' \
        -Wno-dev \
        -B build \
        -S .
  make VERBOSE=1 -C build
}

check() {
  cd "${pkgname}-${pkgver}"
  # some tests fail due to insufficient system privileges, hence only run those
  # that make sense in the build environment
  # https://sourceforge.net/p/drumstick/bugs/24/
  make test -C build/tests/fileTest1
  make test -C build/tests/fileTest2
}

package() {
  depends+=('libasound.so' 'libfluidsynth.so' 'libpulse.so' 'libpulse-simple.so')
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}/" install -C build
  install -t "${pkgdir}/usr/share/doc/${pkgname}/" \
    -vDm 644 {AUTHORS,ChangeLog,NEWS,readme.md,TODO}
}
