# Packaged by Didier Spaier <didier~at~slint~dot~fr>

pkgname=$(pwd|sed "s,.*/,,")
export srcver=6.2.0
pkgver=$(echo $srcver|sed "s/-/_/g")
pkgrel=slint
source=("http://www.jlemmens.nl/homepage/${pkgname}-${srcver}.tar.gz" \
)
# website: http://www.jlemmens.nl/
docs=("copying" "license" "readme" "compile" "Changelog")
options=("nosrcpack")

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (Read eBooks with Linux using a speech-synthesizer)"
"eBook-speaker reads an eBook and uses a speech synthisizer for output."
"eBook-speaker reads the EPUB format. If the given file is not an"
"EPUB it will be converted using several tools like calibre, lowriter,"
"pandoc, pdftotext, scanimage, pnmflip, unrtf or tesseract."
"(http://en.wikipedia.org/wiki/Comparison_of_e-book_formats)"
"eBook-speaker can use any TTS (Text-To_speech) tool, as long as the"
"TTS can read the text from a file and writes the audio to a .wav file."
"The file ~/.eBook-speaker.xml contains TTS tools to use."
"Author: Joss Lemmens"
)
build() {
  cd $SRC/$pkgname-$srcver || return 1
#  patch -p1 --verbose < $startdir/change_TTS_initial_setup_and_remove_add_TTS_dialog.diff || exit 1
  ./configure \
  --prefix=/usr
  make
  make install DESTDIR=$PKG
  mkdir -p $PKG/usr/doc/${pkgname}-$pkgver
  cp doc/Changelog $PKG/usr/doc/${pkgname}-$pkgver
  (cd $SRC/${pkgname}-$srcver/doc/
  cp ebook-speaker.png \
  ebook-speaker.html \
  ebook-speaker.txt \
  ebook-speaker.svg \
  ebook-speaker.menu \
  icons_copyright.txt \
  screenshot.html \
  COMPILE \
  COPYING \
  TODO \
    $PKG/usr/doc/${pkgname}-$pkgver/
  cp $PKG/usr/share/doc/$pkgname/* $PKG/usr/doc/${pkgname}-$pkgver/
  rm -r $PKG/usr/share/doc/
  )
 ( cd $PKG
  for i in $(find -name "eBook*"); do
	( cd $(dirname $i)
	rename eBook ebook *
	)
   done
  )
  mv $PKG/usr/bin/ebook-speaker $PKG/usr/bin/eBook-speaker
  echo 'LC_ALL=$LANG eBook-speaker $*' > $PKG/usr/bin/ebook-speaker
  chmod 0755 $PKG/usr/bin/ebook-speaker
}
