summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/egcs/gcc/cccp.c62
-rw-r--r--gnu/egcs/gcc/cppinit.c67
-rw-r--r--gnu/egcs/gcc/cpplib.h7
-rw-r--r--gnu/egcs/gcc/cppspec.c13
-rw-r--r--gnu/egcs/gcc/gcc.c19
5 files changed, 146 insertions, 22 deletions
diff --git a/gnu/egcs/gcc/cccp.c b/gnu/egcs/gcc/cccp.c
index dfb2157e65c..052542807c4 100644
--- a/gnu/egcs/gcc/cccp.c
+++ b/gnu/egcs/gcc/cccp.c
@@ -154,6 +154,7 @@ static int no_trigraphs = 0;
2 means #include <...> as well. */
static int print_deps = 0;
+static int print_phony = 0;
/* Nonzero if missing .h files in -M output are assumed to be generated
files and not errors. */
@@ -864,6 +865,12 @@ static IF_STACK_FRAME *if_stack = NULL;
/* Buffer of -M output. */
static char *deps_buffer;
+/* Target-name to write with the dependency information. */
+char *deps_target_base;
+
+/* the prefix string that actually gets written containing the target */
+char *deps_target_full;
+
/* Number of bytes allocated in above. */
static int deps_allocated_size;
@@ -1561,6 +1568,24 @@ main (argc, argv)
print_deps_missing_files = 1;
break;
}
+ if (!strcmp(argv[i], "-MT")) {
+ if (i + 1 == argc)
+ fatal ("Filename missing after %s option", argv[i]);
+ i++;
+ deps_target_base = argv[i];
+ break;
+ }
+ if (!strcmp(argv[i], "-MF")) {
+ if (i + 1 == argc)
+ fatal ("Filename missing after %s option", argv[i]);
+ i++;
+ deps_file = argv[i];
+ break;
+ }
+ if (!strcmp(argv[i], "-MP")) {
+ print_phony = 1;
+ break;
+ }
if (!strcmp (argv[i], "-M"))
print_deps = 2;
else if (!strcmp (argv[i], "-MM"))
@@ -1946,6 +1971,8 @@ main (argc, argv)
inhibit compilation. */
if (print_deps_missing_files && (print_deps == 0 || !inhibit_output))
fatal ("-MG must be specified with one of -M or -MM");
+ if (print_phony && print_deps == 0)
+ fatal ("-MP must be specified with one of -M, -MM, -MD, or -MMD");
/* Either of two environment variables can specify output of deps.
Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
@@ -1994,13 +2021,24 @@ main (argc, argv)
deps_size = 0;
deps_column = 0;
- if (deps_target) {
- deps_output (deps_target, ':');
+ if (deps_target_base) {
+ int size = strlen(deps_target_base) + strlen(in_fname) + 3;
+
+ deps_target_full = (char *) xmalloc (size);
+ strlcpy(deps_target_full, deps_target_base, size);
+ strlcat(deps_target_full, ": ", size);
+ strlcat(deps_target_full, in_fname, size);
+ } else if (deps_target) {
+ int size = strlen(deps_target) + 3;
+
+ deps_target_full = (char *) xmalloc (size);
+ strlcpy(deps_target_full, deps_target, size);
+ strlcat(deps_target_full, ": ", size);
} else if (*in_fname == 0) {
- deps_output ("-", ':');
+ deps_target_full = xstrdup("-: ");
} else {
char *p, *q;
- int len;
+ int len, size;
q = base_name (in_fname);
@@ -2036,8 +2074,11 @@ main (argc, argv)
/* Supply our own suffix. */
strcpy (q, OBJECT_SUFFIX);
- deps_output (p, ':');
- deps_output (in_fname, ' ');
+ size = strlen(p) + strlen(in_fname) + 3;
+ deps_target_full = (char *) xmalloc (size);
+ strlcpy(deps_target_full, p, size);
+ strlcat(deps_target_full, ": ", size);
+ strlcat(deps_target_full, in_fname, size);
}
}
@@ -2174,8 +2215,15 @@ main (argc, argv)
if (errors == 0) {
if (deps_file && ! (deps_stream = fopen (deps_file, deps_mode)))
pfatal_with_name (deps_file);
+ fputs (deps_target_full, deps_stream);
+ fputs (" \\\n ", deps_stream);
fputs (deps_buffer, deps_stream);
putc ('\n', deps_stream);
+ if (print_phony) {
+ fputs (deps_buffer, deps_stream);
+ putc (':', deps_stream);
+ putc ('\n', deps_stream);
+ }
if (deps_file) {
if (ferror (deps_stream) || fclose (deps_stream) != 0)
fatal ("I/O error on output");
@@ -10601,7 +10649,7 @@ deps_output (string, spacer)
deps_allocated_size = (deps_size + 2 * size + 50) * 2;
deps_buffer = xrealloc (deps_buffer, deps_allocated_size);
}
- if (spacer == ' ') {
+ if (spacer == ' ' && deps_column > 0) {
deps_buffer[deps_size++] = ' ';
deps_column++;
}
diff --git a/gnu/egcs/gcc/cppinit.c b/gnu/egcs/gcc/cppinit.c
index 9994b32a885..c5e75b510f1 100644
--- a/gnu/egcs/gcc/cppinit.c
+++ b/gnu/egcs/gcc/cppinit.c
@@ -570,6 +570,11 @@ cpp_cleanup (pfile)
pfile->deps_buffer = NULL;
pfile->deps_allocated_size = 0;
}
+ if (pfile->deps_target_full)
+ {
+ free (pfile->deps_target_full);
+ pfile->deps_target_full = NULL;
+ }
if (pfile->input_buffer)
{
@@ -718,14 +723,29 @@ initialize_dependency_output (pfile)
pfile->deps_size = 0;
pfile->deps_column = 0;
- if (opts->deps_target)
- deps_output (pfile, opts->deps_target, ':');
+ if (pfile->deps_target_base)
+ {
+ int size = strlen(pfile->deps_target_base) + strlen(opts->in_fname) + 3;
+
+ pfile->deps_target_full = (char *) xmalloc (size);
+ strlcpy(pfile->deps_target_full, pfile->deps_target_base, size);
+ strlcat(pfile->deps_target_full, ": ", size);
+ strlcat(pfile->deps_target_full, opts->in_fname, size);
+ }
+ else if (opts->deps_target)
+ {
+ int size = strlen(opts->deps_target) + 3;
+
+ pfile->deps_target_full = (char *) xmalloc (size);
+ strlcpy(pfile->deps_target_full, opts->deps_target, size);
+ strlcat(pfile->deps_target_full, ": ", size);
+ }
else if (*opts->in_fname == 0)
- deps_output (pfile, "-", ':');
+ pfile->deps_target_full = xstrdup("-: ");
else
{
char *p, *q, *r;
- int len, x;
+ int len, x, size;
/* Discard all directory prefixes from filename. */
q = base_name (opts->in_fname);
@@ -754,8 +774,11 @@ initialize_dependency_output (pfile)
/* Supply our own suffix. */
strcpy (q, OBJECT_SUFFIX);
- deps_output (pfile, p, ':');
- deps_output (pfile, opts->in_fname, ' ');
+ size = strlen(p) + strlen(opts->in_fname) + 3;
+ pfile->deps_target_full = (char *) xmalloc (size);
+ strlcpy(pfile->deps_target_full, p, size);
+ strlcat(pfile->deps_target_full, ": ", size);
+ strlcat(pfile->deps_target_full, opts->in_fname, size);
}
}
@@ -785,6 +808,11 @@ cpp_start_read (pfile, fname)
cpp_fatal (pfile, "-MG must be specified with one of -M or -MM");
return 0;
}
+ if (opts->print_phony && opts->print_deps == 0)
+ {
+ cpp_fatal (pfile, "-MP must be specified with one of -M, -MM, -MD, or -MMD");
+ return 0;
+ }
/* Chill should not be used with -trigraphs. */
if (opts->chill && opts->trigraphs)
@@ -1095,8 +1123,16 @@ cpp_finish (pfile)
deps_stream = stdout;
else if ((deps_stream = fopen (opts->deps_file, deps_mode)) == 0)
cpp_pfatal_with_name (pfile, opts->deps_file);
+ fputs (pfile->deps_target_full, deps_stream);
+ fputs (" \\\n ", deps_stream);
fputs (pfile->deps_buffer, deps_stream);
putc ('\n', deps_stream);
+ if (opts->print_phony)
+ {
+ fputs (pfile->deps_buffer, deps_stream);
+ putc (':', deps_stream);
+ putc ('\n', deps_stream);
+ }
if (opts->deps_file)
{
if (ferror (deps_stream) || fclose (deps_stream) != 0)
@@ -1457,6 +1493,25 @@ cpp_handle_option (pfile, argc, argv)
opts->print_deps_missing_files = 1;
break;
}
+ if (!strcmp(argv[i], "-MT"))
+ {
+ if (i+1 == argc)
+ goto missing_filename;
+ pfile->deps_target_base = argv[++i];
+ break;
+ }
+ if (!strcmp(argv[i], "-MF"))
+ {
+ if (i+1 == argc)
+ goto missing_filename;
+ opts->deps_file = argv[++i];
+ break;
+ }
+ if (!strcmp(argv[i], "-MP"))
+ {
+ opts->print_phony = 1;
+ break;
+ }
if (!strcmp (argv[i], "-M"))
opts->print_deps = 2;
else if (!strcmp (argv[i], "-MM"))
diff --git a/gnu/egcs/gcc/cpplib.h b/gnu/egcs/gcc/cpplib.h
index 5ef15ea5be3..77d214d095a 100644
--- a/gnu/egcs/gcc/cpplib.h
+++ b/gnu/egcs/gcc/cpplib.h
@@ -233,6 +233,12 @@ struct cpp_reader
/* Buffer of -M output. */
char *deps_buffer;
+ /* Target-name to write with the dependency information. */
+ char *deps_target_base;
+
+ /* the prefix string that actually gets written containing the target */
+ char *deps_target_full;
+
/* Number of bytes allocated in above. */
int deps_allocated_size;
@@ -373,6 +379,7 @@ struct cpp_options {
2 means #include <...> as well. */
char print_deps;
+ char print_phony;
/* Nonzero if missing .h files in -M output are assumed to be generated
files and not errors. */
diff --git a/gnu/egcs/gcc/cppspec.c b/gnu/egcs/gcc/cppspec.c
index 2908b739368..541e1334864 100644
--- a/gnu/egcs/gcc/cppspec.c
+++ b/gnu/egcs/gcc/cppspec.c
@@ -51,7 +51,8 @@ Boston, MA 02111-1307, USA. */
|| !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \
|| !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \
|| !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \
- || !strcmp (STR, "isystem") || !strcmp (STR, "specs"))
+ || !strcmp (STR, "isystem") || !strcmp (STR, "specs") \
+ || !strcmp (STR, "MF") || !strcmp(STR, "MT"))
#ifndef WORD_SWITCH_TAKES_ARG
#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
@@ -84,6 +85,9 @@ lang_specific_driver (errfn, in_argc, in_argv, in_added_libraries)
/* Do we need to insert -E? */
int need_E = 1;
+ /* Do we need to insert -no-gcc? */
+ int need_no_gcc = 1;
+
/* Have we seen an input file? */
int seen_input = 0;
@@ -135,6 +139,8 @@ lang_specific_driver (errfn, in_argc, in_argv, in_added_libraries)
}
else if (argv[i][1] == 'x')
need_fixups = 0;
+ else if (argv[i][1] == 'g' && !strcmp(&argv[i][2], "cc"))
+ need_no_gcc = 0;
else if (WORD_SWITCH_TAKES_ARG (&argv[i][1]))
quote = 1;
}
@@ -183,7 +189,7 @@ lang_specific_driver (errfn, in_argc, in_argv, in_added_libraries)
/* If we don't need to edit the command line, we can bail early. */
- new_argc = argc + need_E + read_stdin
+ new_argc = argc + need_E + need_no_gcc + read_stdin
+ !!o_here + !!lang_c_here + !!lang_S_here;
if (new_argc == argc)
@@ -197,6 +203,9 @@ lang_specific_driver (errfn, in_argc, in_argv, in_added_libraries)
if (need_E)
new_argv[j++] = "-E";
+ if (need_no_gcc)
+ new_argv[j++] = "-no-gcc";
+
for (i = 1; i < argc; i++, j++)
{
if (i == lang_c_here)
diff --git a/gnu/egcs/gcc/gcc.c b/gnu/egcs/gcc/gcc.c
index 457168ab06f..4712307537b 100644
--- a/gnu/egcs/gcc/gcc.c
+++ b/gnu/egcs/gcc/gcc.c
@@ -531,7 +531,8 @@ static struct user_specs *user_specs_head, *user_specs_tail;
|| !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \
|| !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \
|| !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \
- || !strcmp (STR, "isystem") || !strcmp (STR, "specs"))
+ || !strcmp (STR, "isystem") || !strcmp (STR, "specs") \
+ || !strcmp (STR, "MF") || !strcmp(STR, "MT"))
#ifndef WORD_SWITCH_TAKES_ARG
#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
@@ -599,7 +600,7 @@ static struct compiler default_compilers[] =
%{C} %{CC} %{v} %{A*} %{I*} %{P} %{$} %I\
%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{CC:%{!E:%eGNU C does not support -CC without using -E}}\
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MF*} %{MG} %{MP} %{MT*}\
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
%{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
@@ -613,7 +614,7 @@ static struct compiler default_compilers[] =
%{!E:%{!M:%{!MM:cc1 %i %1 \
%{std*} %{nostdinc*} %{A*} %{I*} %I\
%{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a*}\
- %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
+ %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MF*} %{MG} %{MP} %{MT*}\
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
%{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
@@ -636,7 +637,7 @@ static struct compiler default_compilers[] =
%{C} %{CC} %{v} %{A*} %{I*} %{P} %{$} %I\
%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{CC:%{!E:%eGNU C does not support -CC without using -E}}\
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MF*} %{MG} %{MP} %{MT*}\
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
%{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
@@ -665,7 +666,7 @@ static struct compiler default_compilers[] =
%{C} %{CC} %{v} %{A*} %{I*} %{P} %{$} %I\
%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{CC:%{!E:%eGNU C does not support -CC without using -E}}\
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MF*} %{MG} %{MP} %{MT*}\
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
%{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
@@ -683,7 +684,7 @@ static struct compiler default_compilers[] =
cpp0 %{nostdinc*} %{C} %{CC} %{v} %{A*} %{I*} %{P} %{$} %I\
%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{CC:%{!E:%eGNU C does not support -CC without using -E}}\
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MF*} %{MG} %{MP} %{MT*}\
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
%{std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
%{!undef:%{!std=*:%p}%{std=gnu*:%p} %P} %{trigraphs}\
@@ -715,7 +716,8 @@ static struct compiler default_compilers[] =
{"cpp0 -lang-asm %{nostdinc*} %{C} %{CC} %{v} %{A*} %{I*} %{P} %{$} %I\
%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{CC:%{!E:%eGNU C does not support -CC without using -E}}\
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{trigraphs}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MF*} %{MG} %{MP} %{MT*}\
+ %{trigraphs}\
-$ %{!undef:%p %P} -D__ASSEMBLER__ \
%c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
%{ffast-math:-D__FAST_MATH__}\
@@ -865,7 +867,10 @@ struct option_map option_map[] =
{"--print-search-dirs", "-print-search-dirs", 0},
{"--print-file-name", "-print-file-name=", "aj"},
{"--print-libgcc-file-name", "-print-libgcc-file-name", 0},
+ {"--set-dependency-file", "-MF", "a"},
{"--print-missing-file-dependencies", "-MG", 0},
+ {"--print-phony-target-dependencies-too", "-MP", 0},
+ {"--set-dependency-target", "-MT", "a"},
{"--print-multi-lib", "-print-multi-lib", 0},
{"--print-multi-directory", "-print-multi-directory", 0},
{"--print-prog-name", "-print-prog-name=", "aj"},