2009-12-26 14:11:03 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2013-06-19 19:19:50 +00:00
|
|
|
# Reference: https://github.com/b4winckler/macvim/wiki/building
|
2011-03-10 05:11:03 +00:00
|
|
|
class Macvim < Formula
|
2011-03-13 19:34:21 +00:00
|
|
|
homepage 'http://code.google.com/p/macvim/'
|
2014-04-25 20:15:46 +00:00
|
|
|
url 'https://github.com/b4winckler/macvim/archive/snapshot-73.tar.gz'
|
|
|
|
version '7.4-73'
|
|
|
|
sha1 'b87e37fecb305a99bc268becca39f8854e3ff9f0'
|
2013-07-12 16:00:37 +00:00
|
|
|
|
2011-05-27 05:02:55 +00:00
|
|
|
head 'https://github.com/b4winckler/macvim.git', :branch => 'master'
|
2009-12-26 14:11:03 +00:00
|
|
|
|
2012-08-09 23:28:35 +00:00
|
|
|
option "custom-icons", "Try to generate custom document icons"
|
|
|
|
option "override-system-vim", "Override system vim"
|
|
|
|
|
2014-05-30 20:41:18 +00:00
|
|
|
depends_on :xcode => :build
|
2013-05-08 22:17:54 +00:00
|
|
|
depends_on 'cscope' => :recommended
|
2013-05-06 18:41:17 +00:00
|
|
|
depends_on 'lua' => :optional
|
2013-09-03 15:50:51 +00:00
|
|
|
depends_on 'luajit' => :optional
|
2013-01-21 09:33:56 +00:00
|
|
|
depends_on :python => :recommended
|
2013-08-26 01:30:16 +00:00
|
|
|
depends_on :python3 => :optional
|
2010-11-26 19:20:24 +00:00
|
|
|
|
2013-08-23 03:57:50 +00:00
|
|
|
env :std if MacOS.version <= :snow_leopard
|
|
|
|
# Help us! We'd like to use superenv in these environments too
|
|
|
|
|
2009-12-26 14:11:03 +00:00
|
|
|
def install
|
2013-08-26 01:30:16 +00:00
|
|
|
# MacVim doesn't have and required any Python package, unset PYTHONPATH.
|
|
|
|
ENV.delete('PYTHONPATH')
|
|
|
|
|
2011-03-19 16:23:07 +00:00
|
|
|
# Set ARCHFLAGS so the Python app (with C extension) that is
|
|
|
|
# used to create the custom icons will not try to compile in
|
|
|
|
# PPC support (which isn't needed in Homebrew-supported systems.)
|
2013-08-02 02:46:56 +00:00
|
|
|
ENV['ARCHFLAGS'] = "-arch #{MacOS.preferred_arch}"
|
2011-03-13 18:27:30 +00:00
|
|
|
|
2013-06-19 19:17:45 +00:00
|
|
|
# If building for 10.7 or up, make sure that CC is set to "clang".
|
|
|
|
ENV.clang if MacOS.version >= :lion
|
2012-09-02 05:56:39 +00:00
|
|
|
|
2014-07-07 15:17:09 +00:00
|
|
|
# macvim only works with the current Ruby.framework because it builds with -framework Ruby
|
2013-11-09 04:22:00 +00:00
|
|
|
system_ruby = "/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby"
|
2013-10-23 08:38:41 +00:00
|
|
|
|
2012-07-09 19:40:39 +00:00
|
|
|
args = %W[
|
|
|
|
--with-features=huge
|
|
|
|
--enable-multibyte
|
2013-08-16 06:44:05 +00:00
|
|
|
--with-macarchs=#{MacOS.preferred_arch}
|
2012-07-09 19:40:39 +00:00
|
|
|
--enable-perlinterp
|
|
|
|
--enable-rubyinterp
|
|
|
|
--enable-tclinterp
|
2013-10-23 08:38:41 +00:00
|
|
|
--with-ruby-command=#{system_ruby}
|
2013-01-21 09:33:56 +00:00
|
|
|
--with-tlib=ncurses
|
|
|
|
--with-compiledby=Homebrew
|
|
|
|
--with-local-dir=#{HOMEBREW_PREFIX}
|
2012-07-09 19:40:39 +00:00
|
|
|
]
|
2010-11-26 19:20:24 +00:00
|
|
|
|
2013-05-06 18:41:17 +00:00
|
|
|
args << "--enable-cscope" if build.with? "cscope"
|
2010-11-26 19:20:24 +00:00
|
|
|
|
2013-05-06 18:41:17 +00:00
|
|
|
if build.with? "lua"
|
2012-02-27 05:28:00 +00:00
|
|
|
args << "--enable-luainterp"
|
|
|
|
args << "--with-lua-prefix=#{HOMEBREW_PREFIX}"
|
|
|
|
end
|
|
|
|
|
2013-09-03 15:50:51 +00:00
|
|
|
if build.with? "luajit"
|
|
|
|
args << "--enable-luainterp"
|
|
|
|
args << "--with-lua-prefix=#{HOMEBREW_PREFIX}"
|
|
|
|
args << "--with-luajit"
|
|
|
|
end
|
|
|
|
|
2014-02-10 21:42:19 +00:00
|
|
|
if build.with? "python"
|
|
|
|
if build.without? "python3"
|
|
|
|
# MacVim seems to link Python by `-framework Python` (instead of
|
|
|
|
# `python-config --ldflags`) and so we have to pass the -F to point to
|
|
|
|
# where the Python.framework is located, we want it to use!
|
|
|
|
# Also the -L is needed for the correct linking. This is a mess but we have
|
|
|
|
# to wait until MacVim is really able to link against different Python's
|
|
|
|
# on the Mac. Note configure detects brewed python correctly, but that
|
|
|
|
# is ignored.
|
|
|
|
# See https://github.com/Homebrew/homebrew/issues/17908
|
|
|
|
py_prefix = Pathname.new `python-config --prefix`.chomp
|
|
|
|
ENV.prepend "LDFLAGS", "-L#{py_prefix}/lib/python2.7/config -F#{py_prefix.parent.parent.parent}"
|
2014-06-09 12:46:09 +00:00
|
|
|
ENV.prepend "CFLAGS", "-F#{py_prefix.parent.parent.parent}"
|
2014-02-10 21:42:19 +00:00
|
|
|
|
|
|
|
args << "--enable-pythoninterp"
|
|
|
|
else
|
|
|
|
args << "--enable-pythoninterp=dynamic" << "--enable-python3interp=dynamic"
|
|
|
|
end
|
|
|
|
elsif build.with? "python3"
|
|
|
|
args << "--enable-python3interp"
|
2014-01-06 10:22:51 +00:00
|
|
|
end
|
|
|
|
|
2014-05-21 22:10:46 +00:00
|
|
|
# configure appends "SDKS/..." to the value of `xcode-select -print-path`,
|
|
|
|
# but this isn't correct on recent Xcode, so we need to set it manually.
|
|
|
|
# FIXME this is a bug, and it should be fixed upstream.
|
2013-01-21 09:33:56 +00:00
|
|
|
unless MacOS::CLT.installed?
|
2014-05-10 06:17:59 +00:00
|
|
|
args << "--with-developer-dir=#{MacOS::Xcode.prefix}/Platforms/MacOSX.platform/Developer"
|
2014-05-21 22:10:46 +00:00
|
|
|
args << "--with-macsdk=#{MacOS.version}"
|
2013-01-21 09:33:56 +00:00
|
|
|
end
|
2012-12-17 23:33:27 +00:00
|
|
|
|
2010-11-26 19:20:24 +00:00
|
|
|
system "./configure", *args
|
2010-08-14 21:00:47 +00:00
|
|
|
|
2014-02-10 21:42:19 +00:00
|
|
|
if build.with? "python"
|
|
|
|
if build.with? "python3"
|
|
|
|
py_prefix = `python-config --prefix`.chomp
|
|
|
|
inreplace "src/auto/config.mk", /-DDYNAMIC_PYTHON_DLL=\\".*\\"/,
|
|
|
|
%Q[-DDYNAMIC_PYTHON_DLL=\'\"#{py_prefix}/Python\"\']
|
|
|
|
py3_version = /\d\.\d/.match `python3 --version 2>&1`
|
|
|
|
py3_prefix = `python#{py3_version}-config --prefix`.chomp
|
|
|
|
inreplace 'src/auto/config.mk', /-DDYNAMIC_PYTHON3_DLL=\\".*\\"/,
|
|
|
|
%Q[-DDYNAMIC_PYTHON3_DLL=\'\"#{py3_prefix}/Python\"\']
|
|
|
|
end
|
|
|
|
|
2014-02-26 05:00:58 +00:00
|
|
|
unless Formula["python"].installed?
|
2014-02-10 21:42:19 +00:00
|
|
|
inreplace "src/auto/config.h", "/* #undef PY_NO_RTLD_GLOBAL */",
|
|
|
|
"#define PY_NO_RTLD_GLOBAL 1"
|
|
|
|
inreplace "src/auto/config.h", "/* #undef PY3_NO_RTLD_GLOBAL */",
|
|
|
|
"#define PY3_NO_RTLD_GLOBAL 1"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-19 19:19:50 +00:00
|
|
|
if build.include? "custom-icons"
|
|
|
|
# Get the custom font used by the icons
|
2014-05-10 06:17:59 +00:00
|
|
|
system "make", "-C", "src/MacVim/icons", "getenvy"
|
2013-06-19 19:19:50 +00:00
|
|
|
else
|
|
|
|
# Building custom icons fails for many users, so off by default.
|
2010-08-14 21:00:47 +00:00
|
|
|
inreplace "src/MacVim/icons/Makefile", "$(MAKE) -C makeicns", ""
|
|
|
|
inreplace "src/MacVim/icons/make_icons.py", "dont_create = False", "dont_create = True"
|
|
|
|
end
|
|
|
|
|
2009-12-26 14:11:03 +00:00
|
|
|
system "make"
|
|
|
|
|
|
|
|
prefix.install "src/MacVim/build/Release/MacVim.app"
|
|
|
|
inreplace "src/MacVim/mvim", /^# VIM_APP_DIR=\/Applications$/,
|
2012-08-06 21:15:15 +00:00
|
|
|
"VIM_APP_DIR=#{prefix}"
|
2009-12-26 14:11:03 +00:00
|
|
|
bin.install "src/MacVim/mvim"
|
|
|
|
|
|
|
|
# Create MacVim vimdiff, view, ex equivalents
|
2012-09-07 03:22:14 +00:00
|
|
|
executables = %w[mvimdiff mview mvimex gvim gvimdiff gview gvimex]
|
2012-08-09 23:28:35 +00:00
|
|
|
executables += %w[vi vim vimdiff view vimex] if build.include? "override-system-vim"
|
2014-03-25 15:54:36 +00:00
|
|
|
executables.each { |e| bin.install_symlink "mvim" => e }
|
2009-12-26 14:11:03 +00:00
|
|
|
end
|
|
|
|
|
2013-08-26 01:30:16 +00:00
|
|
|
def caveats
|
|
|
|
if build.with? "python" and build.with? "python3"
|
2014-02-10 21:42:19 +00:00
|
|
|
<<-EOS.undent
|
2013-11-11 20:56:15 +00:00
|
|
|
MacVim has been built with dynamic loading of Python 2 and Python 3.
|
2013-08-26 01:30:16 +00:00
|
|
|
|
2013-11-11 20:56:15 +00:00
|
|
|
Note: if MacVim dynamically loads both Python 2 and Python 3, it may
|
|
|
|
crash. For more information, see:
|
2013-08-26 01:30:16 +00:00
|
|
|
http://vimdoc.sourceforge.net/htmldoc/if_pyth.html#python3
|
|
|
|
EOS
|
|
|
|
end
|
2009-12-26 14:11:03 +00:00
|
|
|
end
|
|
|
|
end
|