From a055692a25c10bcd8fd90825cc39709f455335b2 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Thu, 22 Jun 2017 14:37:17 +0000 Subject: Support $SYSROOT for = in -I etc. * incpath.c (add_sysroot_to_chain): Allow for $SYSROOT prefix. * doc/cppdiropts.texi (-I @var{dir}): Document it. From-SVN: r249560 --- gcc/incpath.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'gcc/incpath.c') diff --git a/gcc/incpath.c b/gcc/incpath.c index 98fe5ec9ab3..47942e2547d 100644 --- a/gcc/incpath.c +++ b/gcc/incpath.c @@ -314,7 +314,7 @@ remove_duplicates (cpp_reader *pfile, struct cpp_dir *head, } /* Add SYSROOT to any user-supplied paths in CHAIN starting with - "=". */ + "=" or "$SYSROOT". */ static void add_sysroot_to_chain (const char *sysroot, int chain) @@ -322,8 +322,15 @@ 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); + { + if (p->user_supplied_p) + { + if (p->name[0] == '=') + p->name = concat (sysroot, p->name + 1, NULL); + if (strncmp (p->name, "$SYSROOT", strlen ("$SYSROOT")) == 0) + p->name = concat (sysroot, p->name + strlen ("$SYSROOT"), NULL); + } + } } /* Merge the four include chains together in the order quote, bracket, -- cgit v1.2.3