homebrew-core/Formula/tesseract.rb
2016-01-20 16:36:06 +00:00

101 lines
3.1 KiB
Ruby

class Tesseract < Formula
desc "OCR (Optical Character Recognition) engine"
homepage "https://github.com/tesseract-ocr/"
url "https://github.com/tesseract-ocr/tesseract/archive/3.04.00.tar.gz"
sha256 "7e6e48b625e1fba9bc825a4ef8c39f12c60aae1084939133b3c6a00f8f8dc38c"
bottle do
revision 1
sha256 "07ec3efaa3a9aa56bdb9b2af470e306af9bb6bb093f110ff2df81b8934459230" => :el_capitan
sha256 "905b27b4bdba1fe61157c8f75aa44cbc1b7f6fe4c51800a7070dbca760163a65" => :yosemite
sha256 "722d846bdfe713b5ffd96e2ae77387d6fa10f13dd3d56aac54be2da2206f5a4e" => :mavericks
end
head do
url "https://github.com/tesseract-ocr/tesseract.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
resource "tessdata-head" do
url "https://github.com/tesseract-ocr/tessdata.git"
end
end
option "with-all-languages", "Install recognition data for all languages"
option "with-training-tools", "Install OCR training tools"
option "with-opencl", "Enable OpenCL support"
deprecated_option "all-languages" => "with-all-languages"
depends_on "leptonica"
depends_on "libtiff" => :recommended
if build.with? "training-tools"
depends_on "libtool" => :build
depends_on "icu4c"
depends_on "glib"
depends_on "cairo"
depends_on "pango"
depends_on :x11
end
needs :cxx11
fails_with :llvm do
build 2206
cause "Executable 'tesseract' segfaults on 10.6 when compiled with llvm-gcc"
end
resource "tessdata" do
url "https://github.com/tesseract-ocr/tessdata/archive/3.04.00.tar.gz"
sha256 "5dcb37198336b6953843b461ee535df1401b41008d550fc9e43d0edabca7adb1"
end
resource "eng" do
url "https://github.com/tesseract-ocr/tessdata/raw/3.04.00/eng.traineddata"
sha256 "c0515c9f1e0c79e1069fcc05c2b2f6a6841fb5e1082d695db160333c1154f06d"
end
resource "osd" do
url "https://github.com/tesseract-ocr/tessdata/raw/3.04.00/osd.traineddata"
sha256 "9cf5d576fcc47564f11265841e5ca839001e7e6f38ff7f7aacf46d15a96b00ff"
end
def install
# explicitly state leptonica header location, as the makefile defaults to /usr/local/include,
# which doesn't work for non-default homebrew location
ENV["LIBLEPT_HEADERSDIR"] = HOMEBREW_PREFIX/"include"
ENV.cxx11
system "./autogen.sh" if build.head?
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
]
args << "--enable-opencl" if build.with? "opencl"
system "./configure", *args
system "make", "install"
if build.with? "training-tools"
system "make", "training"
system "make", "training-install"
end
if build.head?
resource("tessdata-head").stage { mv Dir["*"], share/"tessdata" }
elsif build.with? "all-languages"
resource("tessdata").stage { mv Dir["*"], share/"tessdata" }
else
resource("eng").stage { mv "eng.traineddata", share/"tessdata" }
resource("osd").stage { mv "osd.traineddata", share/"tessdata" }
end
end
test do
assert_match version.to_s, shell_output("#{bin}/tesseract -v 2>&1")
end
end