2010-06-02 20:13:39 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Libplist < Formula
|
2011-05-10 22:14:45 +00:00
|
|
|
homepage 'http://cgit.sukimashita.com/libplist.git/'
|
2013-03-24 01:05:54 +00:00
|
|
|
url 'http://cgit.sukimashita.com/libplist.git/snapshot/libplist-1.10.tar.bz2'
|
|
|
|
sha1 'a642bb37eaa4bec428d0b2a4fa8399d80ee73a18'
|
|
|
|
|
|
|
|
head 'http://git.sukimashita.com/libplist.git'
|
|
|
|
|
|
|
|
option 'with-python', 'Enable Cython Python bindings'
|
2010-06-02 20:13:39 +00:00
|
|
|
|
2010-09-19 17:21:57 +00:00
|
|
|
depends_on 'cmake' => :build
|
2010-06-02 20:13:39 +00:00
|
|
|
|
2013-03-24 01:05:54 +00:00
|
|
|
if build.include? 'with-python'
|
|
|
|
depends_on 'Cython' => :python
|
|
|
|
# Needed to find the Cython executable
|
|
|
|
env :userpaths
|
2011-12-02 03:51:55 +00:00
|
|
|
end
|
|
|
|
|
2010-06-02 20:13:39 +00:00
|
|
|
def install
|
2011-09-12 20:23:34 +00:00
|
|
|
ENV.deparallelize # make fails on an 8-core Mac Pro
|
2010-06-10 17:32:35 +00:00
|
|
|
|
2013-03-24 01:05:54 +00:00
|
|
|
args = std_cmake_args
|
|
|
|
|
|
|
|
# Disable Swig Python bindings
|
|
|
|
args << "-DENABLE_SWIG='OFF'"
|
|
|
|
|
|
|
|
if build.include? 'with-python'
|
|
|
|
## Taken from opencv.rb
|
|
|
|
#
|
|
|
|
# The CMake `FindPythonLibs` Module is dumber than a bag of hammers when
|
|
|
|
# more than one python installation is available---for example, it clings
|
|
|
|
# to the Header folder of the system Python Framework like a drowning
|
|
|
|
# sailor.
|
|
|
|
#
|
|
|
|
# This code was cribbed from the VTK formula and uses the output to
|
|
|
|
# `python-config` to do the job FindPythonLibs should be doing in the first
|
|
|
|
# place.
|
|
|
|
python_prefix = `python-config --prefix`.strip
|
|
|
|
# Python is actually a library. The libpythonX.Y.dylib points to this lib, too.
|
|
|
|
if File.exist? "#{python_prefix}/Python"
|
|
|
|
# Python was compiled with --framework:
|
|
|
|
args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
|
|
|
|
if !MacOS::CLT.installed? and python_prefix.start_with? '/System/Library'
|
|
|
|
# For Xcode-only systems, the headers of system's python are inside of Xcode
|
|
|
|
args << "-DPYTHON_INCLUDE_DIR='#{MacOS.sdk_path}/System/Library/Frameworks/Python.framework/Versions/2.7/Headers'"
|
|
|
|
else
|
|
|
|
args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
|
|
|
|
end
|
|
|
|
else
|
|
|
|
python_lib = "#{python_prefix}/lib/lib#{which_python}"
|
|
|
|
if File.exists? "#{python_lib}.a"
|
|
|
|
args << "-DPYTHON_LIBRARY='#{python_lib}.a'"
|
|
|
|
else
|
|
|
|
args << "-DPYTHON_LIBRARY='#{python_lib}.dylib'"
|
|
|
|
end
|
|
|
|
args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/include/#{which_python}'"
|
|
|
|
end
|
|
|
|
else
|
|
|
|
# Also disable Cython Python bindings if we're not building with '--python'
|
|
|
|
args << "-DENABLE_CYTHON='OFF'"
|
|
|
|
end
|
|
|
|
|
|
|
|
system "cmake", ".", "-DCMAKE_INSTALL_NAME_DIR=#{lib}", *args
|
|
|
|
system "make install"
|
2010-06-02 20:13:39 +00:00
|
|
|
end
|
2011-12-02 03:51:55 +00:00
|
|
|
|
2013-03-24 01:05:54 +00:00
|
|
|
def caveats
|
|
|
|
if build.include? 'with-python'
|
|
|
|
<<-EOS.undent
|
|
|
|
To use the Python bindings with non-homebrew Python, you need to amend your
|
|
|
|
PYTHONPATH like so:
|
|
|
|
export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
2012-02-24 01:09:37 +00:00
|
|
|
|
2013-03-24 01:05:54 +00:00
|
|
|
def which_python
|
|
|
|
"python" + `python -c 'import sys;print(sys.version[:3])'`.strip
|
|
|
|
end
|
|
|
|
end
|