2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-08-31 13:45:04 +00:00
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Clang < Formula
|
2009-11-18 22:08:29 +00:00
|
|
|
homepage 'http://llvm.org/'
|
2012-08-11 09:21:42 +00:00
|
|
|
url 'http://llvm.org/releases/3.1/clang-3.1.src.tar.gz'
|
|
|
|
sha1 '19f33b187a50d22fda2a6f9ed989699a9a9efd62'
|
2012-04-19 02:37:43 +00:00
|
|
|
|
|
|
|
head 'http://llvm.org/git/clang.git'
|
2009-11-18 22:08:29 +00:00
|
|
|
end
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Llvm < Formula
|
2009-11-18 22:08:29 +00:00
|
|
|
homepage 'http://llvm.org/'
|
2012-08-11 09:21:42 +00:00
|
|
|
url 'http://llvm.org/releases/3.1/llvm-3.1.src.tar.gz'
|
|
|
|
sha1 '234c96e73ef81aec9a54da92fc2a9024d653b059'
|
2009-11-18 22:08:29 +00:00
|
|
|
|
2012-04-19 02:37:43 +00:00
|
|
|
head 'http://llvm.org/git/llvm.git'
|
|
|
|
|
2012-03-22 17:04:54 +00:00
|
|
|
bottle do
|
2012-08-11 09:21:42 +00:00
|
|
|
sha1 'fcf6c3eb5b074afa820f905f32182e074a29ffb5' => :mountainlion
|
|
|
|
sha1 '4ee3e9242cff9a03af4e1f20017fe547dcd07a4a' => :lion
|
|
|
|
sha1 '940aca37dafaf69a9b378ffd2a59b3c1cfe54ced' => :snowleopard
|
2011-01-14 16:13:32 +00:00
|
|
|
end
|
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
option :universal
|
|
|
|
option 'with-clang', 'Build Clang C/ObjC/C++ frontend'
|
|
|
|
option 'shared', 'Build LLVM as a shared library'
|
|
|
|
option 'all-targets', 'Build all target backends'
|
|
|
|
option 'rtti', 'Build with C++ RTTI'
|
2009-11-18 22:08:29 +00:00
|
|
|
|
2009-08-31 13:45:04 +00:00
|
|
|
def install
|
2012-08-14 18:52:42 +00:00
|
|
|
if build.universal? and build.include? 'shared'
|
2011-01-09 18:32:58 +00:00
|
|
|
onoe "Cannot specify both shared and universal (will not build)"
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
Clang.new("clang").brew { clang_dir.install Dir['*'] } if build.include? 'with-clang'
|
2009-11-18 22:08:29 +00:00
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
if build.universal?
|
2010-12-08 22:43:28 +00:00
|
|
|
ENV['UNIVERSAL'] = '1'
|
|
|
|
ENV['UNIVERSAL_ARCH'] = 'i386 x86_64'
|
|
|
|
end
|
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
ENV['REQUIRES_RTTI'] = '1' if build.include? 'rtti'
|
2011-01-09 18:32:58 +00:00
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
args = [
|
2011-12-03 22:56:37 +00:00
|
|
|
"--prefix=#{prefix}",
|
|
|
|
"--enable-optimized",
|
2012-08-11 09:21:42 +00:00
|
|
|
# As of LLVM 3.1, attempting to build ocaml bindings with Homebrew's
|
|
|
|
# OCaml 3.12.1 results in errors.
|
|
|
|
"--disable-bindings",
|
2011-12-03 22:56:37 +00:00
|
|
|
]
|
2011-01-09 18:32:58 +00:00
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
if build.include? 'all-targets'
|
|
|
|
args << "--enable-targets=all"
|
2011-05-11 22:32:19 +00:00
|
|
|
else
|
2012-08-13 15:55:01 +00:00
|
|
|
args << "--enable-targets=host"
|
2011-05-11 22:32:19 +00:00
|
|
|
end
|
2012-08-13 15:55:01 +00:00
|
|
|
args << "--enable-shared" if build.include? 'shared'
|
2011-01-09 18:32:58 +00:00
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
system "./configure", *args
|
2010-04-07 05:58:35 +00:00
|
|
|
system "make install"
|
2009-11-18 22:08:29 +00:00
|
|
|
|
2012-08-11 09:21:42 +00:00
|
|
|
# install llvm python bindings
|
|
|
|
(share/'llvm/bindings').install buildpath/'bindings/python'
|
2011-05-18 21:44:54 +00:00
|
|
|
|
2012-08-11 09:21:42 +00:00
|
|
|
# install clang tools and bindings
|
2012-02-21 06:04:21 +00:00
|
|
|
cd clang_dir do
|
2012-08-11 09:21:42 +00:00
|
|
|
(share/'clang/tools').install 'tools/scan-build', 'tools/scan-view'
|
|
|
|
(share/'clang/bindings').install 'bindings/python'
|
2012-08-13 15:55:01 +00:00
|
|
|
end if build.include? 'with-clang'
|
2009-08-31 13:45:04 +00:00
|
|
|
end
|
2010-10-07 17:13:59 +00:00
|
|
|
|
2012-03-22 17:19:39 +00:00
|
|
|
def test
|
2012-05-15 21:36:45 +00:00
|
|
|
system "#{bin}/llvm-config", "--version"
|
2012-03-22 17:19:39 +00:00
|
|
|
end
|
|
|
|
|
2011-04-04 23:56:47 +00:00
|
|
|
def caveats; <<-EOS.undent
|
2012-08-11 09:21:42 +00:00
|
|
|
Extra tools and bindings are installed in #{share}/llvm and #{share}/clang.
|
|
|
|
|
2011-04-04 23:56:47 +00:00
|
|
|
If you already have LLVM installed, then "brew upgrade llvm" might not work.
|
|
|
|
Instead, try:
|
2011-07-07 22:35:45 +00:00
|
|
|
brew rm llvm && brew install llvm
|
2010-10-07 17:13:59 +00:00
|
|
|
EOS
|
|
|
|
end
|
2012-02-27 05:01:41 +00:00
|
|
|
|
|
|
|
def clang_dir
|
|
|
|
buildpath/'tools/clang'
|
|
|
|
end
|
2009-08-31 13:45:04 +00:00
|
|
|
end
|