Commit c3843cea by Jakub Jelinek Committed by Jakub Jelinek

tradcpp.c (deps_file, [...]): New variables.

	* tradcpp.c (deps_file, print_deps_missing_files): New variables.
	(main): Handle -MG, -MD, -MMD.  Bail out if -MG is given without -M
	or -MM.
	(do_include): Handle missing headers like cpp0.
	* cppfiles.c (_cpp_execute_include): Don't prefix absolute header
	paths with first include pathname.  Don't strcat to uninitialized
	string.

From-SVN: r38683
parent f4d578da
2001-01-04 Jakub Jelinek <jakub@redhat.com>
* tradcpp.c (deps_file, print_deps_missing_files): New variables.
(main): Handle -MG, -MD, -MMD. Bail out if -MG is given without -M
or -MM.
(do_include): Handle missing headers like cpp0.
* cppfiles.c (_cpp_execute_include): Don't prefix absolute header
paths with first include pathname. Don't strcat to uninitialized
string.
2001-01-04 Bernd Schmidt <bernds@redhat.com> 2001-01-04 Bernd Schmidt <bernds@redhat.com>
* regrename.c (regrename_optimize): Don't rename from frame pointer * regrename.c (regrename_optimize): Don't rename from frame pointer
......
...@@ -648,12 +648,14 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next) ...@@ -648,12 +648,14 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next)
if (CPP_OPTION (pfile, print_deps_missing_files) if (CPP_OPTION (pfile, print_deps_missing_files)
&& PRINT_THIS_DEP (pfile, angle_brackets)) && PRINT_THIS_DEP (pfile, angle_brackets))
{ {
if (!angle_brackets) if (!angle_brackets || *fname == '/')
deps_add_dep (pfile->deps, fname); deps_add_dep (pfile->deps, fname);
else else
{ {
char *p; char *p;
struct file_name_list *ptr; struct file_name_list *ptr;
int len = strlen (ptr->name);
/* If requested as a system header, assume it belongs in /* If requested as a system header, assume it belongs in
the first system header directory. */ the first system header directory. */
if (CPP_OPTION (pfile, bracket_include)) if (CPP_OPTION (pfile, bracket_include))
...@@ -661,14 +663,13 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next) ...@@ -661,14 +663,13 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next)
else else
ptr = CPP_OPTION (pfile, quote_include); ptr = CPP_OPTION (pfile, quote_include);
p = (char *) alloca (strlen (ptr->name) p = (char *) alloca (len + strlen (fname) + 2);
+ strlen (fname) + 2); if (len)
if (*ptr->name != '\0')
{ {
strcpy (p, ptr->name); memcpy (p, ptr->name, len);
strcat (p, "/"); p[len++] = '/';
} }
strcat (p, fname); strcpy (p + len, fname);
_cpp_simplify_pathname (p); _cpp_simplify_pathname (p);
deps_add_dep (pfile->deps, p); deps_add_dep (pfile->deps, p);
} }
......
...@@ -46,6 +46,16 @@ int put_out_comments = 0; ...@@ -46,6 +46,16 @@ int put_out_comments = 0;
int print_deps = 0; int print_deps = 0;
/* File name which deps are being written to. This is 0 if deps are
being written to stdout. */
const char *deps_file = 0;
/* Nonzero if missing .h files in -M output are assumed to be
generated files and not errors. */
int print_deps_missing_files = 0;
/* Nonzero means don't output line number information. */ /* Nonzero means don't output line number information. */
int no_line_commands; int no_line_commands;
...@@ -608,11 +618,32 @@ main (argc, argv) ...@@ -608,11 +618,32 @@ main (argc, argv)
break; break;
case 'M': case 'M':
if (!strcmp (argv[i], "-M")) {
print_deps = 2; char *p = NULL;
else if (!strcmp (argv[i], "-MM"))
print_deps = 1; if (!strncmp (argv[i], "-MD", 3)) {
inhibit_output = 1; p = argv[i] + 3;
print_deps = 2;
} else if (!strncmp (argv[i], "-MMD", 4)) {
p = argv[i] + 4;
print_deps = 1;
} else if (!strcmp (argv[i], "-M")) {
print_deps = 2;
inhibit_output = 1;
} else if (!strcmp (argv[i], "-MM")) {
print_deps = 1;
inhibit_output = 1;
} else if (!strcmp (argv[i], "-MG"))
print_deps_missing_files = 1;
if (p) {
if (*p)
deps_file = p;
else if (i + 1 == argc)
fatal ("Filename missing after %s option", argv[i]);
else
deps_file = argv[++i];
}
}
break; break;
case 'd': case 'd':
...@@ -716,6 +747,9 @@ main (argc, argv) ...@@ -716,6 +747,9 @@ main (argc, argv)
} }
} }
if (print_deps_missing_files && (!print_deps || !inhibit_output))
fatal ("-MG must be specified with one of -M or -MM");
if (user_label_prefix == 0) if (user_label_prefix == 0)
user_label_prefix = USER_LABEL_PREFIX; user_label_prefix = USER_LABEL_PREFIX;
...@@ -809,7 +843,6 @@ main (argc, argv) ...@@ -809,7 +843,6 @@ main (argc, argv)
{ {
char *spec = getenv ("DEPENDENCIES_OUTPUT"); char *spec = getenv ("DEPENDENCIES_OUTPUT");
char *s; char *s;
char *output_file;
if (spec == 0) if (spec == 0)
{ {
...@@ -823,28 +856,33 @@ main (argc, argv) ...@@ -823,28 +856,33 @@ main (argc, argv)
s = strchr (spec, ' '); s = strchr (spec, ' ');
if (s) if (s)
{ {
char *out_file;
deps_target = s + 1; deps_target = s + 1;
output_file = (char *) xmalloc (s - spec + 1); out_file = (char *) xmalloc (s - spec + 1);
memcpy (output_file, spec, s - spec); memcpy (out_file, spec, s - spec);
output_file[s - spec] = 0; out_file[s - spec] = 0;
deps_file = out_file;
} }
else else
{ {
deps_target = 0; deps_target = 0;
output_file = spec; deps_file = spec;
} }
deps_stream = fopen (output_file, "a");
if (deps_stream == 0)
pfatal_with_name (output_file);
} }
/* If the -M option was used, output the deps to standard output. */
else if (print_deps)
deps_stream = stdout;
/* For -M, print the expected object file name /* For -M, print the expected object file name
as the target of this Make-rule. */ as the target of this Make-rule. */
if (print_deps) { if (print_deps) {
if (deps_file) {
deps_stream = fopen (deps_file, "a");
if (deps_stream == 0)
pfatal_with_name (deps_file);
} else
/* If the -M option was used, output the deps to standard output. */
deps_stream = stdout;
deps_allocated_size = 200; deps_allocated_size = 200;
deps_buffer = (char *) xmalloc (deps_allocated_size); deps_buffer = (char *) xmalloc (deps_allocated_size);
deps_buffer[0] = 0; deps_buffer[0] = 0;
...@@ -2334,19 +2372,38 @@ get_filename: ...@@ -2334,19 +2372,38 @@ get_filename:
if (f < 0) { if (f < 0) {
strncpy (fname, (const char *)fbeg, flen); strncpy (fname, (const char *)fbeg, flen);
fname[flen] = 0; fname[flen] = 0;
error_from_errno (fname); if (print_deps_missing_files
&& print_deps > (system_header_p || (system_include_depth > 0))) {
/* For -M, add this file to the dependencies. */ /* If requested as a system header, assume it belongs in
if (print_deps > (system_header_p || (system_include_depth > 0))) { the first system header directory. */
if (system_header_p) if (first_bracket_include)
warning ("nonexistent file <%.*s> omitted from dependency output", stackp = first_bracket_include;
flen, fbeg);
else else
{ stackp = include;
deps_output ((const char *)fbeg, flen);
deps_output (" ", 0); if (!system_header_p || *fbeg == '/' || !stackp->fname)
} deps_output ((const char *)fbeg, flen);
} else {
char *p;
int len = strlen(stackp->fname);
p = (char *) alloca (len + flen + 2);
memcpy (p, stackp->fname, len);
p[len++] = '/';
memcpy (p + len, fbeg, flen);
len += flen;
deps_output (p, len);
}
deps_output (" ", 0);
} else if (print_deps
&& print_deps <= (system_header_p
|| (system_include_depth > 0)))
warning ("No include path in which to find %.*s", flen, fbeg);
else
error_from_errno (fname);
} else { } else {
/* Check to see if this include file is a once-only include file. /* Check to see if this include file is a once-only include file.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment