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
This commit is contained in:
Carlos O'Donell 2006-11-20 17:15:27 +00:00 committed by Carlos O'Donell
parent 9d691ba750
commit 76642aabbd
5 changed files with 60 additions and 0 deletions

View 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

View 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) \

View 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);

View 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;
}

View 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 */