bugmake - Bugs: bug #51973, variable value set by...

 
 

bug #51973: variable value set by target-specific assignment not available to reference in multi-line variable definition

Submitted by:  J. Hart <oss542>
Submitted on:  Sat 09 Sep 2017 08:30:55 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: Not A BugPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: 4.2.1Operating System: POSIX-Based
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 09 Sep 2017 11:06:16 PM UTC, comment #2:

Anonymous:
You are indeed correct. I did not take that first expansion into account. I think your explanation resolves this issue.
Many Thanks for this.

J. Hart <oss542>
Sat 09 Sep 2017 08:53:26 PM UTC, comment #1:

This makefile is behaving as defined: when $(call) is used, make performs a round of variable expansion on the value of the variable that is called. So, when you say

$(call EXELNK,utl1)

make expands that to

utl1:;@echo "jfh1:pt1::"

This expansion is taking place at the top-level of make parsing and not in the context of building a target, so there are no target-specific variable settings to use and $(OBJ1) expands to nothing. Later, when make invokes that recipe to build the target, it does another round of variable expansion with the target-specific variables in place...but at that point there are no variable references left.

In order to have it expand to what you want, you need get the $(OBJ1) variable reference through the $(call) expansion through to the actual target building. To do that, double the dollar-sign:

define EXELNK
$(1):;@echo "jfh1:pt1:$$(OBJ1):"
endef

During the expansion of the $(call), the $$ will expand to $ so that the full rule will be

utl1:;@echo "jfh1:pt1:$(OBJ1):"

...and then when it's invoked as a recipe that target-specific variable expansion will take place as desired.

Anonymous
Sat 09 Sep 2017 08:30:55 PM UTC, original submission:

Makefile:

define EXELNK
$(1):;@echo "jfh1:pt1:$(OBJ1):"
endef
utl1: OBJ1=xOBJ1
$(call EXELNK, utl1)

result of invoking make :
actual - jfh1:pt1::
expected - jfh1:pt1:xOBJ1:

J. Hart <oss542>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by psmith (Updated the item)
  • -unavailable- added by oss542 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 10 Sep 2017 01:39:34 PM UTCpsmithStatusNone=>Not A Bug
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1