homebrew-core/Formula/leptonica.rb
2016-12-30 13:03:07 +01:00

58 lines
1.7 KiB
Ruby

class Leptonica < Formula
desc "Image processing and image analysis library"
homepage "http://www.leptonica.org/"
url "http://www.leptonica.org/source/leptonica-1.74.tar.gz"
sha256 "e170f8a3f79e7f1742aff975ad5bb0c4a124df1532e6e38d9d71aaa5111de5a2"
bottle do
cellar :any
sha256 "2acf4703688924d8ecc79a427ce7c0c0d9dddcd697a4336fac6a58af6b384538" => :sierra
sha256 "9cb6424ce52d45c6f4183bce9dcf722e423a07183053729ce41bd8ca8f784004" => :el_capitan
sha256 "a09aa53e816bd9cc4e9419db1abe2a5bd75ae4b280e8b32d9ac429f50d3519fe" => :yosemite
end
depends_on "libpng" => :recommended
depends_on "jpeg" => :recommended
depends_on "libtiff" => :recommended
depends_on "giflib" => :optional
depends_on "openjpeg" => :optional
depends_on "webp" => :optional
depends_on "pkg-config" => :build
conflicts_with "osxutils",
:because => "both leptonica and osxutils ship a `fileinfo` executable."
def install
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
]
%w[libpng jpeg libtiff giflib].each do |dep|
args << "--without-#{dep}" if build.without?(dep)
end
%w[openjpeg webp].each do |dep|
args << "--with-lib#{dep}" if build.with?(dep)
args << "--without-lib#{dep}" if build.without?(dep)
end
system "./configure", *args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<-EOS
#include <iostream>
#include <leptonica/allheaders.h>
int main(int argc, char **argv) {
std::fprintf(stdout, "%d.%d", LIBLEPT_MAJOR_VERSION, LIBLEPT_MINOR_VERSION);
return 0;
}
EOS
flags = ["-I#{include}/leptonica"] + ENV.cflags.to_s.split
system ENV.cxx, "test.cpp", *flags
assert_equal version.to_s, `./a.out`
end
end