bugmake - Bugs: bug #51414, Use of multiple $$% (for...

 
 

bug #51414: Use of multiple $$% (for .SECONDEXPANSION) causes make to misinterpret the rule as a pattern rule

Submitter:  None
Submitted:  Fri 07 Jul 2017 01:15:19 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.2.1 Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 09 Jul 2017 09:26:49 PM UTC, comment #1: 

Actually what's happening is that your rule is being misinterpreted as a static pattern rule, not a pattern rule, and it's not because you are using $$%, it's because you are using a substitution reference in a secondary expansion.  Also it doesn't matter how many uses of "$$%" you use; even one substitution reference will show this problem.

Because you have used "$$" in the prerequisites list, make doesn't interpret this as a variable reference.  That means the open parenthesis is not part of a variable reference and has no special meaning to make.  So when make sees this:


blahblah : $$(%:blah)


it tokenizes this string as "blahblah", ":", "$$(%", ":", "blah)".  The ":" IS a special character to make, it's a rule separator.  When make sees a word containing the special character "%" between two ":" characters it interprets this to be a static pattern rule.  Because the "target" doesn't match the pattern, you get this error.

I don't see any way to solve this problem: the grammar here is simply ambiguous and make can't know what you mean.

In order to do what you want you cannot use a substitution reference (directly) because of the ":" character in it.  You can either use a patsubst function:


.SECONDEXPANSION:

libmy.a(my_source.o): $$(patsubst %_source.o,%,$$%)_internal.h


(here there's no ":" in the prereq list so it works).  Or you can use a variable to hide the ":" and ensure that make parses things correctly:


nosource = $$(%:_source.o=)

.SECONDEXPANSION:

libmy.a(my_source.o): $$(nosource)_internal.h


Paul D. Smith <psmith>
Group administrator
Fri 07 Jul 2017 01:15:19 PM UTC, original submission:  

Minimal test Makefile:


.SECONDEXPANSION:

libmy.a(my_source.o): $$(%:_source.o=)_internal.h $$(%:_source.o=)_api.h


Resulting error message:

../test_makefile:2: target 'libmy.a(my_source.o)' doesn't match the target pattern

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

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)
  •  

    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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-07-09 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code