bugmake - Bugs: bug #18305, target specific variables with...

 
 

bug #18305: target specific variables with conditional assignments

Submitted by:  Oliver Kiddle <opk>
Submitted on:  Wed 15 Nov 2006 12:44:30 PM UTC  
 
Severity: 3 - NormalItem Group: Enhancement
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Component Version: 3.81Operating System: Any
Fixed Release: NoneTriage Status: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

Wed 10 Jun 2009 02:47:53 AM UTC, comment #1:

Hm. The way conditional variables work is that the "conditionality" of the variable is determined when the variable is assigned (in immediate context), not when the variable is expanded. When we evaluate the variable assignment in "lib: TARGET ?= two" we don't have the inheritance of the "all" target in scope yet, because that doesn't happen until make actually runs the makefile. So at the time that we evaluation "conditionality" there is no other value in scope.

Now actually I lied a little bit because even if you set "TARGET = global" as a global setting, which clearly IS in-scope when the target-specific variable is set, the result will still be "two". That's because conditionality only looks at variables assigned in the same scope.

I don't know if this is really a bug or not. On the one hand it seems like it would be useful to allow conditional assignments such as you describe, but to do that we'd need to change the way variables work to defer the conditional decision until runtime, which means saving the conditional value. That clearly doesn't make sense for global variables since they can be decided right then, so it would only be for target/pattern-specific variables. I'd rather do it all or nothing rather than have global settings work one way and inherited target vars work another.

I'm marking this as an enhancement request, although it's probably a bug that, at least, the docs don't make clear how this works.

Paul D. Smith <psmith>
Project Administrator
Wed 15 Nov 2006 12:44:30 PM UTC, original submission:

If a target-specific conditional variable assignment is used, it unconditionally overrides any inherited target-specific variable. Try the following Makefile with and without the first line. The command is always run with the argument 'two'.

all: TARGET = one
all: lib

lib: TARGET ?= two
lib:
make -f second.mk $(TARGET)

The bug might arguably be that the target-specific variable is being inherited at all though that's actually a useful feature for me. I can get this Makefile to work as I want by using $(or $(TARGET),two).

Oliver

Oliver Kiddle <opk>

 

(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 (Posted a comment)
  •  

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

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 10 Jun 2009 02:47:53 AM UTCpsmithItem GroupBug=>Enhancement

    Back to the top


    Powered by Savane 3.1-cleanup