aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorMax Howell2012-02-16 18:00:04 +0000
committerMax Howell2012-02-16 18:19:01 +0000
commit66f942aa66d9de764e59bf3d36c9d8d61f05f247 (patch)
tree28e8793f7f6270ad4a8ebd63455c91307f576046 /Library/Homebrew/utils.rb
parent82ed6aceb8a8789d58b040910d91f4d66f366156 (diff)
downloadbrew-66f942aa66d9de764e59bf3d36c9d8d61f05f247.tar.bz2
Find the dev tools, even with Xcode 4.3
Fixes Homebrew/homebrew#9179.
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb53
1 files changed, 40 insertions, 13 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index c7da0db6c..452f1fd13 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -251,8 +251,29 @@ module MacOS extend self
MACOS_VERSION
end
+ def dev_tools_path
+ @dev_tools_path ||= if File.file? "/usr/bin/cc" and File.file? "/usr/bin/make"
+ # probably a safe enough assumption
+ "/usr/bin"
+ elsif File.file? "#{xcode_prefix}/usr/bin/make"
+ # cc stopped existing with Xcode 4.3, there are c89 and c99 options though
+ "#{xcode_prefix}/usr/bin"
+ else
+ # yes this seems dumb, but we can't throw because the existance of
+ # dev tools is not mandatory for installing formula. Eventually we
+ # should make forumla specify if they need dev tools or not.
+ "/usr/bin"
+ end
+ end
+
def default_cc
- Pathname.new("/usr/bin/cc").realpath.basename.to_s
+ cc = if !File.file? "/usr/bin/cc" and xcode_version > 4.3
+ # there is no cc file in Xcode 4.3.0 in the /Developer/usr/bin directory
+ "llvm-gcc"
+ else
+ "cc"
+ end
+ Pathname.new("#{dev_tools_path}/cc").realpath.basename.to_s
end
def default_compiler
@@ -260,21 +281,27 @@ module MacOS extend self
when /^gcc/ then :gcc
when /^llvm/ then :llvm
when "clang" then :clang
- else :gcc # a hack, but a sensible one prolly
+ else
+ # guess :(
+ if xcode_version > 4.2
+ :llvm
+ else
+ :gcc
+ end
end
end
def gcc_42_build_version
- @gcc_42_build_version ||= if File.exist? "/usr/bin/gcc-4.2" \
- and not Pathname.new("/usr/bin/gcc-4.2").realpath.basename.to_s =~ /^llvm/
- `/usr/bin/gcc-4.2 --version` =~ /build (\d{4,})/
+ @gcc_42_build_version ||= if File.exist? "#{dev_tools_path}/gcc-4.2" \
+ and not Pathname.new("#{dev_tools_path}/gcc-4.2").realpath.basename.to_s =~ /^llvm/
+ `#{dev_tools_path}/gcc-4.2 --version` =~ /build (\d{4,})/
$1.to_i
end
end
def gcc_40_build_version
- @gcc_40_build_version ||= if File.exist? "/usr/bin/gcc-4.0"
- `/usr/bin/gcc-4.0 --version` =~ /build (\d{4,})/
+ @gcc_40_build_version ||= if File.exist? "#{dev_tools_path}/gcc-4.0"
+ `#{dev_tools_path}/gcc-4.0 --version` =~ /build (\d{4,})/
$1.to_i
end
end
@@ -332,22 +359,22 @@ module MacOS extend self
def llvm_build_version
# for Xcode 3 on OS X 10.5 this will not exist
# NOTE may not be true anymore but we can't test
- @llvm_build_version ||= if File.exist? "/usr/bin/llvm-gcc"
- `/usr/bin/llvm-gcc --version` =~ /LLVM build (\d{4,})/
+ @llvm_build_version ||= if File.exist? "#{dev_tools_path}/llvm-gcc"
+ `#{dev_tools_path}/llvm-gcc --version` =~ /LLVM build (\d{4,})/
$1.to_i
end
end
def clang_version
- @clang_version ||= if File.exist? "/usr/bin/clang"
- `/usr/bin/clang --version` =~ /clang version (\d\.\d)/
+ @clang_version ||= if File.exist? "#{dev_tools_path}/clang"
+ `#{dev_tools_path}/clang --version` =~ /clang version (\d\.\d)/
$1
end
end
def clang_build_version
- @clang_build_version ||= if File.exist? "/usr/bin/clang"
- `/usr/bin/clang --version` =~ %r[tags/Apple/clang-(\d{2,})]
+ @clang_build_version ||= if File.exist? "#{dev_tools_path}/clang"
+ `#{dev_tools_path}/clang --version` =~ %r[tags/Apple/clang-(\d{2,})]
$1.to_i
end
end