class Xapian < Formula desc "C++ search engine library with many bindings" homepage "https://xapian.org/" url "https://oligarchy.co.uk/xapian/1.4.4/xapian-core-1.4.4.tar.xz" mirror "https://mirrors.ocf.berkeley.edu/debian/pool/main/x/xapian-core/xapian-core_1.4.4.orig.tar.xz" sha256 "a6a985a9841a452d75cf2169196b7ca6ebeef27da7c607078cd401ad041732d9" bottle do cellar :any sha256 "64d3ed3134ee473320c7a4c8905bf3d9945d5b83dcf4c0c81ccc5c5870e4ca54" => :sierra sha256 "d605eeb62d6795a27ad32becd86183e97a90eb45ba20e179a38c9da5b9a149ca" => :el_capitan sha256 "d821b58b62471fe144261b1915f7702efa97852f91bffb1e0ee33e315c55940c" => :yosemite end option "with-java", "Java bindings" option "with-php", "PHP bindings" option "with-ruby", "Ruby bindings" deprecated_option "java" => "with-java" deprecated_option "php" => "with-php" deprecated_option "ruby" => "with-ruby" depends_on :ruby => ["2.1", :optional] depends_on :python => :optional depends_on "sphinx-doc" => :build if build.with?("python") skip_clean :la resource "bindings" do url "https://oligarchy.co.uk/xapian/1.4.4/xapian-bindings-1.4.4.tar.xz" sha256 "3b323eac41c42750b7dacc9319b1477a7c1b552c95f590127643dee3b44d8a39" end def install build_binds = build.with?("ruby") || build.with?("python") || build.with?("java") || build.with?("php") system "./configure", "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}" system "make", "install" if build_binds resource("bindings").stage do ENV["XAPIAN_CONFIG"] = bin/"xapian-config" args = %W[ --disable-dependency-tracking --prefix=#{prefix} ] args << "--with-java" if build.with? "java" if build.with? "ruby" ruby_site = lib/"ruby/site_ruby" ENV["RUBY_LIB"] = ENV["RUBY_LIB_ARCH"] = ruby_site args << "--with-ruby" end if build.with? "python" # https://github.com/Homebrew/homebrew-core/issues/2422 ENV.delete("PYTHONDONTWRITEBYTECODE") (lib/"python2.7/site-packages").mkpath ENV["PYTHON_LIB"] = lib/"python2.7/site-packages" # configure looks for python2 and system python doesn't install one ENV["PYTHON"] = which "python" ENV.append_path "PYTHONPATH", Formula["sphinx-doc"].opt_libexec/"lib/python2.7/site-packages" ENV.append_path "PYTHONPATH", Formula["sphinx-doc"].opt_libexec/"vendor/lib/python2.7/site-packages" args << "--with-python" end if build.with? "php" extension_dir = lib/"php/extensions" extension_dir.mkpath args << "--with-php" << "PHP_EXTENSION_DIR=#{extension_dir}" end system "./configure", *args system "make", "install" end end end def caveats if build.with? "ruby" <<-EOS.undent You may need to add the Ruby bindings to your RUBYLIB from: #{HOMEBREW_PREFIX}/lib/ruby/site_ruby EOS end end test do system bin/"xapian-config", "--libs" end end