Commit 48ce6bbb by Nathan Sidwell Committed by Nathan Sidwell

mkdeps.c (deps_add_default_target): Robustify.

	* mkdeps.c (deps_add_default_target): Robustify. Add
	basename component only.
	* cpp.texi (-M): Describe how default target is generated.
	* invoke.texi (-M): Likewise.

From-SVN: r39602
parent 823a9919
2001-02-12 Nathan Sidwell <nathan@codesourcery.com>
* mkdeps.c (deps_add_default_target): Robustify. Add
basename component only.
* cpp.texi (-M): Describe how default target is generated.
* invoke.texi (-M): Likewise.
2001-02-12 Kazu Hirata <kazu@hxi.com> 2001-02-12 Kazu Hirata <kazu@hxi.com>
* toplev.c (push_float_handler): Remove. * toplev.c (push_float_handler): Remove.
......
...@@ -3495,7 +3495,10 @@ suitable for @code{make} describing the dependencies of the main source ...@@ -3495,7 +3495,10 @@ suitable for @code{make} describing the dependencies of the main source
file. The preprocessor outputs one @code{make} rule containing the file. The preprocessor outputs one @code{make} rule containing the
object file name for that source file, a colon, and the names of all the object file name for that source file, a colon, and the names of all the
included files, including those coming from @samp{-include} or included files, including those coming from @samp{-include} or
@samp{-imacros} command line options. If there are many included files @samp{-imacros} command line options. Unless specified explicitly (with
@samp{-MT} or @samp{-MQ}), the object file name consists of the basename
of the source file with any suffix replaced with object file suffix.
If there are many included files
then the rule is split into several lines using @samp{\}-newline. then the rule is split into several lines using @samp{\}-newline.
@item -MM @item -MM
......
...@@ -3364,8 +3364,10 @@ Instead of outputting the result of preprocessing, output a rule ...@@ -3364,8 +3364,10 @@ Instead of outputting the result of preprocessing, output a rule
suitable for @code{make} describing the dependencies of the main source suitable for @code{make} describing the dependencies of the main source
file. The preprocessor outputs one @code{make} rule containing the file. The preprocessor outputs one @code{make} rule containing the
object file name for that source file, a colon, and the names of all the object file name for that source file, a colon, and the names of all the
included files. If there are many included files then the rule is split included files. Unless overridden explicitly, the object file name
into several lines using @samp{\}-newline. consists of the basename of the source file with any suffix replaced with
object file suffix. If there are many included files then the
rule is split into several lines using @samp{\}-newline.
@samp{-M} implies @samp{-E}. @samp{-M} implies @samp{-E}.
......
...@@ -180,8 +180,6 @@ deps_add_default_target (d, tgt) ...@@ -180,8 +180,6 @@ deps_add_default_target (d, tgt)
struct deps *d; struct deps *d;
const char *tgt; const char *tgt;
{ {
char *o, *suffix;
/* Only if we have no targets. */ /* Only if we have no targets. */
if (d->ntargets) if (d->ntargets)
return; return;
...@@ -190,19 +188,20 @@ deps_add_default_target (d, tgt) ...@@ -190,19 +188,20 @@ deps_add_default_target (d, tgt)
deps_add_target (d, "-", 1); deps_add_target (d, "-", 1);
else else
{ {
o = (char *) alloca (strlen (tgt) + 8);
strcpy (o, tgt);
suffix = strrchr (o, '.');
#ifndef OBJECT_SUFFIX #ifndef OBJECT_SUFFIX
# define OBJECT_SUFFIX ".o" # define OBJECT_SUFFIX ".o"
#endif #endif
char *start = basename (tgt);
char *o = (char *) alloca (strlen (start) + strlen (OBJECT_SUFFIX) + 1);
char *suffix;
if (suffix) strcpy (o, start);
strcpy (suffix, OBJECT_SUFFIX);
else suffix = strrchr (o, '.');
strcat (o, OBJECT_SUFFIX); if (!suffix)
suffix = o + strlen (o);
strcpy (suffix, OBJECT_SUFFIX);
deps_add_target (d, o, 1); deps_add_target (d, o, 1);
} }
} }
......
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