Remove Xcode dependence from ENV.rb
Fixes Homebrew/homebrew#7329. Fixes Homebrew/homebrew#7269. Fixes Homebrew/homebrew#7236. Also quite a lot of tidy. This should all work fine. I think we only started referring into xcode_prefix because LLVM used to not be linked into /usr/bin. But for sure this is no longer true. If someone out there doesn't link cc etc. into /usr/bin then I guess we can revise this patch but it's not something we officially supported before, it was just an accident. I added a test step in the init code so that a working compiler will always be selected. This is mainly a fallback for old Xcodes. Though a comment in another area of the code suggested Xcode 3 on 10.5 doesn't have LLVM so…
This commit is contained in:
parent
23dbe43fb7
commit
a0763dfc2c
@ -27,6 +27,10 @@ module HomebrewEnvExtension
|
|||||||
when :gcc then self.gcc
|
when :gcc then self.gcc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# we must have a working compiler!
|
||||||
|
ENV['CC'] = '/usr/bin/cc' unless File.exist? ENV['CC']
|
||||||
|
ENV['CXX'] = '/usr/bin/c++' unless File.exist? ENV['CXX']
|
||||||
|
|
||||||
# In rare cases this may break your builds, as the tool for some reason wants
|
# In rare cases this may break your builds, as the tool for some reason wants
|
||||||
# to use a specific linker. However doing this in general causes formula to
|
# to use a specific linker. However doing this in general causes formula to
|
||||||
# build more successfully because we are changing CC and many build systems
|
# build more successfully because we are changing CC and many build systems
|
||||||
@ -111,50 +115,29 @@ module HomebrewEnvExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
def gcc_4_0_1
|
def gcc_4_0_1
|
||||||
self['CC'] = self['LD'] = '/usr/bin/gcc-4.0'
|
self['CC'] = '/usr/bin/gcc-4.0'
|
||||||
self['CXX'] = '/usr/bin/g++-4.0'
|
self['CXX'] = '/usr/bin/g++-4.0'
|
||||||
self.O3
|
remove_from_cflags '-O4'
|
||||||
remove_from_cflags '-march=core2'
|
remove_from_cflags '-march=core2'
|
||||||
remove_from_cflags %r{-msse4(\.\d)?}
|
remove_from_cflags %r{-msse4(\.\d)?}
|
||||||
end
|
end
|
||||||
alias_method :gcc_4_0, :gcc_4_0_1
|
alias_method :gcc_4_0, :gcc_4_0_1
|
||||||
|
|
||||||
def gcc
|
def gcc
|
||||||
if MacOS.xcode_version < '4'
|
self['CC'] = "/usr/bin/gcc-4.2"
|
||||||
self['CC'] = '/usr/bin/cc'
|
self['CXX'] = "/usr/bin/g++-4.2"
|
||||||
self['CXX'] = '/usr/bin/c++'
|
|
||||||
elsif MacOS.xcode_version >= '4.2'
|
|
||||||
# Apple stopped adding the -4.2 suffixes
|
|
||||||
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/gcc"
|
|
||||||
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/g++"
|
|
||||||
else
|
|
||||||
# With Xcode4 cc, c++, gcc and g++ are actually symlinks to llvm-gcc
|
|
||||||
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/gcc-4.2"
|
|
||||||
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/g++-4.2"
|
|
||||||
end
|
|
||||||
remove_from_cflags '-O4'
|
remove_from_cflags '-O4'
|
||||||
end
|
end
|
||||||
alias_method :gcc_4_2, :gcc
|
alias_method :gcc_4_2, :gcc
|
||||||
|
|
||||||
def llvm
|
def llvm
|
||||||
if MacOS.xcode_version < '4'
|
self['CC'] = "/usr/bin/llvm-gcc"
|
||||||
self.gcc
|
self['CXX'] = "/usr/bin/llvm-g++"
|
||||||
elsif MacOS.xcode_version < '4.1'
|
|
||||||
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-gcc"
|
|
||||||
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-g++"
|
|
||||||
else
|
|
||||||
self['CC'] = '/usr/bin/cc'
|
|
||||||
self['CXX'] = '/usr/bin/c++'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def clang
|
def clang
|
||||||
if MacOS.xcode_version > '4'
|
self['CC'] = "/usr/bin/clang"
|
||||||
self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/clang"
|
self['CXX'] = "/usr/bin/clang++"
|
||||||
self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/clang++"
|
|
||||||
else
|
|
||||||
self.gcc
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def fortran
|
def fortran
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user