2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-08-31 13:45:04 +00:00
|
|
|
|
2010-06-05 17:27:11 +00:00
|
|
|
def build_clang?; ARGV.include? '--with-clang'; end
|
2011-05-11 22:32:19 +00:00
|
|
|
def build_all_targets?; ARGV.include? '--all-targets'; end
|
2011-05-18 21:44:54 +00:00
|
|
|
def build_analyzer?; ARGV.include? '--analyzer'; end
|
2011-04-21 16:42:27 +00:00
|
|
|
def build_universal?; ARGV.build_universal?; end
|
2011-01-09 18:32:58 +00:00
|
|
|
def build_shared?; ARGV.include? '--shared'; end
|
|
|
|
def build_rtti?; ARGV.include? '--rtti'; end
|
2011-09-05 02:56:03 +00:00
|
|
|
def build_jit?; ARGV.include? '--jit'; end
|
2010-06-05 17:27:11 +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/'
|
2011-08-09 02:12:22 +00:00
|
|
|
head 'http://llvm.org/git/clang.git', :using => :git
|
2011-12-02 19:14:55 +00:00
|
|
|
url 'http://llvm.org/releases/3.0/clang-3.0.tar.gz'
|
|
|
|
md5 '43350706ae6cf05d0068885792ea0591'
|
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/'
|
2011-08-09 02:12:22 +00:00
|
|
|
head 'http://llvm.org/git/llvm.git', :using => :git
|
2011-12-02 19:14:55 +00:00
|
|
|
url 'http://llvm.org/releases/3.0/llvm-3.0.tar.gz'
|
|
|
|
md5 'a8e5f5f1c1adebae7b4a654c376a6005'
|
2009-11-18 22:08:29 +00:00
|
|
|
|
2011-01-14 16:13:32 +00:00
|
|
|
def patches
|
|
|
|
# changes the link options for the shared library build
|
|
|
|
# to use the preferred way to build libraries in Mac OS X
|
|
|
|
# Reported upstream: http://llvm.org/bugs/show_bug.cgi?id=8985
|
|
|
|
DATA if build_shared?
|
|
|
|
end
|
|
|
|
|
2009-11-18 22:08:29 +00:00
|
|
|
def options
|
2011-06-23 17:15:10 +00:00
|
|
|
[['--with-clang', 'Build clang'],
|
|
|
|
['--analyzer', 'Build clang analyzer'],
|
2011-01-09 18:32:58 +00:00
|
|
|
['--shared', 'Build shared library'],
|
2011-05-11 22:32:19 +00:00
|
|
|
['--all-targets', 'Build all target backends'],
|
2011-01-09 18:32:58 +00:00
|
|
|
['--rtti', 'Build with RTTI information'],
|
2011-09-05 02:56:03 +00:00
|
|
|
['--universal', 'Build both i386 and x86_64 architectures'],
|
|
|
|
['--jit', 'Build with Just In Time (JIT) compiler functionality']]
|
2009-11-18 22:08:29 +00:00
|
|
|
end
|
|
|
|
|
2009-08-31 13:45:04 +00:00
|
|
|
def install
|
2011-01-09 18:32:58 +00:00
|
|
|
if build_shared? && build_universal?
|
|
|
|
onoe "Cannot specify both shared and universal (will not build)"
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2011-05-18 21:44:54 +00:00
|
|
|
if build_clang? or build_analyzer?
|
2010-06-05 17:27:11 +00:00
|
|
|
clang_dir = Pathname.new(Dir.pwd)+'tools/clang'
|
2011-08-09 02:12:22 +00:00
|
|
|
Clang.new("clang").brew { clang_dir.install Dir['*'] }
|
2009-11-18 22:08:29 +00:00
|
|
|
end
|
|
|
|
|
2010-12-08 22:43:28 +00:00
|
|
|
if build_universal?
|
|
|
|
ENV['UNIVERSAL'] = '1'
|
|
|
|
ENV['UNIVERSAL_ARCH'] = 'i386 x86_64'
|
|
|
|
end
|
|
|
|
|
2011-01-09 18:32:58 +00:00
|
|
|
ENV['REQUIRES_RTTI'] = '1' if build_rtti?
|
|
|
|
|
2011-12-03 22:56:37 +00:00
|
|
|
configure_options = [
|
|
|
|
"--prefix=#{prefix}",
|
|
|
|
"--enable-optimized",
|
|
|
|
# As of LLVM 3.0, the only bindings offered are for OCaml and attempting
|
|
|
|
# to build these when Homebrew's OCaml is installed results in errors.
|
|
|
|
#
|
|
|
|
# See issue #8947 for details.
|
|
|
|
"--enable-bindings=none"
|
|
|
|
]
|
2011-01-09 18:32:58 +00:00
|
|
|
|
2011-05-11 22:32:19 +00:00
|
|
|
if build_all_targets?
|
|
|
|
configure_options << "--enable-targets=all"
|
|
|
|
else
|
|
|
|
configure_options << "--enable-targets=host-only"
|
|
|
|
end
|
|
|
|
|
2011-01-09 18:32:58 +00:00
|
|
|
configure_options << "--enable-shared" if build_shared?
|
2011-09-05 02:56:03 +00:00
|
|
|
configure_options << "--enable-jit" if build_jit?
|
2011-01-09 18:32:58 +00:00
|
|
|
|
|
|
|
system "./configure", *configure_options
|
|
|
|
|
|
|
|
system "make" # separate steps required, otherwise the build fails
|
2010-04-07 05:58:35 +00:00
|
|
|
system "make install"
|
2009-11-18 22:08:29 +00:00
|
|
|
|
2011-04-04 23:56:47 +00:00
|
|
|
Dir.chdir clang_dir do
|
|
|
|
system "make install"
|
2011-04-14 11:36:07 +00:00
|
|
|
bin.install 'tools/scan-build/set-xcode-analyzer'
|
2011-05-18 21:44:54 +00:00
|
|
|
end if build_clang? or build_analyzer?
|
|
|
|
|
|
|
|
Dir.chdir clang_dir do
|
|
|
|
bin.install 'tools/scan-build/scan-build'
|
|
|
|
bin.install 'tools/scan-build/ccc-analyzer'
|
|
|
|
bin.install 'tools/scan-build/c++-analyzer'
|
|
|
|
bin.install 'tools/scan-build/sorttable.js'
|
|
|
|
bin.install 'tools/scan-build/scanview.css'
|
|
|
|
|
|
|
|
bin.install 'tools/scan-view/scan-view'
|
|
|
|
bin.install 'tools/scan-view/ScanView.py'
|
|
|
|
bin.install 'tools/scan-view/Reporter.py'
|
|
|
|
bin.install 'tools/scan-view/startfile.py'
|
|
|
|
bin.install 'tools/scan-view/Resources'
|
|
|
|
end if build_analyzer?
|
2009-08-31 13:45:04 +00:00
|
|
|
end
|
2010-10-07 17:13:59 +00:00
|
|
|
|
2011-04-04 23:56:47 +00:00
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
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
|
2009-08-31 13:45:04 +00:00
|
|
|
end
|
2011-01-14 16:13:32 +00:00
|
|
|
|
2011-04-04 23:56:47 +00:00
|
|
|
|
2011-01-14 16:13:32 +00:00
|
|
|
__END__
|
2011-04-10 12:48:37 +00:00
|
|
|
diff --git i/Makefile.rules w/Makefile.rules
|
|
|
|
index 5fc77a5..a6baaf4 100644
|
|
|
|
--- i/Makefile.rules
|
|
|
|
+++ w/Makefile.rules
|
|
|
|
@@ -507,7 +507,7 @@ ifeq ($(HOST_OS),Darwin)
|
2011-01-14 16:13:32 +00:00
|
|
|
# Get "4" out of 10.4 for later pieces in the makefile.
|
|
|
|
DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
|
|
|
|
|
2011-04-10 12:48:37 +00:00
|
|
|
- LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
|
|
|
|
+ LoadableModuleOptions := -Wl,-undefined,dynamic_lookup
|
|
|
|
SharedLinkOptions := -dynamiclib
|
2011-01-14 16:13:32 +00:00
|
|
|
ifneq ($(ARCH),ARM)
|
|
|
|
SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
|