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
|
2010-12-08 22:43:28 +00:00
|
|
|
def build_universal?; ARGV.include? '--universal'; end
|
2011-01-09 18:32:58 +00:00
|
|
|
def build_shared?; ARGV.include? '--shared'; end
|
|
|
|
def build_rtti?; ARGV.include? '--rtti'; end
|
2010-06-05 17:27:11 +00:00
|
|
|
|
2009-11-18 22:08:29 +00:00
|
|
|
class Clang <Formula
|
2010-10-06 14:20:35 +00:00
|
|
|
url 'http://llvm.org/releases/2.8/clang-2.8.tgz'
|
2009-11-18 22:08:29 +00:00
|
|
|
homepage 'http://llvm.org/'
|
2010-10-06 14:20:35 +00:00
|
|
|
md5 '10e14c901fc3728eecbd5b829e011b59'
|
2009-11-18 22:08:29 +00:00
|
|
|
end
|
|
|
|
|
2009-08-31 13:45:04 +00:00
|
|
|
class Llvm <Formula
|
2010-10-06 14:20:35 +00:00
|
|
|
url 'http://llvm.org/releases/2.8/llvm-2.8.tgz'
|
2009-11-18 22:08:29 +00:00
|
|
|
homepage 'http://llvm.org/'
|
2010-10-07 01:52:50 +00:00
|
|
|
md5 '220d361b4d17051ff4bb21c64abe05ba'
|
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
|
2010-12-08 22:43:28 +00:00
|
|
|
[['--with-clang', 'Also build & install clang'],
|
2011-01-09 18:32:58 +00:00
|
|
|
['--shared', 'Build shared library'],
|
|
|
|
['--rtti', 'Build with RTTI information'],
|
2010-12-08 22:43:28 +00:00
|
|
|
['--universal', 'Build both i386 and x86_64 architectures']]
|
2009-11-18 22:08:29 +00:00
|
|
|
end
|
|
|
|
|
2009-08-31 13:45:04 +00:00
|
|
|
def install
|
2009-11-04 17:10:52 +00:00
|
|
|
ENV.gcc_4_2 # llvm can't compile itself
|
|
|
|
|
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
|
|
|
|
|
2010-06-05 17:27:11 +00:00
|
|
|
if build_clang?
|
|
|
|
clang_dir = Pathname.new(Dir.pwd)+'tools/clang'
|
2010-04-07 05:58:35 +00:00
|
|
|
Clang.new.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?
|
|
|
|
|
|
|
|
configure_options = ["--prefix=#{prefix}",
|
|
|
|
"--enable-targets=host-only",
|
|
|
|
"--enable-optimized"]
|
|
|
|
|
|
|
|
configure_options << "--enable-shared" if build_shared?
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-06-05 17:27:11 +00:00
|
|
|
if build_clang?
|
2009-11-18 22:08:29 +00:00
|
|
|
Dir.chdir clang_dir do
|
|
|
|
system "make install"
|
|
|
|
end
|
|
|
|
end
|
2009-08-31 13:45:04 +00:00
|
|
|
end
|
2010-10-07 17:13:59 +00:00
|
|
|
|
|
|
|
def caveats; <<-EOS
|
|
|
|
If you already have LLVM installed, then "brew upgrade llvm" might not
|
|
|
|
work. Instead, try:
|
|
|
|
$ brew rm llvm
|
|
|
|
$ brew install llvm
|
|
|
|
EOS
|
|
|
|
end
|
2009-08-31 13:45:04 +00:00
|
|
|
end
|
2011-01-14 16:13:32 +00:00
|
|
|
|
|
|
|
__END__
|
|
|
|
diff --git a/Makefile.rules b/Makefile.rules
|
|
|
|
index 9cff105..44d5b2d 100644
|
|
|
|
--- a/Makefile.rules
|
|
|
|
+++ b/Makefile.rules
|
|
|
|
@@ -497,7 +497,7 @@ ifeq ($(HOST_OS),Darwin)
|
|
|
|
# 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/')
|
|
|
|
|
|
|
|
- SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined,suppress \
|
|
|
|
+ SharedLinkOptions=-Wl,-undefined,dynamic_lookup \
|
|
|
|
-dynamiclib
|
|
|
|
ifneq ($(ARCH),ARM)
|
|
|
|
SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
|