# Maintainer: Aaron Fischer <mail@aaron-fischer.net>
# Contributor: Nuno Araujo <nuno.araujo@russo79.com>
# Contributor: Xpander <xpander0@gmail.com>
# Contributor: Stefan Achatz <erazor_de@users.soruceforge.net>
# Contributor: Zachary Lund <admin@computerquip.com>
# Contributor: Jesus Gonzalez <jesusmgh@gmail.com>
# Contributor: Francisco Pina-Martins <f.pinamartins@gmail.com>
# Contributor: Alex <antianno52@gmail.com>
# Contributor: Martchus <martchus@gmx.net>

pkgname=('roccat-tools-common'
         'roccat-tools-arvo'
         'roccat-tools-kiro'
         'roccat-tools-isku'
         'roccat-tools-iskufx'
         'roccat-tools-kone'
         'roccat-tools-koneplus'
         'roccat-tools-konepure'
         'roccat-tools-konepuremilitary'
         'roccat-tools-konepureoptical'
         'roccat-tools-konextd'
         'roccat-tools-konextdoptical'
         'roccat-tools-kovaplus'
         'roccat-tools-kova2016'
         'roccat-tools-lua'
         'roccat-tools-pyra'
         'roccat-tools-ryosmk'
         'roccat-tools-ryosmkfx'
         'roccat-tools-ryostkl'
         'roccat-tools-savu'
         'roccat-tools-skeltr'
         'roccat-tools-sova'
         'roccat-tools-suora'
         'roccat-tools-tyon'
         'roccat-tools-nyth')
pkgbase=roccat-tools
pkgver=5.9.0
pkgrel=2
pkgdesc='Userland applications to configure and make extended use of ROCCAT devices'
arch=('i686' 'x86_64')
url='http://roccat.sourceforge.net'
license=('GPL2')
depends=('libgaminggear>=0.15.1' 'libcanberra' 'gtk2' 'libnotify>=0.7.0' 'dbus-glib' 'udev' 'hicolor-icon-theme' 'libgudev' 'lua>=5.4' 'lua<5.5')
makedepends=('cmake')
optdepends=('kmod-roccat: Adds support for the old kone device.')
source=("http://downloads.sourceforge.net/project/roccat/roccat-tools/roccat-tools-$pkgver.tar.bz2"
        'fix-multiple-definitions.patch'
        '90-uinput.rules'
        'uhid.conf')
sha256sums=('6f6766309bace2aece09910912d4a6d8bec61c9b4432f4f3ed388ebf7e16408a'
            '6268347c22392606c1ea3ea265a43607ed708b5428faa87c0ed1f6d776edb80b'
            '097a333b61921698d60f448e66c34c57905d2098aca998d987be782a0e4862ff'
            '0d328038322f62ff1f3319666df5f8f58c0a028415a917ad247b0446c1ff90f5')

prepare() {
  cd "$srcdir/$pkgbase-$pkgver"

  patch -p1 -i ../fix-multiple-definitions.patch
}

build() {
  cd "$srcdir/$pkgbase-$pkgver"

  cmake . \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DUDEVDIR=/usr/lib/udev/rules.d \
    -DWITHOUT_PYTHON=TRUE \
    -DLIBDIR="/usr/lib" \
    -DWITH_LUA="5.4" \
    -DCMAKE_C_FLAGS="$(pkg-config --cflags harfbuzz)" \
    -DCMAKE_MODULE_PATH="/usr/share/libgaminggear/cmake/Modules"
  make
}

package_roccat-tools-common() {
  pkgdesc='ROCCAT tools common files'
  install=roccat-tools.install

  for i in icons sounds libroccat libroccathelper libroccatwidget roccateventhandler; do
    cd $srcdir/$pkgbase-$pkgver/$i
    make DESTDIR="$pkgdir/" install
  done

  cd $srcdir
  install -Dm644 uhid.conf $pkgdir/etc/modules-load.d/uhid.conf
  install -Dm644 90-uinput.rules $pkgdir/usr/lib/udev/rules.d/90-uinput.rules
}

package_roccat-tools-arvo() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Arvo devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/arvo"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-arvo.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-arvo.rules
}

