f6e80bdea2
New `depends_on :python` Dependency. New `depends_on :python3` Dependency. To avoid having multiple formulae with endings -py2 and -py3, we will handle support for different pythons (2.x vs. 3.x) in the same formula. Further brewed vs. external python will be transparently supported. The formula also gets a new object `python`, which is false if no Python is available or the user has disabled it. Otherwise it is defined and provides several support methods: python.site_packages # the site-packages in the formula's Cellar python.global_site_packages python.binary # the full path to the python binary python.prefix python.version python.version.major python.version.minor python.xy # => e.g. "python2.7" python.incdir # includes of python python.libdir # the python dylib library python.pkg_config_path # used internally by brew python.from_osx? python.framework? python.universal? python.pypy? python.standard_caveats # Text to set PYTHONPATH for python.from_osx? python.if3then3 # => "" for 2.x and to "3" for 3.x. Further, to avoid code duplication, `python` takes an optional block that is run twice if the formula defines depends_on :python AND :python3. python do system python, 'setup.py', "--prefix=#{prefix}" end Read more in the Homebrew wiki.
87 lines
2.1 KiB
Ruby
87 lines
2.1 KiB
Ruby
require 'formula'
|
|
|
|
class XapianBindings < Formula
|
|
homepage 'http://xapian.org'
|
|
url 'http://oligarchy.co.uk/xapian/1.2.13/xapian-bindings-1.2.13.tar.gz'
|
|
sha1 '0cffc6ae2df295d2f8bc052831ed225e60236e92'
|
|
end
|
|
|
|
class Xapian < Formula
|
|
homepage 'http://xapian.org'
|
|
url 'http://oligarchy.co.uk/xapian/1.2.13/xapian-core-1.2.13.tar.gz'
|
|
sha1 'ae5edc64671c5f32a3a24abf8cc3028cb56f6c6b'
|
|
|
|
option "java", "Java bindings"
|
|
option "php", "PHP bindings"
|
|
option "ruby", "Ruby bindings"
|
|
|
|
depends_on :python => :optional
|
|
|
|
skip_clean :la
|
|
|
|
def build_any_bindings?
|
|
build.include? 'ruby' or build.with? 'python' or build.include? 'java' or build.include? 'php'
|
|
end
|
|
|
|
def install
|
|
system "./configure", "--disable-dependency-tracking",
|
|
"--prefix=#{prefix}"
|
|
system "make install"
|
|
return unless build_any_bindings?
|
|
|
|
XapianBindings.new.brew do
|
|
args = %W[
|
|
--disable-dependency-tracking
|
|
--prefix=#{prefix}
|
|
XAPIAN_CONFIG=#{bin}/xapian-config
|
|
--without-csharp
|
|
--without-tcl
|
|
]
|
|
|
|
if build.include? 'java'
|
|
args << '--with-java'
|
|
else
|
|
args << '--without-java'
|
|
end
|
|
|
|
if build.include? 'ruby'
|
|
ruby_site = lib+'ruby/site_ruby'
|
|
ENV['RUBY_LIB'] = ENV['RUBY_LIB_ARCH'] = ruby_site
|
|
args << '--with-ruby'
|
|
else
|
|
args << '--without-ruby'
|
|
end
|
|
|
|
if build.with? 'python'
|
|
ENV['PYTHON_LIB'] = python.site_packages
|
|
args << "--with-python"
|
|
else
|
|
args << "--without-python"
|
|
end
|
|
|
|
if build.include? 'php'
|
|
extension_dir = lib+'php/extensions'
|
|
extension_dir.mkpath
|
|
args << "--with-php" << "PHP_EXTENSION_DIR=#{extension_dir}"
|
|
else
|
|
args << "--without-php"
|
|
end
|
|
system "./configure", *args
|
|
system "make install"
|
|
end
|
|
end
|
|
|
|
def caveats
|
|
s = ''
|
|
s += python.standard_caveats if python
|
|
if build.include? 'ruby'
|
|
s += <<-EOS.undent
|
|
You may need to add the Ruby bindings to your RUBYLIB from:
|
|
#{HOMEBREW_PREFIX}/lib/ruby/site_ruby
|
|
|
|
EOS
|
|
end
|
|
return s.empty? ? nil : s
|
|
end
|
|
|
|
end
|