diff --git a/gcc/cccp.c b/gcc/cccp.c index 54a95d27c29..979ad89f5ee 100644 --- a/gcc/cccp.c +++ b/gcc/cccp.c @@ -65,7 +65,6 @@ typedef unsigned char U_CHAR; #include #ifndef VMS -#include #ifndef USG #include /* for __DATE__ and __TIME__ */ #include @@ -886,6 +885,7 @@ main (argc, argv) char **pend_assertion_options = (char **) xmalloc (argc * sizeof (char *)); int inhibit_predefs = 0; int no_standard_includes = 0; + int no_standard_cplusplus_includes = 0; int missing_newline = 0; /* Non-0 means don't output the preprocessed program. */ @@ -1266,6 +1266,9 @@ main (argc, argv) /* -nostdinc causes no default include directories. You must specify all include-file directories with -I. */ no_standard_includes = 1; + else if (!strcmp (argv[i], "-nostdinc++")) + /* -nostdinc++ causes no default C++-specific include directories. */ + no_standard_cplusplus_includes = 1; else if (!strcmp (argv[i], "-noprecomp")) no_precomp = 1; break; @@ -1501,7 +1504,7 @@ main (argc, argv) if (specd_prefix != 0 && default_len != 0) for (p = include_defaults; p->fname; p++) { /* Some standard dirs are only for C++. */ - if (!p->cplusplus || cplusplus) { + if (!p->cplusplus || (cplusplus && !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. */ @@ -1533,7 +1536,7 @@ main (argc, argv) /* Search ordinary names for GNU include directories. */ for (p = include_defaults; p->fname; p++) { /* Some standard dirs are only for C++. */ - if (!p->cplusplus || cplusplus) { + if (!p->cplusplus || (cplusplus && !no_standard_cplusplus_includes)) { struct file_name_list *new = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); new->control_macro = 0; diff --git a/gcc/gcc.c b/gcc/gcc.c index 16eda227e47..c67fcb463a5 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -34,20 +34,19 @@ compilation is specified by a string called a "spec". */ #include #include #include -#include #include #include "config.h" #include "obstack.h" #include "gvarargs.h" -#ifdef USG #ifndef R_OK #define R_OK 4 #define W_OK 2 #define X_OK 1 #endif +#ifdef USG #define vfork fork #endif /* USG */ @@ -395,7 +394,7 @@ static struct compiler default_compilers[] = { {".c", "@c"}, {"@c", - "cpp -lang-c %{nostdinc} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ + "cpp -lang-c %{nostdinc*} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d}\ -undef -D__GNUC__=2 %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\ @@ -415,7 +414,7 @@ static struct compiler default_compilers[] = %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%b.o}\ %{!pipe:%g.s} %A\n }}}}"}, {"-", - "%{E:cpp -lang-c %{nostdinc} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ + "%{E:cpp -lang-c %{nostdinc*} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d}\ -undef -D__GNUC__=2 %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\ @@ -427,7 +426,7 @@ static struct compiler default_compilers[] = %{!E:%e-E required when input is from standard input}"}, {".m", "@objective-c"}, {"@objective-c", - "cpp -lang-objc %{nostdinc} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ + "cpp -lang-objc %{nostdinc*} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d}\ -undef -D__OBJC__ -D__GNUC__=2 %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\ @@ -450,7 +449,7 @@ static struct compiler default_compilers[] = {".h", "@c-header"}, {"@c-header", "%{!E:%eCompilation of header file requested} \ - cpp %{nostdinc} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ + cpp %{nostdinc*} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} \ -undef -D__GNUC__=2 %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\ @@ -463,7 +462,7 @@ static struct compiler default_compilers[] = {".cxx", "@c++"}, {".C", "@c++"}, {"@c++", - "cpp -lang-c++ %{nostdinc} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ + "cpp -lang-c++ %{nostdinc*} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ %{C:%{!E:%eGNU C++ does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} \ -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus \ @@ -509,7 +508,7 @@ static struct compiler default_compilers[] = %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%b.o} %i %A\n }"}, {".S", "@assembler-with-cpp"}, {"@assembler-with-cpp", - "cpp -lang-asm %{nostdinc} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ + "cpp -lang-asm %{nostdinc*} %{C} %{v} %{A*} %{D*} %{U*} %{I*} %{i*} %{P}\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{trigraphs} \ -undef -$ %{!undef:%p %P} -D__ASSEMBLER__ \ @@ -533,16 +532,17 @@ static int n_default_compilers #ifdef LINK_LIBGCC_SPECIAL /* Have gcc do the search. */ +/* -u* was put back because both BSD and SysV seem to support it. */ static char *link_command_spec = "\ %{!c:%{!M:%{!MM:%{!E:%{!S:ld %X %l %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \ - %{r} %{s} %{T*} %{t} %{x} %{z}\ + %{r} %{s} %{T*} %{t} %{u*} %{x} %{z}\ %{!A:%{!nostdlib:%S}} \ %{L*} %D %o %{!nostdlib:libgcc.a%s %L libgcc.a%s %{!A:%E}}\n }}}}}"; #else /* Use -l and have the linker do the search. */ static char *link_command_spec = "\ %{!c:%{!M:%{!MM:%{!E:%{!S:ld %X %l %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \ - %{r} %{s} %{T*} %{t} %{x} %{z}\ + %{r} %{s} %{T*} %{t} %{u*} %{x} %{z}\ %{!A:%{!nostdlib:%S}} \ %{L*} %D %o %{!nostdlib:-lgcc %L -lgcc %{!A:%E}}\n }}}}}"; #endif