forked from necromant2005/homebrew-boneyard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
llvm31.rb
92 lines (75 loc) · 3.03 KB
/
llvm31.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class Llvm31 < Formula
homepage "http://llvm.org/"
url "http://llvm.org/releases/3.1/llvm-3.1.src.tar.gz"
sha256 "1ea05135197b5400c1f88d00ff280d775ce778f8f9ea042e25a1e1e734a4b9ab"
option :universal
option "with-clang", "Build Clang C/ObjC/C++ frontend"
option "disable-shared", "Don't build LLVM as a shared library"
option "all-targets", "Build all target backends"
option "rtti", "Build with C++ RTTI"
depends_on :python => :recommended
depends_on MaximumMacOSRequirement => :mountain_lion
resource "clang" do
url "http://llvm.org/releases/3.1/clang-3.1.src.tar.gz"
sha256 "ff63e215dcd3e2838ffdea38502f8d35bab17e487f3c3799579961e452d5a786"
end
def install
if build.with?("python") && build.include?("disable-shared")
raise "The Python bindings need the shared library."
end
(buildpath/"tools/clang").install resource("clang") if build.with? "clang"
if build.universal?
ENV.permit_arch_flags
ENV["UNIVERSAL"] = "1"
ENV["UNIVERSAL_ARCH"] = Hardware::CPU.universal_archs.join(" ")
end
ENV["REQUIRES_RTTI"] = "1" if build.include? "rtti"
install_prefix = lib/"llvm-#{version}"
args = [
"--prefix=#{install_prefix}",
"--enable-optimized",
# As of LLVM 3.1, attempting to build ocaml bindings with Homebrew's
# OCaml 3.12.1 results in errors.
"--disable-bindings",
]
if build.include? "all-targets"
args << "--enable-targets=all"
else
args << "--enable-targets=host"
end
args << "--enable-shared" unless build.include? "disable-shared"
system "./configure", *args
system "make", "VERBOSE=1"
system "make", "VERBOSE=1", "install"
# Install Clang tools
(share/"clang-#{version}/tools").install buildpath/"tools/clang/tools/scan-build", buildpath/"tools/clang/tools/scan-view" if build.with? "clang"
if build.with? "python"
# Install llvm python bindings.
mv buildpath/"bindings/python/llvm", buildpath/"bindings/python/llvm-#{version}"
(lib+"python2.7/site-packages").install buildpath/"bindings/python/llvm-#{version}"
# Install clang tools and bindings if requested.
if build.with? "clang"
mv buildpath/"tools/clang/bindings/python/clang", buildpath/"tools/clang/bindings/python/clang-#{version}"
(lib+"python2.7/site-packages").install buildpath/"tools/clang/bindings/python/clang-#{version}"
end
end
# Link executables to bin and add suffix to avoid conflicts
Dir.glob(install_prefix/"bin/*") do |exec_path|
basename = File.basename(exec_path)
bin.install_symlink exec_path => "#{basename}-#{version}"
end
# Also link man pages
Dir.glob(install_prefix/"share/man/man1/*") do |manpage|
basename = File.basename(manpage, ".1")
man1.install_symlink manpage => "#{basename}-#{version}.1"
end
end
test do
system "#{bin}/llvm-config-#{version}", "--version"
end
def caveats
if build.with? "clang"
"Extra tools are installed in #{HOMEBREW_PREFIX}/share/clang-#{version}."
end
end
end