# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Paul Mattal <paul@archlinux.org>

pkgname=lirc
_pkgver=0.10.2
[[ $_pkgver =~ [a-z]$ ]] && pkgver="${_pkgver:0:-1}.${_pkgver: -1}" || pkgver="$_pkgver"
pkgrel=2
epoch=1
pkgdesc="Linux Infrared Remote Control utilities"
arch=('x86_64')
url="https://www.lirc.org/"
license=('GPL')
depends=('alsa-lib' 'libx11' 'libftdi' 'libusb-compat')
makedepends=('help2man' 'alsa-lib' 'libx11' 'libxslt' 'python' 'python-setuptools'
             'python-yaml' 'systemd')
optdepends=('python: for lirc-setup, irdb-get and pronto2lirc'
            'python-gobject: for lirc-setup and irdb-get'
            'python-yaml: for lirc-setup and irdb-get')
provides=('lirc-utils')
conflicts=('lirc-utils')
replaces=('lirc-utils')
backup=('etc/lirc/lirc_options.conf' 'etc/lirc/lircd.conf' 'etc/lirc/lircmd.conf')
source=("https://prdownloads.sourceforge.net/${pkgname}/${pkgname}-${_pkgver}.tar.bz2"
        lirc.logrotate
        lirc.tmpfiles)
sha256sums=('3d44ec8274881cf262f160805641f0827ffcc20ade0d85e7e6f3b90e0d3d222a'
            'bd13ca00e30d85ff9166c03b8f7a20195ef89794e66d7e54f04ba1d014a73e7d'
            'b8eb6ff2a542a9a3b20fe259fe36aece941db8d309598d2eeb1815b779e2f838')

build() {
  cd lirc-${_pkgver}

  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --enable-devinput \
    --enable-uinput
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd lirc-${_pkgver}

  make DESTDIR="${pkgdir}" install

  install -Dm644 "${srcdir}"/lirc.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/lirc.conf
  install -Dm644 "${srcdir}"/lirc.logrotate "${pkgdir}"/etc/logrotate.d/lirc

  rmdir "${pkgdir}"/var/{run/lirc/,run/}
}
