# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: speps <speps at aur dot archlinux dot org>
# Contributor: Philipp Überbacher <hollunder at gmx dot at>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - set -DCONFIG_SSE=OFF

pkgname=qtractor
pkgver=0.9.34
pkgrel=2
pkgdesc="Audio/MIDI multitrack sequencer"
arch=(x86_64)
url="https://qtractor.sourceforge.io/"
license=(GPL2)
groups=(pro-audio)
depends=(
  gcc-libs
  glibc
  hicolor-icon-theme
  libmad
  libxcb
  qt6-base
  qt6-svg
  zlib
)
makedepends=(
  alsa-lib
  aubio
  clap
  cmake
  dssi
  jack
  ladspa
  liblo
  libogg
  libsamplerate
  libsndfile
  libvorbis
  lilv
  lv2
  qt6-tools
  rubberband
  suil
  vst3sdk
)
optdepends=(
  'new-session-manager: for session management'
  'qt6-wayland: for native wayland support'
)
provides=(
  clap-host
  dssi-host
  ladspa-host
  lv2-host
  vst-host
  vst3-host
)
source=(https://github.com/rncbc/$pkgname/archive/refs/tags/${pkgname}_${pkgver//./_}.tar.gz)
sha512sums=('e27281b84f713a9c91e143a5bb06ebedc80e4d7a43dd966796bcde20b7308583f4952dbe681257c0f687ddd40127b9c16cbe28f7684508e6c8964d7c188a608b')
b2sums=('d4ccc266f07542f1e383e34a1c74f2960432d6d768b765ea1c600e2b34466519eb8f9a4c9a2b0c162987b9c4dc0f36ce12f883c4dd40eaec6af4c08f90e4445b')

build() {
  local cmake_options=(
    -B build
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCONFIG_QT6=ON
    -DCONFIG_SSE=OFF
    -S $pkgname-${pkgname}_${pkgver//./_}
    -Wno-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

package() {
  depends+=(
    alsa-lib libasound.so
    aubio libaubio.so
    jack libjack.so
    liblo liblo.so
    libogg libogg.so
    libsamplerate libsamplerate.so
    libsndfile libsndfile.so
    libvorbis libvorbisenc.so libvorbisfile.so libvorbis.so
    lilv liblilv-0.so
    rubberband librubberband.so
  )

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-${pkgname}_${pkgver//./_}/{README,README.VST} -t "$pkgdir/usr/share/doc/$pkgname/"
}