diff options
author | Daniel Jacobowitz <drow@mvista.com> | 2003-02-13 17:23:56 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@gcc.gnu.org> | 2003-02-13 17:23:56 +0000 |
commit | 047d636f544fad604aec883b45012d59369839fe (patch) | |
tree | 3d7379a3ec405d4e0f84ede65961991b09195727 /gcc/cppinit.c | |
parent | 902cf50c93298503d3966675cd01841b97c909e8 (diff) | |
download | gcc-047d636f544fad604aec883b45012d59369839fe.zip gcc-047d636f544fad604aec883b45012d59369839fe.tar.gz gcc-047d636f544fad604aec883b45012d59369839fe.tar.bz2 |
Makefile.in (PREPROCESSOR_DEFINES): Add @TARGET_SYSTEM_ROOT_DEFINE@.
* Makefile.in (PREPROCESSOR_DEFINES): Add
@TARGET_SYSTEM_ROOT_DEFINE@.
* configure.in (PREFIX_INCLUDE_DIR): Don't define if $with_sysroot
is specified or if building a cross compiler.
(TARGET_SYSTEM_ROOT_DEFINE): Add TARGET_SYSTEM_ROOT_RELOCATABLE
if the sysroot is under $exec_prefix.
* configure: Regenerated.
* cppdefault.h: Use native include paths if TARGET_SYSTEM_ROOT is
defined.
(struct default_include): Add add_sysroot field.
(cpp_SYSROOT): Declare.
* cppdefault.c (cpp_include_defaults): Fill in add_sysroot
field.
(cpp_SYSROOT): New variable.
* cppinit.c (cpp_create_reader): Initialize
CPP_OPTION (pfile, sysroot).
(init_standard_includes): Handle add_sysroot. Do not
add unrelocated copies of relocated directories.
(COMMAND_LINE_OPTIONS): Add -isysroot.
(cpp_handle_option): Handle -isysroot.
* cpplib.h (struct cpp_options): Add sysroot member.
* gcc.c (The Specs Language): Update description of %I.
(target_system_root_changed): New variable.
(process_command): Conditionalize make_relative_prefix call
on !VMS and TARGET_SYSTEM_ROOT_RELOCATABLE. Set
target_system_root_changed.
(do_spec_1): Add -isysroot to %I.
* doc/invoke.texi (Spec Files): Update description of %I.
* doc/install.texi (--with-sysroot): Update comment about
relocation.
From-SVN: r62853
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r-- | gcc/cppinit.c | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 591b4bf..40b5059 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -529,6 +529,7 @@ cpp_create_reader (lang) CPP_OPTION (pfile, warn_endif_labels) = 1; CPP_OPTION (pfile, warn_deprecated) = 1; CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99); + CPP_OPTION (pfile, sysroot) = cpp_SYSROOT; CPP_OPTION (pfile, pending) = (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending)); @@ -757,46 +758,26 @@ init_standard_includes (pfile) { const struct default_include *p; const char *specd_prefix = CPP_OPTION (pfile, include_prefix); + int default_len, specd_len; + char *default_prefix; /* Search "translated" versions of GNU directories. These have /usr/local/lib/gcc... replaced by specd_prefix. */ + default_len = 0; + specd_len = 0; + default_prefix = NULL; if (specd_prefix != 0 && cpp_GCC_INCLUDE_DIR_len) { /* Remove the `include' from /usr/local/lib/gcc.../include. GCC_INCLUDE_DIR will always end in /include. */ - int default_len = cpp_GCC_INCLUDE_DIR_len; - char *default_prefix = (char *) alloca (default_len + 1); - int specd_len = strlen (specd_prefix); + default_len = cpp_GCC_INCLUDE_DIR_len; + default_prefix = (char *) alloca (default_len + 1); + specd_len = strlen (specd_prefix); memcpy (default_prefix, cpp_GCC_INCLUDE_DIR, default_len); default_prefix[default_len] = '\0'; - - for (p = cpp_include_defaults; p->fname; p++) - { - /* Some standard dirs are only for C++. */ - if (!p->cplusplus - || (CPP_OPTION (pfile, cplusplus) - && !CPP_OPTION (pfile, no_standard_cplusplus_includes))) - { - /* Does this dir start with the prefix? */ - if (!strncmp (p->fname, default_prefix, default_len)) - { - /* Yes; change prefix and add to search list. */ - int flen = strlen (p->fname); - int this_len = specd_len + flen - default_len; - char *str = (char *) xmalloc (this_len + 1); - memcpy (str, specd_prefix, specd_len); - memcpy (str + specd_len, - p->fname + default_len, - flen - default_len + 1); - - append_include_chain (pfile, str, SYSTEM, p->cxx_aware); - } - } - } } - /* Search ordinary names for GNU include directories. */ for (p = cpp_include_defaults; p->fname; p++) { /* Some standard dirs are only for C++. */ @@ -804,7 +785,30 @@ init_standard_includes (pfile) || (CPP_OPTION (pfile, cplusplus) && !CPP_OPTION (pfile, no_standard_cplusplus_includes))) { - char *str = update_path (p->fname, p->component); + char *str; + + /* Should this dir start with the sysroot? */ + if (p->add_sysroot && CPP_OPTION (pfile, sysroot)) + str = concat (CPP_OPTION (pfile, sysroot), p->fname, NULL); + + /* Does this dir start with the prefix? */ + else if (default_len + && !strncmp (p->fname, default_prefix, default_len)) + { + /* Yes; change prefix and add to search list. */ + int flen = strlen (p->fname); + int this_len = specd_len + flen - default_len; + + str = (char *) xmalloc (this_len + 1); + memcpy (str, specd_prefix, specd_len); + memcpy (str + specd_len, + p->fname + default_len, + flen - default_len + 1); + } + + else + str = update_path (p->fname, p->component); + append_include_chain (pfile, str, SYSTEM, p->cxx_aware); } } @@ -1161,6 +1165,7 @@ new_pending_directive (pend, text, handler) DEF_OPT("imacros", no_fil, OPT_imacros) \ DEF_OPT("include", no_fil, OPT_include) \ DEF_OPT("iprefix", no_pth, OPT_iprefix) \ + DEF_OPT("isysroot", no_dir, OPT_isysroot) \ DEF_OPT("isystem", no_dir, OPT_isystem) \ DEF_OPT("iwithprefix", no_dir, OPT_iwithprefix) \ DEF_OPT("iwithprefixbefore", no_dir, OPT_iwithprefixbefore) @@ -1305,6 +1310,10 @@ cpp_handle_option (pfile, argc, argv) CPP_OPTION (pfile, include_prefix_len) = strlen (arg); break; + case OPT_isysroot: + CPP_OPTION (pfile, sysroot) = arg; + break; + case OPT_A: if (arg[0] == '-') { |