# Maintainer: David Runge <dave@sleepmap.de>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>

pkgname=brltty
pkgver=6.0
pkgrel=3
pkgdesc="Braille display driver for Linux/Unix"
arch=('x86_64')
url="https://brltty.app"
license=('LGPL2.1')
depends=('gpm' 'icu' 'liblouis' 'tcl')
makedepends=('at-spi2-core' 'bluez-libs' 'cython' 'espeak' 'java-environment'
'libxaw' 'ocaml-ctypes' 'ocaml-findlib' 'polkit' 'speech-dispatcher')
optdepends=('at-spi2-core: X11/GNOME Apps accessibility'
            'atk: ATK bridge for X11/GNOME accessibility'
            'bluez-libs: bluetooth support'
            'espeak: espeak driver'
            'java-runtime: Java support'
            'libxaw: X11 support'
            'ocaml: OCaml support'
            'polkit: PolicyKit support'
            'python: Python support'
            'speech-dispatcher: speech-dispatcher driver')
backup=(etc/brltty.conf)
options=('!emptydirs')
install=brltty.install
source=("https://brltty.app/archive/${pkgname}-${pkgver}.tar.bz2"
        "${pkgname}.service"
        "${pkgname}.tmpfiles"
        "${pkgname}.sysusers")
sha512sums=('b114cb55916109ddeb472df1e5d206c27e93cab64c4b51f82cf0887f63f6fa90064230f769302b1ba9ba7259079026a83e7b7ed46ba20a40676a487df317902e'
            '5da854db7612b7fcc1f1a8da0825e19509158041ceedbefc7649d220fd94a17c11044985abfc435b65a8b795c19dd2d16ff05f59641e57805f710b76570a5af4'
            'a530fe66983768f9dc544af01c586abc101dfa2ed76885b4f1fd78c483b59e8445f2c0dbbfb865dd1cf2874342c346bd35ce978ab246e9cdd31d2d489a14e770'
            'cc2e2d5f33d4e11d6ff828aefc0773ccdc02127ce2f00649c1e3f8d4b39b90789f4a0e41385b344f850c38bd4a1df36d3d9d413a59144d431defdd343633f800')

build() {
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr \
              --sysconfdir=/etc \
              --localstatedir=/var \
              --mandir=/usr/share/man \
              --with-tables-directory=/usr/share/brltty \
              --with-screen-driver=lx \
              --enable-gpm
  make
}

package() {
  cd "${pkgname}-${pkgver}"
  make INSTALL_ROOT="${pkgdir}" install
  install -vDm 644 "Documents/${pkgname}.conf" -t "${pkgdir}/etc/"
  install -vDm 644 "../${pkgname}.service" \
    -t "${pkgdir}/usr/lib/systemd/system/"
  install -vDm 644 "../${pkgname}.sysusers" \
    "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
  install -vDm 644 "../${pkgname}.tmpfiles" \
    "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf"
}