package_roccat-tools-kiro() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Kiro devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/kiro"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-kiro.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-kiro.rules
}

package_roccat-tools-isku() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Isku devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/isku"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-isku.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-isku.rules
}

package_roccat-tools-iskufx() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Isku FX devices'
  depends=('roccat-tools-common' 'roccat-tools-isku')

  cd "$srcdir/$pkgbase-$pkgver/iskufx"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-iskufx.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-iskufx.rules
}

package_roccat-tools-kone() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Kone devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/kone"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-kone.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-kone.rules
}

package_roccat-tools-koneplus() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Kone[+] devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/koneplus"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-koneplus.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-koneplus.rules
}

package_roccat-tools-konepure() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Kone Pure devices'
  depends=('roccat-tools-common' 'roccat-tools-konextd')

  cd "$srcdir/$pkgbase-$pkgver/konepure"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-konepure.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-konepure.rules
}

package_roccat-tools-konepureoptical() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Kone Pure optical devices'
  depends=('roccat-tools-common' 'roccat-tools-konepure')

  cd "$srcdir/$pkgbase-$pkgver/konepureoptical"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-konepureoptical.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-konepureoptical.rules
}

package_roccat-tools-konepuremilitary() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Kone Pure Military devices'
  depends=('roccat-tools-common' 'roccat-tools-konepure')

  cd "$srcdir/$pkgbase-$pkgver/konepuremilitary"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-konepuremilitary.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-konepuremilitary.rules
}

package_roccat-tools-konextd() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Kone XTD devices'
  depends=('roccat-tools-common' 'roccat-tools-koneplus')

  cd "$srcdir/$pkgbase-$pkgver/konextd"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-konextd.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-konextd.rules
}

package_roccat-tools-konextdoptical() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Kone XTD Optical devices'
  depends=('roccat-tools-common' 'roccat-tools-konepuremilitary')

  cd "$srcdir/$pkgbase-$pkgver/konextdoptical"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-konextdoptical.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-konextdoptical.rules
}

package_roccat-tools-kovaplus() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Kova[+] devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/kovaplus"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-kovaplus.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-kovaplus.rules
}

package_roccat-tools-kova2016() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Kova2016 devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/kova2016"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-kova2016.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-kova2016.rules
}

package_roccat-tools-lua() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Lua devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/lua"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-lua.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-lua.rules
}

package_roccat-tools-pyra() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Pyra devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/pyra"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-pyra.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-pyra.rules
}

package_roccat-tools-ryosmk() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT RyosMK devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/ryosmk"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-ryosmk.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-ryosmk.rules
}

package_roccat-tools-ryosmkfx() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT RyosMK FX devices'
  depends=('roccat-tools-common' 'roccat-tools-ryosmk')

  cd "$srcdir/$pkgbase-$pkgver/ryosmkfx"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-ryosmkfx.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-ryosmkfx.rules
}

package_roccat-tools-ryostkl() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT RyosTKL devices'
  depends=('roccat-tools-common' 'roccat-tools-ryosmk')

  cd "$srcdir/$pkgbase-$pkgver/ryostkl"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-ryostkl.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-ryostkl.rules
}

package_roccat-tools-savu() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Savu devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/savu"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-savu.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-savu.rules
}

package_roccat-tools-tyon() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Tyon devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/tyon"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-tyon.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-tyon.rules
}

package_roccat-tools-suora() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Suora devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/suora"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-suora.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-suora.rules
}

package_roccat-tools-skeltr() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Skeltr devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/skeltr"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-skeltr.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-skeltr.rules
}

package_roccat-tools-sova() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Sova devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/sova"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-sova.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-sova.rules
}

package_roccat-tools-nyth() {
  pkgdesc='Userland applications to configure and make extended use of ROCCAT Nyth devices'
  depends=('roccat-tools-common')

  cd "$srcdir/$pkgbase-$pkgver/nyth"
  make DESTDIR="$pkgdir/" install
  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm644 udev/90-roccat-nyth.rules $pkgdir/usr/lib/udev/rules.d/90-roccat-nyth.rules
}
