diff options
author | Joseph Myers <joseph@codesourcery.com> | 2007-03-22 20:38:27 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2007-03-22 20:38:27 +0000 |
commit | 9a200623651c1fe91e2377235e302da84dd47e18 (patch) | |
tree | 2bc90b2b69bca238979afbdfab5748dfe632c623 /gcc/c-incpath.c | |
parent | dd4a64247f0e8fb81da6be573bb03b95ad2c0846 (diff) | |
download | gcc-9a200623651c1fe91e2377235e302da84dd47e18.zip gcc-9a200623651c1fe91e2377235e302da84dd47e18.tar.gz gcc-9a200623651c1fe91e2377235e302da84dd47e18.tar.bz2 |
c-incpath.c (add_sysroot_to_chain): New.
* c-incpath.c (add_sysroot_to_chain): New.
(merge_include_chains): Add sysroot argument. Call
add_sysroot_to_chain if sysrooted.
(register_include_chains): Update call to merge_include_chains.
* doc/cppopts.texi: Document use of '=' in include directory
arguments.
From-SVN: r123134
Diffstat (limited to 'gcc/c-incpath.c')
-rw-r--r-- | gcc/c-incpath.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/gcc/c-incpath.c b/gcc/c-incpath.c index 3a9585b..3e819ce 100644 --- a/gcc/c-incpath.c +++ b/gcc/c-incpath.c @@ -51,7 +51,8 @@ static const char dir_separator_str[] = { DIR_SEPARATOR, 0 }; static void add_env_var_paths (const char *, int); static void add_standard_paths (const char *, const char *, const char *, int); static void free_path (struct cpp_dir *, int); -static void merge_include_chains (cpp_reader *, int); +static void merge_include_chains (const char *, cpp_reader *, int); +static void add_sysroot_to_chain (const char *, int); static struct cpp_dir *remove_duplicates (cpp_reader *, struct cpp_dir *, struct cpp_dir *, struct cpp_dir *, int); @@ -282,6 +283,19 @@ remove_duplicates (cpp_reader *pfile, struct cpp_dir *head, return head; } +/* Add SYSROOT to any user-supplied paths in CHAIN starting with + "=". */ + +static void +add_sysroot_to_chain (const char *sysroot, int chain) +{ + struct cpp_dir *p; + + for (p = heads[chain]; p != NULL; p = p->next) + if (p->name[0] == '=' && p->user_supplied_p) + p->name = concat (sysroot, p->name + 1, NULL); +} + /* Merge the four include chains together in the order quote, bracket, system, after. Remove duplicate dirs (as determined by INO_T_EQ()). @@ -293,8 +307,17 @@ remove_duplicates (cpp_reader *pfile, struct cpp_dir *head, written -iquote bar -Ifoo -Iquux. */ static void -merge_include_chains (cpp_reader *pfile, int verbose) +merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) { + /* Add the sysroot to user-supplied paths starting with "=". */ + if (sysroot) + { + add_sysroot_to_chain (sysroot, QUOTE); + add_sysroot_to_chain (sysroot, BRACKET); + add_sysroot_to_chain (sysroot, SYSTEM); + add_sysroot_to_chain (sysroot, AFTER); + } + /* Join the SYSTEM and AFTER chains. Remove duplicates in the resulting SYSTEM chain. */ if (heads[SYSTEM]) @@ -419,7 +442,7 @@ register_include_chains (cpp_reader *pfile, const char *sysroot, target_c_incpath.extra_includes (sysroot, iprefix, stdinc); - merge_include_chains (pfile, verbose); + merge_include_chains (sysroot, pfile, verbose); cpp_set_include_chains (pfile, heads[QUOTE], heads[BRACKET], quote_ignores_source_dir); |