From 71268b7f16f017a94304488e3b3cbc4c1ca3bfe7 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Thu, 22 Aug 2013 22:29:49 -0700 Subject: [PATCH] Provide reusable GNU GCC constants in ENV --- Library/Homebrew/extend/ENV/shared.rb | 13 ++++++++++--- Library/Homebrew/extend/ENV/super.rb | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index 7e8b4e0958..4800ed7c49 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -2,7 +2,10 @@ 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', /(gcc-\d\.\d)/] + # Update these every time a new GNU GCC branch is released + GNU_GCC_VERSIONS = (3..9) + GNU_GCC_REGEXP = /gcc-(4\.[3-9])/ + COMPLER_ALIASES = {'gcc' => 'gcc-4.2', 'llvm' => 'llvm-gcc'} COMPILER_SYMBOL_MAP = { 'gcc-4.0' => :gcc_4_0, 'gcc-4.2' => :gcc, @@ -80,8 +83,12 @@ module SharedEnvExtension def compiler if (cc = ARGV.cc) - raise("Invalid value for --cc: #{cc}") if COMPILERS.grep(cc).empty? - COMPILER_SYMBOL_MAP.fetch(cc, cc) + COMPILER_SYMBOL_MAP.fetch(cc) do |other| + if other =~ GNU_GCC_REGEXP then other + else + raise "Invalid value for --cc: #{other}" + end + end elsif ARGV.include? '--use-gcc' gcc_installed = Formula.factory('apple-gcc42').installed? rescue false # fall back to something else on systems without Apple gcc diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 49a59017c3..2b39572097 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -110,7 +110,7 @@ module Superenv append_path('PATH', apple_gcc42.opt_prefix/'bin') if apple_gcc42 end - if ENV['HOMEBREW_CC'] =~ /gcc-(\d\.\d)/ && $1 != '4.2' + if ENV['HOMEBREW_CC'] =~ GNU_GCC_REGEXP warn_about_non_apple_gcc($1) end end