From 06dbec5aaf810e89596d8ad7582f1d8cf1b6d568 Mon Sep 17 00:00:00 2001
From: Jack Nagel <jacknagel@gmail.com>
Date: Mon, 4 Nov 2013 11:02:12 -0600
Subject: [PATCH] Disable make_fuss when running configure invoked by make

The cc wrapper's make_fuss is only enabled when HOMEBREW_CCCFG contains
'O', which is set by the make wrapper. This means it is disable when
running configure scripts. However, this does not include configure
scripts invoked by make, which inherit the value of HOMEBREW_CCCFG from
the make process. make_fuss will be enabled for these scripts, cause
breakage.

Configure scripts generated by autoconf 2.56 (November 2002) or later
export DUALCASE into the environment of subprocesses. This variable is
only used by the MKS shell, so we can use it as a heuristic to determine
if we are running as a subprocess of a configure script.
---
 Library/ENV/4.3/cc                   | 11 ++++++++++-
 Library/Homebrew/extend/ENV/super.rb |  4 ++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc
index 30f32b04aa..7f18b466ad 100755
--- a/Library/ENV/4.3/cc
+++ b/Library/ENV/4.3/cc
@@ -102,7 +102,7 @@ class Cmd
     when :ld
       ldflags + args
     end.compact
-    make_fuss(allflags) if verbose? and cccfg? 'O'
+    make_fuss(allflags)
     allflags
   end
   def refurbished_args
@@ -228,6 +228,8 @@ class Cmd
     sys.to_flags('-isystem') + opt.to_flags('-I')
   end
   def make_fuss args
+    return unless make_fuss?
+
     dels = @args - args
     adds = args - @args
     dups = dels & args
@@ -236,9 +238,16 @@ class Cmd
     STDERR.puts "brew: superenv deduped: #{dups}" unless dups.empty?
     STDERR.puts "brew: superenv added: #{adds*' '}" unless adds.empty?
   end
+  def make_fuss?
+    verbose? and cccfg? 'O' and not configure?
+  end
   def verbose?
     !ENV['VERBOSE'].nil? || !ENV['HOMEBREW_VERBOSE'].nil?
   end
+  def configure?
+    # configure scripts generated with autoconf 2.56 or later export DUALCASE
+    ENV.key? 'DUALCASE'
+  end
 end
 
 if __FILE__ == $PROGRAM_NAME
diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb
index 6c05bddb4f..ce8de00d08 100644
--- a/Library/Homebrew/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/ENV/super.rb
@@ -52,6 +52,10 @@ module Superenv
     delete('CDPATH') # avoid make issues that depend on changing directories
     delete('GREP_OPTIONS') # can break CMake
     delete('CLICOLOR_FORCE') # autotools doesn't like this
+
+    # Configure scripts generated by autoconf 2.56 or later export DUALCASE,
+    # which we use as a heuristic for running under configure
+    delete('DUALCASE')
   end
 
   def setup_build_environment(formula=nil)
-- 
GitLab