gcc 3.2's cpp breaks configure scripts

John David Anglin dave@hiauly1.hia.nrc.ca
Thu Aug 1 20:09:00 GMT 2002


> John David Anglin wrote:
> > The gcc warning is correct in the cases that I have examined.  I don't
> > believe that configure should be adding include directories to CPPFLAGS
> > that are already being searched as system directories by gcc.  This
> > changes the include search order as noted in the warning and may
> > cause unexpected results.
> >
> Ah but which are theses directories?  There is no way to know as far
> as I can see.  (If you don't fancy doing some rather serious parsing
> of either the specfile, the output from -dumpspecs or from gcc -v -E).

Enclosed is a patch to the gettext macros lib-link.m4 and lib-prefix.m4
to prevent them from appending GCC system directories to CPPFLAGS.  It
uses "gcc -v -E" and checks for the warning.  I have tested the patch
by building textutils-2.1 using the new macros.  Possibly, the macros
can be improved but the patch seems to be doing what I want.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2002-07-31  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* lib-link.m4: Don't add GCC system include directories to CPPFLAGS.
	* lib-prefix.m4: Likewise.

--- lib-link.m4.orig	Sat Jul 20 03:15:04 2002
+++ lib-link.m4	Thu Aug  1 21:57:16 2002
@@ -345,9 +345,10 @@
               dnl But don't add it
               dnl   1. if it's the standard /usr/include,
               dnl   2. if it's /usr/local/include and we are using GCC on Linux,
-              dnl   3. if it's already present in $CPPFLAGS or the already
+              dnl   3. if it doesn't exist as a directory.
+              dnl   4. if it's a GCC system include directory,
+              dnl   5. if it's already present in $CPPFLAGS or the already
               dnl      constructed $INCNAME,
-              dnl   4. if it doesn't exist as a directory.
               if test "X$additional_includedir" != "X/usr/include"; then
                 haveit=
                 if test "X$additional_includedir" = "X/usr/local/include"; then
@@ -358,6 +359,17 @@
                   fi
                 fi
                 if test -z "$haveit"; then
+                  if test -d "$additional_includedir"; then
+                    if test -n "$GCC"; then
+                      if test -n "`echo 'main (){}' | $CC -v -E -I$additional_includedir - 2>&1 | grep 'changing search order for system directory'`"; then
+                        haveit=yes
+                      fi
+                    fi
+                  else
+                    haveit=yes
+                  fi
+                fi
+                if test -z "$haveit"; then
                   for x in $CPPFLAGS $INC[]NAME; do
                     AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
                     if test "X$x" = "X-I$additional_includedir"; then
@@ -366,10 +378,8 @@
                     fi
                   done
                   if test -z "$haveit"; then
-                    if test -d "$additional_includedir"; then
-                      dnl Really add $additional_includedir to $INCNAME.
-                      INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
-                    fi
+                    dnl Really add $additional_includedir to $INCNAME.
+                    INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
                   fi
                 fi
               fi
--- lib-prefix.m4.orig	Sat Feb 16 06:24:09 2002
+++ lib-prefix.m4	Thu Aug  1 22:00:57 2002
@@ -51,6 +51,7 @@
     dnl   2. if it's already present in $CPPFLAGS,
     dnl   3. if it's /usr/local/include and we are using GCC on Linux,
     dnl   4. if it doesn't exist as a directory.
+    dnl   5. if it's a GCC system include directory,
     if test "X$additional_includedir" != "X/usr/include"; then
       haveit=
       for x in $CPPFLAGS; do
@@ -68,11 +69,20 @@
             esac
           fi
         fi
-        if test -z "$haveit"; then
-          if test -d "$additional_includedir"; then
-            dnl Really add $additional_includedir to $CPPFLAGS.
-            CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
+      fi
+      if test -z "$haveit"; then
+        if test -d "$additional_includedir"; then
+          if test -n "$GCC"; then
+            if test -n "`echo 'main (){}' | $CC -v -E -I$additional_includedir - 2>&1 | grep 'changing search order for system directory'`"; then
+              haveit=yes
+            fi
           fi
+        else
+          haveit=yes
+        fi
+        if test -z "$haveit"; then
+          dnl Really add $additional_includedir to $CPPFLAGS.
+          CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
         fi
       fi
     fi



More information about the Gcc mailing list