summaryrefslogtreecommitdiff
path: root/gcc/mkdeps.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-12 14:06:22 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-12 14:06:22 +0000
commit18c6ea52c9c5902b6f722a1fcbab1142a8fc196e (patch)
tree484bc05f164378c9dbb5ea022669b86655e63b43 /gcc/mkdeps.c
parent7a539874aa4bbeb4995811774db36246d14dc7ab (diff)
downloadgcc-18c6ea52c9c5902b6f722a1fcbab1142a8fc196e.tar.gz
* mkdeps.c (deps_add_default_target): Robustify. Add
basename component only. * cpp.texi (-M): Describe how default target is generated. * invoke.texi (-M): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39602 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/mkdeps.c')
-rw-r--r--gcc/mkdeps.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/gcc/mkdeps.c b/gcc/mkdeps.c
index b0c62c5627c..14935b328a6 100644
--- a/gcc/mkdeps.c
+++ b/gcc/mkdeps.c
@@ -180,8 +180,6 @@ deps_add_default_target (d, tgt)
struct deps *d;
const char *tgt;
{
- char *o, *suffix;
-
/* Only if we have no targets. */
if (d->ntargets)
return;
@@ -190,19 +188,20 @@ deps_add_default_target (d, tgt)
deps_add_target (d, "-", 1);
else
{
- o = (char *) alloca (strlen (tgt) + 8);
-
- strcpy (o, tgt);
- suffix = strrchr (o, '.');
-
#ifndef OBJECT_SUFFIX
# define OBJECT_SUFFIX ".o"
#endif
+ char *start = basename (tgt);
+ char *o = (char *) alloca (strlen (start) + strlen (OBJECT_SUFFIX) + 1);
+ char *suffix;
- if (suffix)
- strcpy (suffix, OBJECT_SUFFIX);
- else
- strcat (o, OBJECT_SUFFIX);
+ strcpy (o, start);
+
+ suffix = strrchr (o, '.');
+ if (!suffix)
+ suffix = o + strlen (o);
+ strcpy (suffix, OBJECT_SUFFIX);
+
deps_add_target (d, o, 1);
}
}