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
|
# Os is the default Apple uses for all its stuff so let's trust them
|
||||||
self['CFLAGS'] = self['CXXFLAGS'] = "-Os #{SAFE_CFLAGS_FLAGS}"
|
self['CFLAGS'] = self['CXXFLAGS'] = "-Os #{SAFE_CFLAGS_FLAGS}"
|
||||||
|
|
||||||
|
# set us up for the user's compiler choice
|
||||||
self.send self.compiler
|
self.send self.compiler
|
||||||
|
|
||||||
# we must have a working compiler!
|
# we must have a working compiler!
|
||||||
unless File.exist? ENV['CC'] and File.exist? ENV['CXX']
|
unless File.exist? ENV['CC'] and File.exist? ENV['CXX']
|
||||||
@compiler = MacOS.default_compiler
|
@compiler = MacOS.default_compiler
|
||||||
self.send @compiler
|
self.send @compiler
|
||||||
|
|
||||||
ENV['CC'] = '/usr/bin/cc'
|
ENV['CC'] = '/usr/bin/cc'
|
||||||
ENV['CXX'] = '/usr/bin/c++'
|
ENV['CXX'] = '/usr/bin/c++'
|
||||||
end
|
end
|
||||||
@ -75,8 +78,8 @@ module HomebrewEnvExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
def gcc_4_0_1
|
def gcc_4_0_1
|
||||||
self['CC'] = '/usr/bin/gcc-4.0'
|
self['CC'] = "#{MacOS.dev_tools_path}/gcc-4.0"
|
||||||
self['CXX'] = '/usr/bin/g++-4.0'
|
self['CXX'] = "#{MacOS.dev_tools_path}/g++-4.0"
|
||||||
replace_in_cflags '-O4', '-O3'
|
replace_in_cflags '-O4', '-O3'
|
||||||
set_cpu_cflags 'nocona -mssse3', :core => 'prescott', :bottle => 'generic'
|
set_cpu_cflags 'nocona -mssse3', :core => 'prescott', :bottle => 'generic'
|
||||||
@compiler = :gcc
|
@compiler = :gcc
|
||||||
@ -84,8 +87,12 @@ module HomebrewEnvExtension
|
|||||||
alias_method :gcc_4_0, :gcc_4_0_1
|
alias_method :gcc_4_0, :gcc_4_0_1
|
||||||
|
|
||||||
def gcc args = {}
|
def gcc args = {}
|
||||||
gcc_path = Pathname.new "/usr/bin/gcc-4.2"
|
# Apple stopped shipping gcc-4.2 with Xcode 4.2
|
||||||
gxx_path = Pathname.new "/usr/bin/g++-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['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'
|
self['CXX'] = gxx_path.exist? ? gxx_path : HOMEBREW_PREFIX+'bin/g++-4.2'
|
||||||
replace_in_cflags '-O4', '-O3'
|
replace_in_cflags '-O4', '-O3'
|
||||||
@ -98,15 +105,15 @@ module HomebrewEnvExtension
|
|||||||
alias_method :gcc_4_2, :gcc
|
alias_method :gcc_4_2, :gcc
|
||||||
|
|
||||||
def llvm
|
def llvm
|
||||||
self['CC'] = "/usr/bin/llvm-gcc"
|
self['CC'] = "#{MacOS.dev_tools_path}/llvm-gcc"
|
||||||
self['CXX'] = "/usr/bin/llvm-g++"
|
self['CXX'] = "#{MacOS.dev_tools_path}/llvm-g++"
|
||||||
set_cpu_cflags 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott'
|
set_cpu_cflags 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott'
|
||||||
@compiler = :llvm
|
@compiler = :llvm
|
||||||
end
|
end
|
||||||
|
|
||||||
def clang args = {}
|
def clang args = {}
|
||||||
self['CC'] = "/usr/bin/clang"
|
self['CC'] = "#{MacOS.dev_tools_path}/clang"
|
||||||
self['CXX'] = "/usr/bin/clang++"
|
self['CXX'] = "#{MacOS.dev_tools_path}/clang++"
|
||||||
replace_in_cflags(/-Xarch_i386 (-march=\S*)/, '\1')
|
replace_in_cflags(/-Xarch_i386 (-march=\S*)/, '\1')
|
||||||
# Clang mistakenly enables AES-NI on plain Nehalem
|
# Clang mistakenly enables AES-NI on plain Nehalem
|
||||||
set_cpu_cflags 'native', :nehalem => 'native -Xclang -target-feature -Xclang -aes'
|
set_cpu_cflags 'native', :nehalem => 'native -Xclang -target-feature -Xclang -aes'
|
||||||
|
|||||||
@ -251,8 +251,29 @@ module MacOS extend self
|
|||||||
MACOS_VERSION
|
MACOS_VERSION
|
||||||
end
|
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
|
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
|
end
|
||||||
|
|
||||||
def default_compiler
|
def default_compiler
|
||||||
@ -260,21 +281,27 @@ module MacOS extend self
|
|||||||
when /^gcc/ then :gcc
|
when /^gcc/ then :gcc
|
||||||
when /^llvm/ then :llvm
|
when /^llvm/ then :llvm
|
||||||
when "clang" then :clang
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def gcc_42_build_version
|
def gcc_42_build_version
|
||||||
@gcc_42_build_version ||= if File.exist? "/usr/bin/gcc-4.2" \
|
@gcc_42_build_version ||= if File.exist? "#{dev_tools_path}/gcc-4.2" \
|
||||||
and not Pathname.new("/usr/bin/gcc-4.2").realpath.basename.to_s =~ /^llvm/
|
and not Pathname.new("#{dev_tools_path}/gcc-4.2").realpath.basename.to_s =~ /^llvm/
|
||||||
`/usr/bin/gcc-4.2 --version` =~ /build (\d{4,})/
|
`#{dev_tools_path}/gcc-4.2 --version` =~ /build (\d{4,})/
|
||||||
$1.to_i
|
$1.to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def gcc_40_build_version
|
def gcc_40_build_version
|
||||||
@gcc_40_build_version ||= if File.exist? "/usr/bin/gcc-4.0"
|
@gcc_40_build_version ||= if File.exist? "#{dev_tools_path}/gcc-4.0"
|
||||||
`/usr/bin/gcc-4.0 --version` =~ /build (\d{4,})/
|
`#{dev_tools_path}/gcc-4.0 --version` =~ /build (\d{4,})/
|
||||||
$1.to_i
|
$1.to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -332,22 +359,22 @@ module MacOS extend self
|
|||||||
def llvm_build_version
|
def llvm_build_version
|
||||||
# for Xcode 3 on OS X 10.5 this will not exist
|
# for Xcode 3 on OS X 10.5 this will not exist
|
||||||
# NOTE may not be true anymore but we can't test
|
# NOTE may not be true anymore but we can't test
|
||||||
@llvm_build_version ||= if File.exist? "/usr/bin/llvm-gcc"
|
@llvm_build_version ||= if File.exist? "#{dev_tools_path}/llvm-gcc"
|
||||||
`/usr/bin/llvm-gcc --version` =~ /LLVM build (\d{4,})/
|
`#{dev_tools_path}/llvm-gcc --version` =~ /LLVM build (\d{4,})/
|
||||||
$1.to_i
|
$1.to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clang_version
|
def clang_version
|
||||||
@clang_version ||= if File.exist? "/usr/bin/clang"
|
@clang_version ||= if File.exist? "#{dev_tools_path}/clang"
|
||||||
`/usr/bin/clang --version` =~ /clang version (\d\.\d)/
|
`#{dev_tools_path}/clang --version` =~ /clang version (\d\.\d)/
|
||||||
$1
|
$1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clang_build_version
|
def clang_build_version
|
||||||
@clang_build_version ||= if File.exist? "/usr/bin/clang"
|
@clang_build_version ||= if File.exist? "#{dev_tools_path}/clang"
|
||||||
`/usr/bin/clang --version` =~ %r[tags/Apple/clang-(\d{2,})]
|
`#{dev_tools_path}/clang --version` =~ %r[tags/Apple/clang-(\d{2,})]
|
||||||
$1.to_i
|
$1.to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user