OSDN Git Service

gcc/
authorcarlos <carlos@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Nov 2006 17:15:27 +0000 (17:15 +0000)
committercarlos <carlos@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Nov 2006 17:15:27 +0000 (17:15 +0000)
2006-11-20  Carlos O'Donell  <carlos@codesourcery.com>
    Mark Mitchell  <mark@codesourcery.com>

* cppdefault.c: Define cpp_PREFIX, cpp_PREFIX_len, and
gcc_exec_prefix.
(cpp_relocated): New function.
* cppdefault.h: Declare cpp_PREFIX, cpp_PREFIX_len, gcc_exec_prefix
and cpp_relocated.
* Makefile.in (PREPROCESSOR_DEFINES): Add -DPREFIX option.
* c-incpath.c (add_standard_paths): Call cpp_relocated. If relocated,
replace configured prefix with gcc_exec_prefix.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119017 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/Makefile.in
gcc/c-incpath.c
gcc/cppdefault.c
gcc/cppdefault.h

index bf8f895..bdc6b36 100644 (file)
@@ -1,3 +1,15 @@
+2006-11-20  Carlos O'Donell  <carlos@codesourcery.com>
+           Mark Mitchell  <mark@codesourcery.com>
+
+       * cppdefault.c: Define cpp_PREFIX, cpp_PREFIX_len, and 
+       gcc_exec_prefix.
+       (cpp_relocated): New function.
+       * cppdefault.h: Declare cpp_PREFIX, cpp_PREFIX_len, gcc_exec_prefix 
+       and cpp_relocated. 
+       * Makefile.in (PREPROCESSOR_DEFINES): Add -DPREFIX option.
+       * c-incpath.c (add_standard_paths): Call cpp_relocated. If relocated,
+       replace configured prefix with gcc_exec_prefix. 
+
 2006-11-20  Bernd Schmidt  <bernd.schmidt@analog.com>
 
        * config/bfin/bfin.h (LEGITIMATE_CONSTANT_P): Call
index 8136290..c6334d7 100644 (file)
@@ -3071,6 +3071,7 @@ PREPROCESSOR_DEFINES = \
   -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
   -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
   -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
+  -DPREFIX=\"$(prefix)\" \
   @TARGET_SYSTEM_ROOT_DEFINE@
 
 cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
index 0e534dd..2c5ac6d 100644 (file)
@@ -127,6 +127,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
                    const char *imultilib, int cxx_stdinc)
 {
   const struct default_include *p;
+  int relocated = cpp_relocated();
   size_t len;
 
   if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0)
@@ -163,6 +164,17 @@ add_standard_paths (const char *sysroot, const char *iprefix,
          /* Should this directory start with the sysroot?  */
          if (sysroot && p->add_sysroot)
            str = concat (sysroot, p->fname, NULL);
+         else if (!p->add_sysroot && relocated)
+           {
+             /* If the compiler is relocated, and this is a configured 
+                prefix relative path, then we use gcc_exec_prefix instead 
+                of the configured prefix.  */
+             gcc_assert (strncmp (p->fname, cpp_PREFIX,
+                                    cpp_PREFIX_len) == 0);
+             str = concat (gcc_exec_prefix, p->fname
+                             + cpp_PREFIX_len, NULL);
+             str = update_path (str, p->component);
+           }
          else
            str = update_path (p->fname, p->component);
 
index d040558..c72cb39 100644 (file)
@@ -96,3 +96,31 @@ const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
 const char cpp_GCC_INCLUDE_DIR[] = "";
 const size_t cpp_GCC_INCLUDE_DIR_len = 0;
 #endif
+
+/* The configured prefix.  */
+const char cpp_PREFIX[] = PREFIX;
+const size_t cpp_PREFIX_len = sizeof PREFIX - 1;
+
+/* This value is set by cpp_relocated at runtime */
+const char *gcc_exec_prefix;
+
+/* Return true if the toolchain is relocated.  */
+bool
+cpp_relocated (void)
+{
+  static int relocated = -1;
+
+  /* A relocated toolchain ignores standard include directories.  */
+  if (relocated == -1)
+    {
+      /* Check if the toolchain was relocated?  */
+      GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX");
+      if (gcc_exec_prefix)
+       relocated = 1;
+      else
+       relocated = 0;
+    }
+
+  return relocated;
+}
+
index a3a2416..2da6d05 100644 (file)
@@ -52,4 +52,11 @@ extern const struct default_include cpp_include_defaults[];
 extern const char cpp_GCC_INCLUDE_DIR[];
 extern const size_t cpp_GCC_INCLUDE_DIR_len;
 
+extern const char cpp_PREFIX[];
+extern const size_t cpp_PREFIX_len;
+extern const char *gcc_exec_prefix;
+
+/* Return true if the toolchain is relocated.  */
+bool cpp_relocated (void);
+
 #endif /* ! GCC_CPPDEFAULT_H */