From a0763dfc2c2e95a19c8e1789ad8f4d25710f3029 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 31 Aug 2011 17:50:39 +0100 Subject: [PATCH] Remove Xcode dependence from ENV.rb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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… --- Library/Homebrew/extend/ENV.rb | 41 ++++++++++------------------------ 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index b894c000d4..5b9c13125d 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -27,6 +27,10 @@ module HomebrewEnvExtension when :gcc then self.gcc 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 # 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 @@ -111,50 +115,29 @@ module HomebrewEnvExtension end 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.O3 + remove_from_cflags '-O4' remove_from_cflags '-march=core2' remove_from_cflags %r{-msse4(\.\d)?} end alias_method :gcc_4_0, :gcc_4_0_1 def gcc - if MacOS.xcode_version < '4' - self['CC'] = '/usr/bin/cc' - 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 + self['CC'] = "/usr/bin/gcc-4.2" + self['CXX'] = "/usr/bin/g++-4.2" remove_from_cflags '-O4' end alias_method :gcc_4_2, :gcc def llvm - if MacOS.xcode_version < '4' - self.gcc - 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 + self['CC'] = "/usr/bin/llvm-gcc" + self['CXX'] = "/usr/bin/llvm-g++" end def clang - if MacOS.xcode_version > '4' - self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/clang" - self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/clang++" - else - self.gcc - end + self['CC'] = "/usr/bin/clang" + self['CXX'] = "/usr/bin/clang++" end def fortran