SUMMARY="An OCR Engine that was developed at HP and now at Google"
DESCRIPTION="
An OCR Engine that was developed at HP Labs between 1985 and 1995... and \
now at Google.
Tesseract is probably the most accurate open source OCR engine available. \
Combined with the Leptonica Image Processing Library it can read a wide \
variety of image formats and convert them to text in over 60 languages. \
It was one of the top 3 engines in the 1995 UNLV Accuracy test. Between \
1995 and 2006 it had little work done on it, but since then it has been \
improved extensively by Google. It is released under the Apache License \
2.0."
HOMEPAGE="https://github.com/tesseract-ocr/"
COPYRIGHT="1985-1995 HP labs
	2012 Google Inc."
LICENSE="Apache v2"
REVISION="2"
SOURCE_URI="https://github.com/tesseract-ocr/tesseract/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="494d64ffa7069498a97b909a0e65a35a213989e0184f1ea15332933a90d43445"
PATCHES="tesseract-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

libVersion="3.0.5"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	tesseract$secondaryArchSuffix = $portVersion
	vendor_tesseract = $portVersion
	cmd:ambiguous_words$secondaryArchSuffix = $portVersion
	cmd:classifier_tester$secondaryArchSuffix = $portVersion
	cmd:cntraining$secondaryArchSuffix = $portVersion
	cmd:combine_tessdata$secondaryArchSuffix = $portVersion
	cmd:dawg2wordlist$secondaryArchSuffix = $portVersion
	cmd:mftraining$secondaryArchSuffix = $portVersion
	cmd:shapeclustering$secondaryArchSuffix = $portVersion
	cmd:tesseract$secondaryArchSuffix = $portVersion
	cmd:unicharset_extractor$secondaryArchSuffix = $portVersion
	cmd:wordlist2dawg$secondaryArchSuffix = $portVersion
	lib:libtesseract$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	tesseract_data_eng
	lib:libgif$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:liblept$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libwebp$secondaryArchSuffix
	lib:libz$secondaryArchSuffix"

PROVIDES_devel="
	tesseract${secondaryArchSuffix}_devel = $portVersion
	devel:libtesseract$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	tesseract$secondaryArchSuffix == $portVersion base
	devel:liblept$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgif$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:liblept$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libwebp$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:awk
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage tesseract$secondaryArchSuffix \
	$libDir/libtesseract.so.$libVersion

BUILD()
{
	autogen.sh
	export LEPTONICA_CFLAGS=-I$(finddir B_SYSTEM_HEADERS_DIRECTORY)${secondaryArchSubDir}/leptonica
	export TESSDATA_PREFIX=$dataDir/tessdata
	runConfigure configure
	make $jobArgs
}

INSTALL()
{
	make install

	#remove libtool file
	rm -f $libDir/*.la

	prepareInstalledDevelLibs libtesseract
	fixPkgconfig

	# devel package
	packageEntries devel $developDir
}
