aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Formula/ffmpeg.rb8
-rw-r--r--Library/Homebrew/extend/ENV.rb58
-rw-r--r--Library/Homebrew/formula.rb25
3 files changed, 59 insertions, 32 deletions
diff --git a/Library/Formula/ffmpeg.rb b/Library/Formula/ffmpeg.rb
index aead9a790..2ee2fb89a 100644
--- a/Library/Formula/ffmpeg.rb
+++ b/Library/Formula/ffmpeg.rb
@@ -38,9 +38,11 @@ class Ffmpeg < Formula
if MacOS.lion?
args << "--cc=clang"
else
- args << "--cc=clang" if ENV.use_clang?
- args << "--cc=llvm-gcc" if ENV.use_llvm?
- args << "--cc=gcc" if ENV.use_gcc?
+ args << case ENV.compiler
+ when :clang then "--cc=clang"
+ when :llvm then "--cc=llvm-gcc"
+ when :gcc then "--cc=gcc"
+ end
end
# For 32-bit compilation under gcc 4.2, see:
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index 019b8ae86..38852b817 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -25,14 +25,10 @@ module HomebrewEnvExtension
self['CC'] = '/usr/bin/cc'
self['CXX'] = '/usr/bin/c++'
- if MACOS_VERSION >= 10.6
- if self.use_clang?
- self.clang
- elsif self.use_llvm?
- self.llvm
- elsif self.use_gcc?
- self.gcc
- end
+ case self.compiler
+ when :clang then self.clang
+ when :llvm then self.llvm
+ when :gcc then self.gcc
end
# In rare cases this may break your builds, as the tool for some reason wants
@@ -141,7 +137,9 @@ module HomebrewEnvExtension
alias_method :gcc_4_2, :gcc
def llvm
- if MacOS.xcode_version < '4.1'
+ 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
@@ -151,8 +149,12 @@ module HomebrewEnvExtension
end
def clang
- self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/clang"
- self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/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
end
def fortran
@@ -310,14 +312,42 @@ Please take one of the following actions:
remove 'CXXFLAGS', f
end
+ def compiler
+ # TODO seems that ENV.clang in a Formula.install should warn when called
+ # if the user has set something that is tested here
+
+ # test for --flags first so that installs can be overridden on a per
+ # install basis
+ if ARGV.include? '--use-gcc'
+ :gcc
+ elsif ARGV.include? '--use-llvm'
+ :llvm
+ elsif ARGV.include? '--use-clang'
+ :clang
+ end
+
+ # test for ENVs in inverse order to flags, this is sensible, trust me
+ if self['HOMEBREW_USE_CLANG']
+ :clang
+ elsif self['HOMEBREW_USE_LLVM']
+ :llvm
+ elsif self['HOMEBREW_USE_GCC']
+ :gcc
+ else
+ :gcc
+ end
+ end
+
+ # don't use in new code
+ # don't remove though, but do add to compatibility.rb
def use_clang?
- self['HOMEBREW_USE_CLANG'] or ARGV.include? '--use-clang'
+ compiler == :clang
end
def use_gcc?
- self['HOMEBREW_USE_GCC'] or ARGV.include? '--use-gcc'
+ compiler == :gcc
end
def use_llvm?
- self['HOMEBREW_USE_LLVM'] or ARGV.include? '--use-llvm'
+ compiler == :llvm
end
def make_jobs
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 51e5dd397..add827979 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -296,23 +296,18 @@ class Formula
end
def handle_llvm_failure llvm
- unless ENV.use_llvm? or ENV.use_clang?
- ENV.gcc_4_2 if MacOS.default_cc =~ /llvm/
- return
- end
-
- opoo "LLVM was requested, but this formula is reported as not working with LLVM:"
- puts llvm.reason
-
- if ARGV.force?
- puts "Continuing anyway.\n" +
- "If this works, let us know so we can update the formula to remove the warning."
+ case ENV.compiler
+ case :llvm, :clang
+ opoo "LLVM was requested, but this formula is reported to not work with LLVM:"
+ puts llvm.reason
+ puts
+ puts "We are continuing anyway so the build succeeds, please let us know so we can"
+ puts "update the formula. If it doesn't work you can: brew install --use-gcc"
+ puts
else
- puts "Continuing with GCC 4.2 instead.\n"+
- "(Use `brew install --force #{name}` to force use of LLVM.)"
- ENV.gcc_4_2
+ ENV.gcc if MacOS.default_cc =~ /llvm/
+ return
end
- puts
end
def self.class_s name