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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Robert Morell
URL:
  <http://savannah.gnu.org/bugs/?51414>

                 Summary: Use of multiple $$% (for .SECONDEXPANSION) causes
make to misinterpret the rule as a pattern rule
                 Project: make
            Submitted by: None
            Submitted on: Fri 07 Jul 2017 01:15:19 PM UTC
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.2.1
        Operating System: None
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

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





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51414>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Robert Morell
Update of bug #51414 (project make):

                  Status:                    None => Not A Bug              
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up 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


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51414>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Loading...