[CPP patch]: -M default name
Nathan Sidwell
nathan@codesourcery.com
Fri Feb 9 01:34:00 GMT 2001
Neil Booth wrote:
> OK, I think this fixes the empty file problem. Nathan, are you OK
> with the basename stuff?
Here's the basename stuff, built and tested on i686-pc-linux-gnu, ok?
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-08 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.
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/08 15:17:23
*************** 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,208 ****
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,207 ----
deps_add_target (d, "-", 1);
else
{
#ifndef OBJECT_SUFFIX
# define OBJECT_SUFFIX ".o"
#endif
+ char *start = basename (tgt);
+ char *o = (char *) alloca (strlen (start) + strlen (OBJECT_SUFFIX) + 1);
+ char *suffix;
! strcpy (o, start);
!
! suffix = strrchr (o, '.');
! if (!suffix)
! suffix = o + strlen (o);
! strcpy (suffix, OBJECT_SUFFIX);
!
deps_add_target (d, o, 1);
}
}
Index: cpp.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpp.texi,v
retrieving revision 1.45
diff -c -3 -p -r1.45 cpp.texi
*** cpp.texi 2001/02/02 19:39:46 1.45
--- cpp.texi 2001/02/08 15:17:30
*************** suitable for @code{make} describing the
*** 3487,3493 ****
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
included files, including those coming from @samp{-include} or
! @samp{-imacros} command line options. If there are many included files
then the rule is split into several lines using @samp{\}-newline.
@item -MM
--- 3487,3496 ----
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
included files, including those coming from @samp{-include} or
! @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.
@item -MM
Index: invoke.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/invoke.texi,v
retrieving revision 1.273
diff -c -3 -p -r1.273 invoke.texi
*** invoke.texi 2001/02/05 11:45:13 1.273
--- invoke.texi 2001/02/08 15:17:50
*************** Instead of outputting the result of prep
*** 3364,3371 ****
suitable for @code{make} describing the dependencies of the main source
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
! included files. If there are many included files then the rule is split
! into several lines using @samp{\}-newline.
@samp{-M} implies @samp{-E}.
--- 3364,3373 ----
suitable for @code{make} describing the dependencies of the main source
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
! included files. Unless overridden explicitly, 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.
@samp{-M} implies @samp{-E}.
More information about the Gcc-patches
mailing list