# 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=1
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)
sha1sums=('02092890205891b6de5a699294485a1eedba46c5'
          '4342b004eb53d51fcbb9af2cf136bb4990874608'
          '5cd3f206e6e60632d9bea2ce9d22dbe5283eb129')

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/}
}
