Commit 56cd5b95 by Neil Booth Committed by Neil Booth

cppinit.c (init_dependency_output): Take deps output file from -o if none given with -MF.

	* cppinit.c (init_dependency_output): Take deps output file
	from -o if none given with -MF.  Suppress normal output.
	* gcc.c (cpp_unique_options): Have -M and -MM imply -E.
	* doc/cpp.texi, doc/invoke.texi: Update.

From-SVN: r49892
parent 042cdf71
2002-02-20 Neil Booth <neil@daikokuya.demon.co.uk>
* cppinit.c (init_dependency_output): Take deps output file
from -o if none given with -MF. Suppress normal output.
* gcc.c (cpp_unique_options): Have -M and -MM imply -E.
* doc/cpp.texi, doc/invoke.texi: Update.
2002-02-19 Zack Weinberg <zack@codesourcery.com> 2002-02-19 Zack Weinberg <zack@codesourcery.com>
* toplev.c (output_quoted_string): Write unprintable * toplev.c (output_quoted_string): Write unprintable
......
...@@ -1084,7 +1084,7 @@ output_deps (pfile) ...@@ -1084,7 +1084,7 @@ output_deps (pfile)
const char *const deps_mode = const char *const deps_mode =
CPP_OPTION (pfile, print_deps_append) ? "a" : "w"; CPP_OPTION (pfile, print_deps_append) ? "a" : "w";
if (CPP_OPTION (pfile, deps_file) == 0) if (CPP_OPTION (pfile, deps_file)[0] == '\0')
deps_stream = stdout; deps_stream = stdout;
else else
{ {
...@@ -1835,7 +1835,8 @@ cpp_post_options (pfile) ...@@ -1835,7 +1835,8 @@ cpp_post_options (pfile)
cpp_fatal (pfile, "you must additionally specify either -M or -MM"); cpp_fatal (pfile, "you must additionally specify either -M or -MM");
} }
/* Set up dependency-file output. */ /* Set up dependency-file output. On exit, if print_deps is non-zero
then deps_file is not NULL; stdout is the empty string. */
static void static void
init_dependency_output (pfile) init_dependency_output (pfile)
cpp_reader *pfile; cpp_reader *pfile;
...@@ -1874,21 +1875,22 @@ init_dependency_output (pfile) ...@@ -1874,21 +1875,22 @@ init_dependency_output (pfile)
else else
output_file = spec; output_file = spec;
/* Command line overrides environment variables. */
if (CPP_OPTION (pfile, deps_file) == 0)
CPP_OPTION (pfile, deps_file) = output_file;
CPP_OPTION (pfile, print_deps_append) = 1; CPP_OPTION (pfile, print_deps_append) = 1;
} }
else
/* If -M or -MM was seen, default output to wherever was specified
with -o. out_fname is non-NULL here. */
output_file = CPP_OPTION (pfile, out_fname);
/* If dependencies go to standard output, or -MG is used, we should /* Command line -MF overrides environment variables and default. */
suppress output, including -dM, -dI etc. */ if (CPP_OPTION (pfile, deps_file) == 0)
if (CPP_OPTION (pfile, deps_file) == 0 CPP_OPTION (pfile, deps_file) = output_file;
|| CPP_OPTION (pfile, print_deps_missing_files))
{ /* When doing dependencies, we should suppress all output, including
CPP_OPTION (pfile, no_output) = 1; -dM, -dI etc. */
CPP_OPTION (pfile, dump_macros) = 0; CPP_OPTION (pfile, no_output) = 1;
CPP_OPTION (pfile, dump_includes) = 0; CPP_OPTION (pfile, dump_macros) = 0;
} CPP_OPTION (pfile, dump_includes) = 0;
} }
/* Handle --help output. */ /* Handle --help output. */
......
...@@ -3956,6 +3956,8 @@ suffix replaced with object file suffix. If there are many included ...@@ -3956,6 +3956,8 @@ suffix replaced with object file suffix. If there are many included
files then the rule is split into several lines using @samp{\}-newline. files then the rule is split into several lines using @samp{\}-newline.
The rule has no commands. The rule has no commands.
Passing @option{-M} to the driver implies @option{-E}.
@item -MM @item -MM
Like @option{-M}, but mention only the files included with @code{@w{#include Like @option{-M}, but mention only the files included with @code{@w{#include
"@var{file}"}} or with @option{-include} or @option{-imacros} command line "@var{file}"}} or with @option{-include} or @option{-imacros} command line
...@@ -3963,10 +3965,14 @@ options. System header files included with @code{@w{#include <@var{file}>}} ...@@ -3963,10 +3965,14 @@ options. System header files included with @code{@w{#include <@var{file}>}}
are omitted. are omitted.
@item -MF @var{file} @item -MF @var{file}
When used with @option{-M} or @option{-MM}, specifies a file to write the @anchor{-MF}
dependencies to. This allows the preprocessor to write the preprocessed When used with @option{-M} or @option{-MM}, specifies a
file to stdout normally. If no @option{-MF} switch is given, CPP sends file to write the dependencies to. If no @option{-MF} switch is given
the rules to stdout and suppresses normal preprocessed output. the preprocessor sends the rules to the same place it would have sent
preprocessed output.
When used with the driver options @option{-MD} or @option{-MMD},
@option{-MF} overrides the default dependency output file.
@item -MG @item -MG
When used with @option{-M} or @option{-MM}, @option{-MG} says to treat missing When used with @option{-M} or @option{-MM}, @option{-MG} says to treat missing
...@@ -4019,14 +4025,24 @@ $$(objpfx)foo.o: foo.c ...@@ -4019,14 +4025,24 @@ $$(objpfx)foo.o: foo.c
The default target is automatically quoted, as if it were given with The default target is automatically quoted, as if it were given with
@option{-MQ}. @option{-MQ}.
@item -MD @var{file} @item -MD
@itemx -MMD @var{file} @option{-MD} is equivalent to @option{-M -MF @var{file}}, except that
@option{-MD @var{file}} is equivalent to @option{-M -MF @var{file}}, and @option{-E} is not implied. The driver determines @var{file} based on
@option{-MMD @var{file}} is equivalent to @option{-MM -MF @var{file}}. whether an @option{-o} option is given. If it is, the driver uses its
argument but with a suffix of @file{.d}, otherwise it take the
basename of the input file and applies a @file{.d} suffix.
If @option{-MD} is used in conjunction with @option{-E}, any
@option{-o} switch is understood to specify the dependency output file
(but @pxref{-MF}), but if used without @option{-E}, each @option{-o}
is understood to specify a target object file.
Since @option{-E} is not implied, @option{-MD} can be used to generate
a dependency output file as a side-effect of the compilation process.
Due to limitations in the compiler driver, you must use these switches @item -MMD
when you want to generate a dependency file as a side-effect of normal Like @option{-MD} except mention only user header files, not system
compilation. -header files.
@item -x c @item -x c
@itemx -x c++ @itemx -x c++
......
...@@ -4029,15 +4029,19 @@ Used with the @option{-E} option. ...@@ -4029,15 +4029,19 @@ Used with the @option{-E} option.
@item -M @item -M
@opindex M @opindex M
Instead of outputting the result of preprocessing, output a rule Instead of outputting the result of preprocessing, output a rule
suitable for @code{make} describing the dependencies of the main source suitable for @command{make} describing the dependencies of the main
file. The preprocessor outputs one @code{make} rule containing the source file. The preprocessor outputs one @command{make} rule containing
object file name for that source file, a colon, and the names of all the the object file name for that source file, a colon, and the names of all
included files. Unless overridden explicitly, the object file name the included files, including those coming from @option{-include} or
consists of the basename of the source file with any suffix replaced with @option{-imacros} command line options.
object file suffix. If there are many included files then the
rule is split into several lines using @samp{\}-newline.
@option{-M} implies @option{-E}. Unless specified explicitly (with @option{-MT} or @option{-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.
The rule has no commands.
Passing @option{-M} to the driver implies @option{-E}.
@item -MM @item -MM
@opindex MM @opindex MM
...@@ -4047,13 +4051,19 @@ Like @option{-M}, but mention only the files included with @samp{#include ...@@ -4047,13 +4051,19 @@ Like @option{-M}, but mention only the files included with @samp{#include
@item -MD @item -MD
@opindex MD @opindex MD
Like @option{-M} but the dependency information is written to a file @option{-MD} is equivalent to @option{-M -MF @var{file}}, except that
rather than stdout. @code{gcc} will use the same file name and @option{-E} is not implied. The driver determines @var{file} based on
directory as the object file, but with the suffix @file{.d} instead. whether an @option{-o} option is given. If it is, the driver uses its
argument but with a suffix of @file{.d}, otherwise it take the
basename of the input file and applies a @file{.d} suffix.
If @option{-MD} is used in conjunction with @option{-E}, any
@option{-o} switch is understood to specify the dependency output file
(but @pxref{-MF}), but if used without @option{-E}, each @option{-o}
is understood to specify a target object file.
This is in addition to compiling the main file as specified---@option{-MD} Since @option{-E} is not implied, @option{-MD} can be used to generate
does not inhibit ordinary compilation the way @option{-M} does, a dependency output file as a side-effect of the compilation process.
unless you also specify @option{-MG}.
With Mach, you can use the utility @code{md} to merge multiple With Mach, you can use the utility @code{md} to merge multiple
dependency files into a single dependency file suitable for using with dependency files into a single dependency file suitable for using with
...@@ -4066,10 +4076,14 @@ Like @option{-MD} except mention only user header files, not system ...@@ -4066,10 +4076,14 @@ Like @option{-MD} except mention only user header files, not system
@item -MF @var{file} @item -MF @var{file}
@opindex MF @opindex MF
When used with @option{-M} or @option{-MM}, specifies a file to write the @anchor{-MF}
dependencies to. This allows the preprocessor to write the preprocessed When used with @option{-M} or @option{-MM}, specifies a
file to stdout normally. If no @option{-MF} switch is given, CPP sends file to write the dependencies to. If no @option{-MF} switch is given
the rules to stdout and suppresses normal preprocessed output. the preprocessor sends the rules to the same place it would have sent
preprocessed output.
When used with the driver options @option{-MD} or @option{-MMD},
@option{-MF} overrides the default dependency output file.
Another way to specify output of a @code{make} rule is by setting Another way to specify output of a @code{make} rule is by setting
the environment variable @env{DEPENDENCIES_OUTPUT} (@pxref{Environment the environment variable @env{DEPENDENCIES_OUTPUT} (@pxref{Environment
......
...@@ -665,7 +665,8 @@ static const char *cpp_unique_options = ...@@ -665,7 +665,8 @@ static const char *cpp_unique_options =
%{nostdinc*} %{C} %{v} %{I*} %{P} %{$} %I\ %{nostdinc*} %{C} %{v} %{I*} %{P} %{$} %I\
%{MD:-M -MF %W{!o: %b.d}%W{o*:%.d%*}}\ %{MD:-M -MF %W{!o: %b.d}%W{o*:%.d%*}}\
%{MMD:-MM -MF %W{!o: %b.d}%W{o*:%.d%*}}\ %{MMD:-MM -MF %W{!o: %b.d}%W{o*:%.d%*}}\
%{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{!E:%{M|MD|MM|MMD:%{o*:-MQ %*}}}\ %{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*}\
%{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}}\
%{!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}\
%{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\ %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
...@@ -674,7 +675,7 @@ static const char *cpp_unique_options = ...@@ -674,7 +675,7 @@ static const char *cpp_unique_options =
%{ffreestanding:-D__STDC_HOSTED__=0} %{fno-hosted:-D__STDC_HOSTED__=0}\ %{ffreestanding:-D__STDC_HOSTED__=0} %{fno-hosted:-D__STDC_HOSTED__=0}\
%{!ffreestanding:%{!fno-hosted:-D__STDC_HOSTED__=1}} %{remap}\ %{!ffreestanding:%{!fno-hosted:-D__STDC_HOSTED__=1}} %{remap}\
%{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i\ %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i\
%{E:%W{o*}}"; %{E|M|MM:%W{o*}}";
/* This contains cpp options which are common with cc1_options and are passed /* This contains cpp options which are common with cc1_options and are passed
only when preprocessing only to avoid duplication. */ only when preprocessing only to avoid duplication. */
......
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