# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: Mateusz Herych <heniekk@gmail.com>
# Contributor: Charles Lindsay <charles@chaoslizard.org>

pkgname=cdemu-daemon
pkgver=3.2.5
pkgrel=1
pkgdesc="CD/DVD-ROM device emulator daemon"
arch=(x86_64)
url="https://cdemu.sourceforge.io/"
license=(GPL)
depends=(dbus VHBA-MODULE libao 'libmirage>=3.2.0')
makedepends=(cmake intltool)
optdepends=('alsa-lib: to enable the ALSA audio driver'
            'pulseaudio: to enable the PA audio driver')
install=cdemu-daemon.install
source=("https://downloads.sourceforge.net/cdemu/$pkgname/$pkgname-$pkgver.tar.xz")
sha256sums=('8d1053b195e8f9040c5628340740aa9bbfdd4891bac06fbc5eb5cd4ec376e699')

prepare() {
  cd $pkgname-$pkgver
}

build() {
  cmake -S $pkgname-$pkgver -B build \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -Dt "$pkgdir/usr/share/doc/$pkgname" -m644 $pkgname-$pkgver/README
  install -Dt "$pkgdir/usr/lib/systemd/user" -m644 \
    $pkgname-$pkgver/service-example/cdemu-daemon.service
  install -Dt "$pkgdir/usr/share/dbus-1/services" -m644 \
    $pkgname-$pkgver/service-example/net.sf.cdemu.CDEmuDaemon.service
  echo vhba | install -Dm644 /dev/stdin "$pkgdir/usr/lib/modules-load.d/cdemu.conf"
}

# vim:set sw=2 et:
