diff --git a/Library/Homebrew/brewkit.rb b/Library/Homebrew/brewkit.rb index 4c9bdbc262..ce15625a01 100644 --- a/Library/Homebrew/brewkit.rb +++ b/Library/Homebrew/brewkit.rb @@ -37,7 +37,7 @@ require 'hardware' MACOS_VERSION=$1.to_f ENV['MACOSX_DEPLOYMENT_TARGET']=$1 -# to be consistent with cflags, we ignore the existing environment +# ignore existing build vars, thus we should have less bugs to deal with ENV['LDFLAGS']="" cflags=%w[-O3] @@ -63,9 +63,12 @@ else cflags<<"-march=prescott" end cflags<<"-mfpmath=sse" - # gcc 4.0 is the default on Leopard - ENV['CC']="gcc-4.2" - ENV['CXX']="g++-4.2" + + # use gcc 4.2 if available (Xcode 3.1 and above) + if system "which -s gcc-4.2" and $?.success? + ENV['CC']="gcc-4.2" + ENV['CXX']="g++-4.2" + end end cflags<<"-mmmx" diff --git a/bin/brew b/bin/brew index e58fa38db0..b8e726c603 100755 --- a/bin/brew +++ b/bin/brew @@ -75,13 +75,18 @@ begin exit 0 end + require 'brewkit' + if ARGV.verbose? - require 'brewkit' ohai "Build Environment" %w[CFLAGS LDFLAGS CPPFLAGS MAKEFLAGS CC CXX].each do |f| puts "#{f}: #{ENV[f]}" unless ENV[f].to_s.empty? end end + + unless system "which #{ENV['CC'] or 'cc'} &> /dev/null" and $?.success? + raise "We cannot find a c compiler, have you installed the latest Xcode?" + end # we need to ensure a pristine ENV for each process or the formula # will start with the ENV from the previous build