summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos O'Donell <carlos@codesourcery.com>2006-11-20 17:15:27 +0000
committerCarlos O'Donell <carlos@gcc.gnu.org>2006-11-20 17:15:27 +0000
commit76642aabbd91c89cfae1c3ba2fa61785b6fbabd6 (patch)
tree97ba2bb27388441e1c8a03a879e691c010485917
parent9d691ba7501c741571edc1618c434316b1eb0170 (diff)
cppdefault.c: Define cpp_PREFIX, cpp_PREFIX_len, and gcc_exec_prefix.
gcc/ 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. Co-Authored-By: Mark Mitchell <mark@codesourcery.com> From-SVN: r119017
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/Makefile.in1
-rw-r--r--gcc/c-incpath.c12
-rw-r--r--gcc/cppdefault.c28
-rw-r--r--gcc/cppdefault.h7
5 files changed, 60 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bf8f895ded6..bdc6b36c96c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 8136290694e..c6334d70ec9 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -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) \
diff --git a/gcc/c-incpath.c b/gcc/c-incpath.c
index 0e534dd2337..2c5ac6db89f 100644
--- a/gcc/c-incpath.c
+++ b/gcc/c-incpath.c
@@ -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);
diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c
index d040558b54c..c72cb390aba 100644
--- a/gcc/cppdefault.c
+++ b/gcc/cppdefault.c
@@ -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;
+}
+
diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h
index a3a24169554..2da6d05f564 100644
--- a/gcc/cppdefault.h
+++ b/gcc/cppdefault.h
@@ -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 */