# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: David Runge <dave@sleepmap.de>
# Contributor: Ali H. Caliskan <ali.h.caliskan AT gmail DOT com>
# Contributor: Ryan Coyner <rcoyner@gmail.com>
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>

pkgname=mixxx
pkgver=2.2.2
pkgrel=1
pkgdesc="Free, open source software for digital DJ'ing."
arch=('x86_64')
url="https://www.mixxx.org"
license=('GPL2')
groups=('pro-audio')
depends=('chromaprint' 'faad2' 'gperftools' 'hidapi' 'libid3tag' 'libmad'
'libmp4v2' 'libshout' 'lilv' 'opusfile' 'portaudio' 'portmidi' 'protobuf'
'qt5-script' 'qt5-svg' 'qt5-x11extras' 'qtkeychain' 'rubberband' 'soundtouch'
'taglib' 'upower' 'wavpack')
makedepends=('glu' 'qt5-tools' 'scons' 'vamp-plugin-sdk')
checkdepends=('xorg-server-xvfb')
source=("https://github.com/${pkgname}dj/${pkgname}/archive/release-${pkgver}.tar.gz" scons-python3.patch)
sha512sums=('3b9365bd9d9a7d387cd8791d7d9f6315116e04322370db103998d5e055a6de5e159a4605c7de96cbcf13e7d0653cbe53140dca18a8c3f1b688b227be2c4aeb6f'
            '4b01dc590ca6d7ae2ac20af77e74e02fe7c179ffc1e5cad6cffb22c6cc750ab1757103e27922430abe6d3d7a023bb22fd15640fbaff8acc812acef5099598fe3')

prepare() {
  mv -v "${pkgname}-release-${pkgver}" "${pkgname}-${pkgver}"
  cd "${pkgname}-${pkgver}"
  patch -p1 -i ../scons-python3.patch
}

build() {
  cd "${pkgname}-${pkgver}"
  export SCONSFLAGS="-j $(nproc)"
  scons prefix=/usr \
        build=release \
        faad=1 \
        modplug=1 \
        perftools=1 \
        perftools_profiler=1 \
        qt_sqlite_plugin=0 \
        qtkeychain=1 \
        test=1 \
        target=linux \
        virtualize=0 \
        wv=1
}

check() {
  cd "${pkgname}-${pkgver}"
  xvfb-run lin64_build/${pkgname}-test
}

package() {
  cd "${pkgname}-${pkgver}"
  scons prefix=/usr \
        install_root="${pkgdir}/usr" \
        install
  # removing the test executable
  rm -v "${pkgdir}/usr/bin/${pkgname}-test"
}
