summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/cpp.texi13
-rw-r--r--gcc/cppinit.c36
-rw-r--r--gcc/cpplib.h5
-rw-r--r--gcc/gcc.c4
-rw-r--r--gcc/mkdeps.c54
-rw-r--r--gcc/mkdeps.h21
7 files changed, 94 insertions, 54 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ec1565dcd75..35edc3e63ca 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2001-01-04 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * cpp.texi: Update for -MT.
+ * cppinit.c (initialize_dependency_output): Add a default
+ target if none has been given already.
+ (no_tgt, OPT_MT): New.
+ (cpp_handle_option): Handle -MT. Update -M etc.
+ * cpplib.h (struct cpp_options): Remove deps_target.
+ * gcc.c (cpp_options): Handle -MT.
+ * mkdeps.c (struct deps): Move from mkdeps.h.
+ (deps_calc_target): Rename deps_add_default_target. Add a
+ default target if none has been specified already.
+ * mkdeps.h (struct deps): Move to mkdeps.c.
+ (deps_calc_target): Rename deps_add_default_target.
+
2000-01-03 Richard Henderson <rth@redhat.com>
* c-decl.c (grokdeclarator): Give zero-length arrays size zero.
diff --git a/gcc/cpp.texi b/gcc/cpp.texi
index 26a625f250b..db7f86b8506 100644
--- a/gcc/cpp.texi
+++ b/gcc/cpp.texi
@@ -17,7 +17,7 @@
This file documents the GNU C Preprocessor.
Copyright 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-1999, 2000 Free Software Foundation, Inc.
+1999, 2000, 2001 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -53,7 +53,7 @@ C Language manual.
@vskip 0pt plus 1filll
@c man begin COPYRIGHT
Copyright @copyright{} 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
-1997, 1998, 1999, 2000
+1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
@@ -3476,6 +3476,15 @@ files into a single dependency file suitable for using with the
Like @samp{-MD} except mention only user header files, not system
header files.
+@item -MT @var{target}
+@findex -MT
+By default CPP uses the base file name and appends the object suffix,
+normally ``.o'', to it to obtain the name of the target for dependency
+generation. With @samp{-MT} you can specify one or more of your own
+targets; doing so overrides the default.
+
+The targets are output in the order they appear on the command line.
+
@item -H
@findex -H
Print the name of each header file used, in addition to other normal
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index ea4bc6bc519..de00b2faef6 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -1,6 +1,6 @@
/* CPP Library.
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000 Free Software Foundation, Inc.
+ 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -753,34 +753,27 @@ initialize_dependency_output (pfile)
return;
}
+ if (! pfile->deps)
+ pfile->deps = deps_init ();
+
/* Find the space before the DEPS_TARGET, if there is one. */
s = strchr (spec, ' ');
if (s)
{
- CPP_OPTION (pfile, deps_target) = s + 1;
+ deps_add_target (pfile->deps, s + 1);
output_file = (char *) xmalloc (s - spec + 1);
memcpy (output_file, spec, s - spec);
output_file[s - spec] = 0;
}
else
- {
- CPP_OPTION (pfile, deps_target) = 0;
- output_file = spec;
- }
+ output_file = spec;
CPP_OPTION (pfile, deps_file) = output_file;
CPP_OPTION (pfile, print_deps_append) = 1;
}
- pfile->deps = deps_init ();
-
- /* Print the expected object file name as the target of this Make-rule. */
- if (CPP_OPTION (pfile, deps_target))
- deps_add_target (pfile->deps, CPP_OPTION (pfile, deps_target));
- else if (*CPP_OPTION (pfile, in_fname) == 0)
- deps_add_target (pfile->deps, "-");
- else
- deps_calc_target (pfile->deps, CPP_OPTION (pfile, in_fname));
+ /* Set the default target (if there is none already). */
+ deps_add_default_target (pfile->deps, CPP_OPTION (pfile, in_fname));
if (CPP_OPTION (pfile, in_fname))
deps_add_dep (pfile->deps, CPP_OPTION (pfile, in_fname));
@@ -1063,6 +1056,7 @@ new_pending_directive (pend, text, handler)
#define no_mac N_("Macro name missing after %s")
#define no_pth N_("Path name missing after %s")
#define no_num N_("Number missing after %s")
+#define no_tgt N_("Target missing after %s")
/* This is the list of all command line options, with the leading
"-" removed. It must be sorted in ASCII collating order. */
@@ -1083,6 +1077,7 @@ new_pending_directive (pend, text, handler)
DEF_OPT("MG", 0, OPT_MG) \
DEF_OPT("MM", 0, OPT_MM) \
DEF_OPT("MMD", no_fil, OPT_MMD) \
+ DEF_OPT("MT", no_tgt, OPT_MT) \
DEF_OPT("P", 0, OPT_P) \
DEF_OPT("U", no_mac, OPT_U) \
DEF_OPT("W", no_arg, OPT_W) /* arg optional */ \
@@ -1484,6 +1479,9 @@ cpp_handle_option (pfile, argc, argv)
case OPT_MD:
case OPT_MM:
case OPT_MMD:
+ if (! pfile->deps)
+ pfile->deps = deps_init ();
+
if (opt_code == OPT_M || opt_code == OPT_MD)
CPP_OPTION (pfile, print_deps) = 2;
else
@@ -1497,6 +1495,14 @@ cpp_handle_option (pfile, argc, argv)
else
CPP_OPTION (pfile, no_output) = 1;
break;
+
+ case OPT_MT:
+ /* Add a target. */
+ if (! pfile->deps)
+ pfile->deps = deps_init ();
+ deps_add_target (pfile->deps, arg);
+ break;
+
case OPT_A:
if (arg[0] == '-')
{
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 3c71188c480..98e8e1b500c 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -1,5 +1,5 @@
/* Definitions for CPP library.
- Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
+ Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
Written by Per Bothner, 1994-95.
@@ -281,9 +281,6 @@ struct cpp_options
being written to stdout. */
const char *deps_file;
- /* Target-name to write with the dependency information. */
- char *deps_target;
-
/* Search paths for include files. */
struct file_name_list *quote_include; /* First dir to search for "file" */
struct file_name_list *bracket_include;/* First dir to search for <file> */
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 70cb6bee06f..53c7ba24463 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1,6 +1,6 @@
/* Compiler driver program that can handle many languages.
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000 Free Software Foundation, Inc.
+ 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -584,7 +584,7 @@ static const char *cpp_options =
"%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{std*} %{nostdinc*}\
%{C} %{v} %{I*} %{P} %{$} %I\
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{MT}\
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3}\
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
%c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
diff --git a/gcc/mkdeps.c b/gcc/mkdeps.c
index 66417d00fee..8d3e0bfce89 100644
--- a/gcc/mkdeps.c
+++ b/gcc/mkdeps.c
@@ -1,5 +1,5 @@
/* Dependency generator for Makefile fragments.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Contributed by Zack Weinberg, Mar 2000
This program is free software; you can redistribute it and/or modify it
@@ -24,13 +24,22 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "system.h"
#include "mkdeps.h"
+/* Keep this structure local to this file, so clients don't find it
+ easy to start making assumptions. */
+struct deps
+{
+ const char **targetv;
+ unsigned int ntargets; /* number of slots actually occupied */
+ unsigned int targets_size; /* amt of allocated space - in words */
+
+ const char **depv;
+ unsigned int ndeps;
+ unsigned int deps_size;
+};
+
static const char *munge PARAMS ((const char *));
static const char *base_name PARAMS ((const char *));
-#ifndef OBJECT_SUFFIX
-# define OBJECT_SUFFIX ".o"
-#endif
-
/* Given a filename, quote characters in that filename which are
significant to Make. Note that it's not possible to quote all such
characters - e.g. \n, %, *, ?, [, \ (in some contexts), and ~ are
@@ -180,24 +189,39 @@ deps_add_target (d, t)
d->targetv[d->ntargets++] = t;
}
+/* Sets the default target if none has been given already. An empty
+ string as the default target in interpreted as stdin. */
void
-deps_calc_target (d, t)
+deps_add_default_target (d, tgt)
struct deps *d;
- const char *t;
+ const char *tgt;
{
char *o, *suffix;
- t = base_name (t);
- o = (char *) alloca (strlen (t) + 8);
+ /* Only if we have no targets. */
+ if (d->ntargets)
+ return;
- strcpy (o, t);
- suffix = strrchr (o, '.');
- if (suffix)
- strcpy (suffix, OBJECT_SUFFIX);
+ if (tgt[0] == '\0')
+ deps_add_target (d, "-");
else
- strcat (o, OBJECT_SUFFIX);
+ {
+ tgt = base_name (tgt);
+ o = (char *) alloca (strlen (tgt) + 8);
+
+ strcpy (o, tgt);
+ suffix = strrchr (o, '.');
- deps_add_target (d, 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);
+ }
}
void
diff --git a/gcc/mkdeps.h b/gcc/mkdeps.h
index 7a2c130af8a..727a78485a9 100644
--- a/gcc/mkdeps.h
+++ b/gcc/mkdeps.h
@@ -1,5 +1,5 @@
/* Dependency generator for Makefile fragments.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Contributed by Zack Weinberg, Mar 2000
This program is free software; you can redistribute it and/or modify it
@@ -26,16 +26,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/* This is the data structure used by all the functions in mkdeps.c.
It's quite straightforward, but should be treated as opaque. */
-struct deps
-{
- const char **targetv;
- unsigned int ntargets; /* number of slots actually occupied */
- unsigned int targets_size; /* amt of allocated space - in words */
-
- const char **depv;
- unsigned int ndeps;
- unsigned int deps_size;
-};
+struct deps;
/* Create a deps buffer. */
extern struct deps *deps_init PARAMS ((void));
@@ -46,11 +37,9 @@ extern void deps_free PARAMS ((struct deps *));
/* Add a target (appears on left side of the colon) to the deps list. */
extern void deps_add_target PARAMS ((struct deps *, const char *));
-/* Given the name of the primary source file, calculate and add the
- name of the target. This is done by locating and stripping the
- file extension (if any) and adding .o (OBJECT_SUFFIX). In addition,
- any directory components of the path are discarded. */
-extern void deps_calc_target PARAMS ((struct deps *, const char *));
+/* Sets the default target if none has been given already. An empty
+ string as the default target in interpreted as stdin. */
+extern void deps_add_default_target PARAMS ((struct deps *, const char *));
/* Add a dependency (appears on the right side of the colon) to the
deps list. Dependencies will be printed in the order that they