# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Andreas Hauser <andy-aur@splashground.de>

# Modified and included in Slint by Didier Spaier didieratslintdotfr

pkgname=tesseract
pkgver=5.3.0
pkgrel=1slint
slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (Tesseract Open Source OCR Engine)"
"This package contains an OCR engine - libtesseract and a command line"
"program - tesseract. Tesseract 4 adds a new neural net (LSTM) based "
"OCR engine which is focused on line recognition, but also still"
"supports the legacy Tesseract OCR engine of Tesseract 3 which works by"
"recognizing character patterns."
"Tesseract has unicode (UTF-8) support, and can recognize more than 100"
"languages \"out of the box\". It supports various output formats:"
"plain text, hOCR (HTML), PDF, invisible-text-only PDF, TSV." 
"The lead developer is Ray Smith. The maintainer is Zdenko Podobny."
)

# url="https://github.com/tesseract-ocr/tesseract"

source=(https://github.com/tesseract-ocr/tesseract/archive/$pkgver.tar.gz
        https://github.com/tesseract-ocr/tessdata/raw/bf82613055ebc6e63d9e3b438a5c234bfd638c93/osd.traineddata
        tesseract.1.asc)
docs=(AUTHORS COPYING LICENSE ChangeLog)
build() {
  cd $SRC/${pkgname}-$pkgver
  cp -f $SRC/tesseract.1.asc doc/
  [ -x configure ] || ./autogen.sh
  [ -f Makefile ] || ./configure --prefix=/usr --libdir=/usr/lib64
  make
  make training
  make DESTDIR=$PKG install
  make DESTDIR=$PKG training-install
  rm -f $PKG/usr/lib*/*.la
  mkdir -p $PKG/usr/share/tessdata
  install -Dm0644 $SRC/osd.traineddata $PKG/usr/share/tessdata/osd.traineddata
  mkdir -p $PKG/usr/doc/${pkgname}-$pkgver
  pandoc -s -f gfm README.md -o $PKG/usr/doc/${pkgname}-$pkgver/README.html
}
