From e364498113e145b5ac424325e3903cc2287d7e7f Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Tue, 8 Apr 2014 18:25:27 -0400 Subject: [SV 41983] Support omitting the text argument to $(file ...) Reported by Tim Murphy * function.c (func_file): Only write TEXT if it is not NULL. * NEWS, doc/make.texi: Document the new feature * tests/scripts/functions/file: Verify that the no-text version of $(file ...) works and doesn't add a newline. --- doc/make.texi | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/make.texi b/doc/make.texi index 8fbdb61..21e32de 100644 --- a/doc/make.texi +++ b/doc/make.texi @@ -1528,7 +1528,7 @@ A rule is always expanded the same way, regardless of the form: @example @var{immediate} : @var{immediate} ; @var{deferred} - @var{deferred} + @var{deferred} @end example That is, the target and prerequisite sections are expanded immediately, @@ -7516,7 +7516,7 @@ exist. The syntax of the @code{file} function is: @example -$(file @var{op} @var{filename},@var{text}) +$(file @var{op} @var{filename}[,@var{text}]) @end example The operator @var{op} can be either @code{>} which indicates overwrite @@ -7528,8 +7528,9 @@ When the @code{file} function is expanded all its arguments are expanded first, then the file indicated by @var{filename} will be opened in the mode described by @var{op}. Finally @var{text} will be written to the file. If @var{text} does not already end in a newline, -a final newline will be written. The result of evaluating the -@code{file} function is always the empty string. +even if empty, a final newline will be written. If the @var{text} +argument is not given, nothing will be written. The result of +evaluating the @code{file} function is always the empty string. It is a fatal error if the file cannot be opened for writing, or if the write operation fails. @@ -7556,7 +7557,7 @@ input file, you might write your recipe like this: @example @group program: $(OBJECTS) - $(file >$@@.in,) $(foreach O,$^,$(file >>$@@.in,$O)) + $(file >$@@.in) $(foreach O,$^,$(file >>$@@.in,$O)) $(CMD) $(CMDFLAGS) @@$@@.in @@rm $@@.in @end group -- cgit v1.2.3