[buildout]

extends =
  ../pkgconfig/buildout.cfg
  ../autoconf/buildout.cfg
  ../automake/buildout.cfg
  ../jbigkit/buildout.cfg
  ../leptonica/buildout.cfg
  ../libpng/buildout.cfg
  ../libtool/buildout.cfg
  ../patch/buildout.cfg
  ../webp/buildout.cfg
  
parts =
  tesseract
  tesseract-traineddata
  tesseract-eng-traineddata
  tesseract-osd-traineddata

[tesseract]
recipe = slapos.recipe.cmmi
url = https://github.com/tesseract-ocr/tesseract/archive/6b250b58121a9858d3e3019a78a6f7d421bd0fc7.tar.gz
md5sum = fdc38148ad8eb1bd0485a217503dd6d5
pkg_config_depends = ${leptonica:location}/lib/pkgconfig:${fontconfig:location}/lib/pkgconfig:${fontconfig:pkg_config_depends}:${lcms2:location}/lib/pkgconfig:${xz-utils:location}/lib/pkgconfig
pre-configure =
  aclocal -I${pkgconfig:location}/share/aclocal -I${libtool:location}/share/aclocal
  ./autogen.sh
  autoreconf -ivf
  autoconf -Wno-portability

configure-options =
  --disable-static
  --datarootdir=${tesseract-traineddata:location}
# XXX: tesseract seems not easily configurable at runtime about where to find
# its trained data, so we set its datarootdir above to a controlled location

# tesseract has a non-standard way of testing for leptonica, hence the
# LIBLEPT_HEADERSDIR entry below:
environment =
  PATH=${pkgconfig:location}/bin:${autoconf:location}/bin:${automake:location}/bin:${libtool:location}/bin:${m4:location}/bin:${patch:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${:pkg_config_depends}
  ACLOCAL_ARGS=-I${libtool:location}/share/aclocal
  ACLOCAL_PATH=${pkgconfig:location}/share/aclocal:${libtool:location}/share/aclocal
  LIBLEPT_HEADERSDIR=${leptonica:location}/include
  CPPFLAGS=-I${leptonica:location}/include
  LDFLAGS =-L${leptonica:location}/lib -Wl,-rpath=${leptonica:location}/lib -L${jbigkit:location}/lib -Wl,-rpath=${jbigkit:location}/lib -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib

make-options =
  LIBTOOL=${libtool:location}/bin/libtool

[tesseract-traineddata]
location = ${buildout:parts-directory}/${:_buildout_section_name_}

[tesseract-eng-traineddata]
recipe = slapos.recipe.build:download
destination = ${tesseract-traineddata:location}/tessdata/eng.traineddata
url = https://github.com/tesseract-ocr/tessdata/raw/590567f20dc044f6948a8e2c61afc714c360ad0e/eng.traineddata
md5sum = 57e0df3d84fed9fbf8c7a8e589f8f012

[tesseract-osd-traineddata]
recipe = slapos.recipe.build:download
destination = ${tesseract-traineddata:location}/tessdata/osd.traineddata
url = https://github.com/tesseract-ocr/tessdata/raw/590567f20dc044f6948a8e2c61afc714c360ad0e/osd.traineddata
md5sum = 7611737524efd1ce2dde67eff629bbcf

