* 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.
From-SVN: r38681
+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.
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
@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
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
/* 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
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));
#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. */
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 */ \
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
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] == '-')
{
/* 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.
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> */
/* 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.
"%{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__}}\
/* 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
#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
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
/* 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
/* 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));
/* 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