[CPP patch]: -M default name
Nathan Sidwell
nathan@codesourcery.com
Tue Feb 6 02:24:00 GMT 2001
Neil,
this patch makes the default dependency target name have no directory
component, and reverts the behaviour of your patch of
2001-01-05 Neil Booth <neil@daikokuya.demon.co.uk>
what was the rationale for that? It's breaking something like
gcc -MD src/file.c
we get a file.o and a file.d, but file.d says the target is src/file.o
See bug 1881, for which this is a problem. If there are good reasons
for the current behaviour, then we need to change the specs in gcc.c
to set the target name correctly.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-02-06 Nathan Sidwell <nathan@codesourcery.com>
* mkdeps.c (deps_add_default_target): Robustify. Strip to base
name component.
Index: mkdeps.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/mkdeps.c,v
retrieving revision 1.11
diff -c -3 -p -r1.11 mkdeps.c
*** mkdeps.c 2001/01/06 11:08:49 1.11
--- mkdeps.c 2001/02/06 10:18:39
*************** deps_add_default_target (d, tgt)
*** 180,187 ****
struct deps *d;
const char *tgt;
{
- char *o, *suffix;
-
/* Only if we have no targets. */
if (d->ntargets)
return;
--- 180,185 ----
*************** deps_add_default_target (d, tgt)
*** 190,209 ****
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
! if (suffix)
! strcpy (suffix, OBJECT_SUFFIX);
! else
! strcat (o, OBJECT_SUFFIX);
! deps_add_target (d, o, 1);
}
}
--- 188,214 ----
deps_add_target (d, "-", 1);
else
{
#ifndef OBJECT_SUFFIX
# define OBJECT_SUFFIX ".o"
#endif
+ char *o = (char *) alloca (strlen (tgt) + strlen (OBJECT_SUFFIX) + 1);
+ char *start;
+ char *suffix;
+
+ strcpy (o, tgt);
+
+ suffix = strrchr (o, '.');
+ if (!suffix)
+ suffix = o + strlen (o);
! strcpy (suffix, OBJECT_SUFFIX);
! for (start = suffix; start != o; start--)
! if (IS_DIR_SEPARATOR (*start))
! {
! start++;
! break;
! }
! deps_add_target (d, start, 1);
}
}
More information about the Gcc-patches
mailing list