Commit 03b9ab42 by Neil Booth Committed by Neil Booth

cpp.texi: Update for -MT.

        * 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
parent 13ac31ac
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> 2000-01-03 Richard Henderson <rth@redhat.com>
* c-decl.c (grokdeclarator): Give zero-length arrays size zero. * c-decl.c (grokdeclarator): Give zero-length arrays size zero.
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
This file documents the GNU C Preprocessor. This file documents the GNU C Preprocessor.
Copyright 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 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 Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice this manual provided the copyright notice and this permission notice
...@@ -53,7 +53,7 @@ C Language manual. ...@@ -53,7 +53,7 @@ C Language manual.
@vskip 0pt plus 1filll @vskip 0pt plus 1filll
@c man begin COPYRIGHT @c man begin COPYRIGHT
Copyright @copyright{} 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, Copyright @copyright{} 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
1997, 1998, 1999, 2000 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc. Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of 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 ...@@ -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 Like @samp{-MD} except mention only user header files, not system
header files. 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 @item -H
@findex -H @findex -H
Print the name of each header file used, in addition to other normal Print the name of each header file used, in addition to other normal
......
/* CPP Library. /* CPP Library.
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 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. Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986 Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987 Adapted to ANSI C, Richard Stallman, Jan 1987
...@@ -753,34 +753,27 @@ initialize_dependency_output (pfile) ...@@ -753,34 +753,27 @@ initialize_dependency_output (pfile)
return; return;
} }
if (! pfile->deps)
pfile->deps = deps_init ();
/* Find the space before the DEPS_TARGET, if there is one. */ /* Find the space before the DEPS_TARGET, if there is one. */
s = strchr (spec, ' '); s = strchr (spec, ' ');
if (s) if (s)
{ {
CPP_OPTION (pfile, deps_target) = s + 1; deps_add_target (pfile->deps, s + 1);
output_file = (char *) xmalloc (s - spec + 1); output_file = (char *) xmalloc (s - spec + 1);
memcpy (output_file, spec, s - spec); memcpy (output_file, spec, s - spec);
output_file[s - spec] = 0; output_file[s - spec] = 0;
} }
else else
{ output_file = spec;
CPP_OPTION (pfile, deps_target) = 0;
output_file = spec;
}
CPP_OPTION (pfile, deps_file) = output_file; CPP_OPTION (pfile, deps_file) = output_file;
CPP_OPTION (pfile, print_deps_append) = 1; CPP_OPTION (pfile, print_deps_append) = 1;
} }
pfile->deps = deps_init (); /* Set the default target (if there is none already). */
deps_add_default_target (pfile->deps, CPP_OPTION (pfile, in_fname));
/* 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));
if (CPP_OPTION (pfile, in_fname)) if (CPP_OPTION (pfile, in_fname))
deps_add_dep (pfile->deps, 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) ...@@ -1063,6 +1056,7 @@ new_pending_directive (pend, text, handler)
#define no_mac N_("Macro name missing after %s") #define no_mac N_("Macro name missing after %s")
#define no_pth N_("Path name missing after %s") #define no_pth N_("Path name missing after %s")
#define no_num N_("Number 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 /* This is the list of all command line options, with the leading
"-" removed. It must be sorted in ASCII collating order. */ "-" removed. It must be sorted in ASCII collating order. */
...@@ -1083,6 +1077,7 @@ new_pending_directive (pend, text, handler) ...@@ -1083,6 +1077,7 @@ new_pending_directive (pend, text, handler)
DEF_OPT("MG", 0, OPT_MG) \ DEF_OPT("MG", 0, OPT_MG) \
DEF_OPT("MM", 0, OPT_MM) \ DEF_OPT("MM", 0, OPT_MM) \
DEF_OPT("MMD", no_fil, OPT_MMD) \ DEF_OPT("MMD", no_fil, OPT_MMD) \
DEF_OPT("MT", no_tgt, OPT_MT) \
DEF_OPT("P", 0, OPT_P) \ DEF_OPT("P", 0, OPT_P) \
DEF_OPT("U", no_mac, OPT_U) \ DEF_OPT("U", no_mac, OPT_U) \
DEF_OPT("W", no_arg, OPT_W) /* arg optional */ \ DEF_OPT("W", no_arg, OPT_W) /* arg optional */ \
...@@ -1484,6 +1479,9 @@ cpp_handle_option (pfile, argc, argv) ...@@ -1484,6 +1479,9 @@ cpp_handle_option (pfile, argc, argv)
case OPT_MD: case OPT_MD:
case OPT_MM: case OPT_MM:
case OPT_MMD: case OPT_MMD:
if (! pfile->deps)
pfile->deps = deps_init ();
if (opt_code == OPT_M || opt_code == OPT_MD) if (opt_code == OPT_M || opt_code == OPT_MD)
CPP_OPTION (pfile, print_deps) = 2; CPP_OPTION (pfile, print_deps) = 2;
else else
...@@ -1497,6 +1495,14 @@ cpp_handle_option (pfile, argc, argv) ...@@ -1497,6 +1495,14 @@ cpp_handle_option (pfile, argc, argv)
else else
CPP_OPTION (pfile, no_output) = 1; CPP_OPTION (pfile, no_output) = 1;
break; break;
case OPT_MT:
/* Add a target. */
if (! pfile->deps)
pfile->deps = deps_init ();
deps_add_target (pfile->deps, arg);
break;
case OPT_A: case OPT_A:
if (arg[0] == '-') if (arg[0] == '-')
{ {
......
/* Definitions for CPP library. /* 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. Free Software Foundation, Inc.
Written by Per Bothner, 1994-95. Written by Per Bothner, 1994-95.
...@@ -281,9 +281,6 @@ struct cpp_options ...@@ -281,9 +281,6 @@ struct cpp_options
being written to stdout. */ being written to stdout. */
const char *deps_file; const char *deps_file;
/* Target-name to write with the dependency information. */
char *deps_target;
/* Search paths for include files. */ /* Search paths for include files. */
struct file_name_list *quote_include; /* First dir to search for "file" */ struct file_name_list *quote_include; /* First dir to search for "file" */
struct file_name_list *bracket_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. /* Compiler driver program that can handle many languages.
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 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. This file is part of GNU CC.
...@@ -584,7 +584,7 @@ static const char *cpp_options = ...@@ -584,7 +584,7 @@ static const char *cpp_options =
"%{C:%{!E:%eGNU C does not support -C without using -E}}\ "%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{std*} %{nostdinc*}\ %{std*} %{nostdinc*}\
%{C} %{v} %{I*} %{P} %{$} %I\ %{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}\ %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3}\
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\ %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
%c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\ %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
......
/* Dependency generator for Makefile fragments. /* 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 Contributed by Zack Weinberg, Mar 2000
This program is free software; you can redistribute it and/or modify it 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. ...@@ -24,13 +24,22 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "system.h" #include "system.h"
#include "mkdeps.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 *munge PARAMS ((const char *));
static const char *base_name 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 /* Given a filename, quote characters in that filename which are
significant to Make. Note that it's not possible to quote all such significant to Make. Note that it's not possible to quote all such
characters - e.g. \n, %, *, ?, [, \ (in some contexts), and ~ are characters - e.g. \n, %, *, ?, [, \ (in some contexts), and ~ are
...@@ -180,24 +189,39 @@ deps_add_target (d, t) ...@@ -180,24 +189,39 @@ deps_add_target (d, t)
d->targetv[d->ntargets++] = 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 void
deps_calc_target (d, t) deps_add_default_target (d, tgt)
struct deps *d; struct deps *d;
const char *t; const char *tgt;
{ {
char *o, *suffix; char *o, *suffix;
t = base_name (t); /* Only if we have no targets. */
o = (char *) alloca (strlen (t) + 8); if (d->ntargets)
return;
strcpy (o, t); if (tgt[0] == '\0')
suffix = strrchr (o, '.'); deps_add_target (d, "-");
if (suffix)
strcpy (suffix, OBJECT_SUFFIX);
else 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 void
......
/* Dependency generator for Makefile fragments. /* 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 Contributed by Zack Weinberg, Mar 2000
This program is free software; you can redistribute it and/or modify it 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. ...@@ -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. /* This is the data structure used by all the functions in mkdeps.c.
It's quite straightforward, but should be treated as opaque. */ It's quite straightforward, but should be treated as opaque. */
struct deps 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;
};
/* Create a deps buffer. */ /* Create a deps buffer. */
extern struct deps *deps_init PARAMS ((void)); extern struct deps *deps_init PARAMS ((void));
...@@ -46,11 +37,9 @@ extern void deps_free PARAMS ((struct deps *)); ...@@ -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. */ /* Add a target (appears on left side of the colon) to the deps list. */
extern void deps_add_target PARAMS ((struct deps *, const char *)); extern void deps_add_target PARAMS ((struct deps *, const char *));
/* Given the name of the primary source file, calculate and add the /* Sets the default target if none has been given already. An empty
name of the target. This is done by locating and stripping the string as the default target in interpreted as stdin. */
file extension (if any) and adding .o (OBJECT_SUFFIX). In addition, extern void deps_add_default_target PARAMS ((struct deps *, const char *));
any directory components of the path are discarded. */
extern void deps_calc_target PARAMS ((struct deps *, const char *));
/* Add a dependency (appears on the right side of the colon) to the /* Add a dependency (appears on the right side of the colon) to the
deps list. Dependencies will be printed in the order that they deps list. Dependencies will be printed in the order that they
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment