#Packager: Dimitris Tzemos <dijemos~at~gmail~dot~com>

pkgname=brltty
pkgver=5.5
pkgrel=2dj
source=("http://mielke.cc/brltty/archive/brltty-$pkgver.tar.xz" "rc.brltty")
sourcetemplate=http://people.salixos.org/djemos/salix/$pkgname
docs=("README" "Documents/{Manual-*,TODO,CONTRIBUTORS,HISTORY,README.*}")
url="http://mielke.cc/brltty"
options=('noautodotnew')
dotnew=(etc/rc.d/rc.brltty)

slackdesc=\
(
 #|-----handy-ruler------------------------------------------------------|
"brltty (Braille display daemon)"
"BRLTTY is a daemon which provides access to the Linux console (text"
"mode) for a blind person using a soft braille display.  It drives the"
"braille terminal and provides complete screen review functionality."
"After installation, brltty will be started at boot time. If you "
"don't want that, make non-executable the script /etc/rc.d/rc.brltty"
"To configure brltty, run /usr/sbin/bp2cf or edit /etc/brltty.conf"
)

build() {
cd $startdir/src/$pkgname-$pkgver || return 1

#Remove the unneeded DOS/Windows stuff.
rm -rf DOS Windows || return 1

sh autogen

./configure \
  --prefix=/usr \
  --bindir=/bin \
  --sbindir=/sbin \
  --libdir=/lib${LIBDIRSUFFIX} \
  --infodir=/usr/info \
  --mandir=/usr/man \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --disable-java-bindings \
  --build=$arch-slackware-linux
  
make -j2 || exit 1
make install INSTALL_ROOT=$PKG || exit 1
chmod 755 $PKG/bin/* $PKG/lib${LIBDIRSUFFIX}/brltty/* || return 1

mkdir -p $PKG/usr/doc/brltty-$pkgver || return 1
cp -a \
  $startdir/src/$pkgname-$pkgver/Documents/{Manual-*,TODO,CONTRIBUTORS,HISTORY,README.*} \
  $PKG/usr/doc/brltty-$pkgver || return 1
cat $startdir/src/$pkgname-$pkgver/Documents/ChangeLog | head -n 150 > $PKG/usr/doc/brltty-$pkgver/ChangeLog || return 1
( cd $PKG/usr/doc/brltty-$pkgver
  find . -name "Makefile*" -exec rm -f {} \;
  find . -name "*.sgml" -exec rm -f {} \;
  find . -size 0 -type f -exec rm -f {} \;
)

# If there's a ChangeLog, installing at least part of the recent history
# is useful, but don't let it get totally out of control:
if [ -r $startdir/src/$pkgname-$pkgver/Documents/ChangeLog ]; then
  DOCSDIR=$(echo $PKG/usr/doc/$pkgname-$pkgver)
  cat $startdir/src/$pkgname-$pkgver/Documents/ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog || return 1
  touch -r $startdir/src/$pkgname-$pkgver/Documents/ChangeLog $DOCSDIR/ChangeLog || return 1
fi

mkdir -p $PKG/etc || return 1
cp -a $startdir/src/$pkgname-$pkgver/Documents/brltty.conf $PKG/etc/brltty.conf.new || return 1
mkdir -p $PKG/etc/rc.d || return 1
cp -a $SRC/rc.brltty $PKG/etc/rc.d/ || return 1

}
