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="http://code.google.com/p/tesseract-ocr"
LICENSE="Apache v2"
COPYRIGHT="1985-1995 HP labs
	2012 Google Inc."
SOURCE_URI="https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz"
CHECKSUM_SHA256="26cd39cb3f2a6f6f1bf4050d1cc0aae35edee49eb49a92df3cb7f9487caa013d"
REVISION="1"

ARCHITECTURES="x86 x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	# x86_gcc2 is fine as primary target architecture as long as we're building
	# for a different secondary architecture.
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
else
	ARCHITECTURES="$ARCHITECTURES !x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	tesseract$secondaryArchSuffix = $portVersion
	lib:libtesseract$secondaryArchSuffix = $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
	"
PROVIDES_devel="
	tesseract${secondaryArchSuffix}_devel = $portVersion
	devel:libtesseract$secondaryArchSuffix = $portVersion
	"

REQUIRES_devel="
	tesseract$secondaryArchSuffix == $portVersion
	"

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgcc_s$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	lib:liblept$secondaryArchSuffix
	lib:libgif$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng$secondaryArchSuffix
	lib:libwebp$secondaryArchSuffix
	lib:libz$secondaryArchSuffix"

BUILD_REQUIRES="
	devel:liblept$secondaryArchSuffix
	devel:libgif$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng$secondaryArchSuffix
	devel:libwebp$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:aclocal
	cmd:autoconf
	cmd:awk
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	"
SOURCE_DIR="tesseract-ocr"

PATCHES="tesseract-3.02.02.patch"

PATCH()
{
	sed -i 's,AM_CONFIG_HEADER,AC_CONFIG_HEADERS,g' configure.ac
}

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

INSTALL()
{
	make install
	
	prepareInstalledDevelLibs libtesseract
	fixPkgconfig
	
	# devel package
	packageEntries devel $developDir
}

TEST()
{
	make test
	make check
}
