# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Storm Dragon <stormdragon2976@gmail.com>
# Contributor: Aaron 'venisonslurpee' Laursen <venisonslurpee@gmail.com>
# Contributor: Christopher Rosell <chrippa@tanuki.se>
# Contributor: lh <jarryson@gmail.com>
# Contributor: Sebastian Schwarz <seschwar@gmail.com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Xilon <xilon@gmail.com>

pkgname=xmms2
pkgver=0.9.4
pkgrel=4
pkgdesc='X-platform Music Multiplexing System 2'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url='https://github.com/xmms2/wiki/wiki'
license=(GPL-2.0-only LGPL-2.1-only)
_depends=('alsa-lib: ALSA output'
          'avahi: announce xmms2d via bonjour/mDNS/zeroconf'
          'boost: C++ bindings'
          'curl: play HTTP streams'
          'cython: Python bindings'
          'faad2: AAC support'
          'ffmpeg: WMA, avcodec & avformat support'
          'fftw: visualization'
          'flac: FLAC support'
          'fluidsynth: MIDI support'
          'jack: JACK output'
          'libao: libao output'
          'libcdio-paranoia: CDDA support'
          'libdiscid: CDDA support'
          'libgme: support for various video game music formats'
          'libmad: MP3 support'
          'libmms: play MMS streams'
          'libmodplug: MOD support'
          'libmpcdec: Musepack support'
          'libofa: MusicDNS fingerprinting'
          'libsamplerate: vocoder support'
          'libshout: Icecast output'
          'libvorbis: Ogg Vorbis support'
          'libxml2: XSPF and podcast support'
          'mac: APE support'
          'mpg123: alternative MP3 support'
          'opusfile: Opus support'
          'perl: Perl bindings'
          'ruby: Ruby bindings'
          'smbclient: direct CIFS/SMB access'
          'speex: Speex support'
          'sqlite: for sqlite2s4'
          'wavpack: WavPack support')
makedepends=("${_depends[@]%%:*}" git libpulse perl-pod-parser waf)
optdepends=("${_depends[@]}" 'pulseaudio: PulseAudio output')
source=(https://github.com/xmms2/xmms2-devel/releases/download/$pkgver/$pkgname-$pkgver.tar.xz
        tmpfiles.conf
        sysusers.conf
        system.service
        user.service)
sha256sums=('100a35d2467006fe1828988043a9202e804ed8b0e94326addf32bb27645cb42a'
            '13e3e2720e21d048d776156f8ab17c40d05b70437823da00b3c4cc2e7f7ecf7f'
            'a37e35dedd48fb8fbc2c97d79be8a3d3c3b00191826f6046f730f649cd67812a'
            'a159b18c5959cfe76ca87990ff6879d082bfe9a4c6d674c493461f7f2781f348'
            '76f1a06b81cec0f5942430401998f6c8cd9cb95d798f97b854f88afd73ffe61d')

build() {
  cd xmms2-$pkgver
  export LINKFLAGS="$LDFLAGS"
  ./waf configure --prefix=/usr --libdir=/usr/lib --sbindir=/usr/bin --without-ldconfig \
    --with-ruby-archdir=`ruby -e 'puts RbConfig::CONFIG["vendorarchdir"]'` \
    --with-ruby-libdir=`ruby -e 'puts RbConfig::CONFIG["vendorlibdir"]'` \
    --with-perl-archdir=`perl -V:installvendorarch | cut -f2 -d\'` \
    --with-optionals=launcher,xmmsclient++,xmmsclient++-glib,perl,ruby,nycli,pixmaps,et,mdns,medialib-updater,sqlite2s4 \
    --without-optionals=python
  ./waf build
}

package() {
  cd xmms2-$pkgver
  ./waf --destdir="$pkgdir" install

  cd "$srcdir"
  install -Dm644 sysusers.conf "$pkgdir/usr/lib/sysusers.d/xmms2.conf"
  install -Dm644 tmpfiles.conf "$pkgdir/usr/lib/tmpfiles.d/xmms2.conf"
  install -Dm644 system.service "$pkgdir/usr/lib/systemd/system/xmms2d.service"
  install -Dm644 user.service "$pkgdir/usr/lib/systemd/user/xmms2d.service"
}
