---
 gcc-3.4.4/gcc/c-incpath.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+)

Index: b/gcc-3.4.4/gcc/c-incpath.c
===================================================================
--- a/gcc-3.4.4/gcc/c-incpath.c
+++ b/gcc-3.4.4/gcc/c-incpath.c
@@ -283,6 +283,34 @@ merge_include_chains (cpp_reader *pfile,
     }
 }
 
+static void
+check_for_localheaders(cpp_reader *pfile)
+{
+  int rval;
+  char* env_var = NULL;
+
+  env_var = getenv("WARN_ABOUT_LOCAL_HEADERS");
+
+  if (env_var != NULL && strcmp("YES", env_var) == 0)
+    {
+
+      struct cpp_dir *p;
+
+      for (p = heads[QUOTE];; p = p->next)
+	{
+	  if (!p)
+	    break;
+	  rval = strncmp(p->name, "/usr", 4);
+	  if (rval == 0)
+	    {
+	      fprintf(stderr, "Error: local search path for header files used: %s\n", p->name);
+	      cpp_error (pfile, CPP_DL_ERROR, "Please check environment variables, "
+	                 "-I options, and the default search path for this entry.\n");
+	    }
+	}
+    }
+}
+
 /* Use given -I paths for #include "..." but not #include <...>, and
    don't search the directory of the present file for #include "...".
    (Note that -I. -I- is not the same as the default setup; -I. uses
@@ -359,6 +387,8 @@ register_include_chains (cpp_reader *pfi
 
   merge_include_chains (pfile, verbose);
 
+  check_for_localheaders(pfile);
+
   cpp_set_include_chains (pfile, heads[QUOTE], heads[BRACKET],
 			  quote_ignores_source_dir);
 }

