diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 67ebb8b30c..45d2f11685 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -183,6 +183,10 @@ module HomebrewArgvExtension replace(old_args) end + def cc + value 'cc' + end + private def downcased_unique_named diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index f3bc50d589..aeb7ca4792 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -2,6 +2,8 @@ module SharedEnvExtension CC_FLAG_VARS = %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS} FC_FLAG_VARS = %w{FCFLAGS FFLAGS} + COMPILERS = ['clang', 'gcc-4.0', 'gcc-4.2', 'llvm-gcc'] + def remove_cc_etc keys = %w{CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS} removed = Hash[*keys.map{ |key| [key, self[key]] }.flatten] diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index cacd04dca7..a01e38efe6 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -344,7 +344,9 @@ module Stdenv # test for --flags first so that installs can be overridden on a per # install basis. Then test for ENVs in inverse order to flags, this is # sensible, trust me - @compiler ||= if ARGV.include? '--use-gcc' + @compiler ||= if (cc = ARGV.cc) + COMPILERS.grep(cc).pop ? cc : raise("Invalid value for --cc: #{cc}") + elsif ARGV.include? '--use-gcc' :gcc elsif ARGV.include? '--use-llvm' :llvm diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 5cf186b192..a24a0668df 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -122,7 +122,9 @@ module Superenv private def determine_cc - if ARGV.include? '--use-gcc' + if (cc = ARGV.cc) + COMPILERS.grep(cc).pop ? cc : raise("Invalid value for --cc: #{cc}") + elsif ARGV.include? '--use-gcc' gcc_installed = Formula.factory('apple-gcc42').installed? rescue false # fall back to something else on systems without Apple gcc if MacOS.locate('gcc-4.2') || gcc_installed