bugmake - Bugs: bug #58961, Document dynamic phony targets.

 
 

bug #58961: Document dynamic phony targets.

Submitter:  Dmitry Goncharov <dgoncharov>
Submitted:  Sat 15 Aug 2020 02:44:41 PM UTC
   
 
Severity:  3 - Normal Item Group:  Documentation
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  None Operating System:  None
Fixed Release:  4.4 Triage Status:  Small Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 06 Dec 2020 08:32:18 PM UTC, comment #2: 

The text here seemed to me to be too extended to explain the restriction so I wrote it like this instead:


+Prerequisites of @code{.PHONY} are always interpreted as literal
+target names, never as patterns (even if they contain @samp{%}
+characters).  To always rebuild a pattern rule consider using a
+``force target'' (@pxref{Force Targets, ,Rules without Recipes or
+Prerequisites}).


Hopefully that is sufficient.

Paul D. Smith <psmith>
Group administrator
Sat 15 Aug 2020 03:27:35 PM UTC, comment #1: 

Please use the latest attached file.

Dmitry Goncharov <dgoncharov>
Sat 15 Aug 2020 02:44:41 PM UTC, original submission:  

Document dynamic phony targets.

diff --git a/doc/make.texi b/doc/make.texi
index 21573c0..a8aa3a2 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -2829,6 +2829,28 @@ cleandiff :
         rm *.diff
 @end example
 
+.PHONY works with prerequisites statically defined in the makefile.
+Declaring a target that changes depending on user input or some other external
+condition as a prerequisites of .PHONY will not achieve the desired effect.
+
+@example
+print-%:
+       @@echo $* = $($*)
+@end example
+
+This rule will print the value of a variable specified by the user on the
+command line.
+
+If you say @samp{make print-OBJ}, make will print the value of variable @var{obj}.
+However, if there is a file called print-OBJ in the current directory, then this
+rule will not be executed.
+
+Declaring @samp{print-%} a prerequisite of .PHONY will not work, because when
+you say @samp{make print-OBJ} the target is @samp{print-OBJ}, not
+@samp{print-%}.
+
+You can force such target. @xref{Force Targets}.
+
 @node Force Targets, Empty Targets, Phony Targets, Rules
 @section Rules without Recipes or Prerequisites
 @cindex force targets

Dmitry Goncharov <dgoncharov>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by dgoncharov (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-12-06 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.4
        Triage StatusNone Small Effort
    2020-08-15 dgoncharov Attached File- Added doc_dynamic_phony_targets.diff, #49677
    2020-08-15 dgoncharov Attached File- Added doc_dynamic_phony_targets.diff, #49676

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code