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
+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
-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) \
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)
/* 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);
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;
+}
+
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 */