parent
82ed6aceb8
commit
66f942aa66
@ -22,11 +22,14 @@ module HomebrewEnvExtension
|
||||
# Os is the default Apple uses for all its stuff so let's trust them
|
||||
self['CFLAGS'] = self['CXXFLAGS'] = "-Os #{SAFE_CFLAGS_FLAGS}"
|
||||
|
||||
# set us up for the user's compiler choice
|
||||
self.send self.compiler
|
||||
|
||||
# we must have a working compiler!
|
||||
unless File.exist? ENV['CC'] and File.exist? ENV['CXX']
|
||||
@compiler = MacOS.default_compiler
|
||||
self.send @compiler
|
||||
|
||||
ENV['CC'] = '/usr/bin/cc'
|
||||
ENV['CXX'] = '/usr/bin/c++'
|
||||
end
|
||||
@ -75,8 +78,8 @@ module HomebrewEnvExtension
|
||||
end
|
||||
|
||||
def gcc_4_0_1
|
||||
self['CC'] = '/usr/bin/gcc-4.0'
|
||||
self['CXX'] = '/usr/bin/g++-4.0'
|
||||
self['CC'] = "#{MacOS.dev_tools_path}/gcc-4.0"
|
||||
self['CXX'] = "#{MacOS.dev_tools_path}/g++-4.0"
|
||||
replace_in_cflags '-O4', '-O3'
|
||||
set_cpu_cflags 'nocona -mssse3', :core => 'prescott', :bottle => 'generic'
|
||||
@compiler = :gcc
|
||||
@ -84,8 +87,12 @@ module HomebrewEnvExtension
|
||||
alias_method :gcc_4_0, :gcc_4_0_1
|
||||
|
||||
def gcc args = {}
|
||||
gcc_path = Pathname.new "/usr/bin/gcc-4.2"
|
||||
gxx_path = Pathname.new "/usr/bin/g++-4.2"
|
||||
# Apple stopped shipping gcc-4.2 with Xcode 4.2
|
||||
# However they still provide a gcc symlink to llvm
|
||||
# But we don't want LLVM of course.
|
||||
|
||||
gcc_path = Pathname.new "#{MacOS.dev_tools_path}/gcc-4.2"
|
||||
gxx_path = Pathname.new "#{MacOS.dev_tools_path}/g++-4.2"
|
||||
self['CC'] = gcc_path.exist? ? gcc_path : HOMEBREW_PREFIX+'bin/gcc-4.2'
|
||||
self['CXX'] = gxx_path.exist? ? gxx_path : HOMEBREW_PREFIX+'bin/g++-4.2'
|
||||
replace_in_cflags '-O4', '-O3'
|
||||
@ -98,15 +105,15 @@ module HomebrewEnvExtension
|
||||
alias_method :gcc_4_2, :gcc
|
||||
|
||||
def llvm
|
||||
self['CC'] = "/usr/bin/llvm-gcc"
|
||||
self['CXX'] = "/usr/bin/llvm-g++"
|
||||
self['CC'] = "#{MacOS.dev_tools_path}/llvm-gcc"
|
||||
self['CXX'] = "#{MacOS.dev_tools_path}/llvm-g++"
|
||||
set_cpu_cflags 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott'
|
||||
@compiler = :llvm
|
||||
end
|
||||
|
||||
def clang args = {}
|
||||
self['CC'] = "/usr/bin/clang"
|
||||
self['CXX'] = "/usr/bin/clang++"
|
||||
self['CC'] = "#{MacOS.dev_tools_path}/clang"
|
||||
self['CXX'] = "#{MacOS.dev_tools_path}/clang++"
|
||||
replace_in_cflags(/-Xarch_i386 (-march=\S*)/, '\1')
|
||||
# Clang mistakenly enables AES-NI on plain Nehalem
|
||||
set_cpu_cflags 'native', :nehalem => 'native -Xclang -target-feature -Xclang -aes'
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user