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


bug #18305: target specific variables with conditional assignments

Submitter:  Oliver Kiddle <opk>
Submitted:  Wed 15 Nov 2006 12:44:30 PM UTC
Severity:  3 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  3.81 Operating System:  Any
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup

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>
Group 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
        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 Kiddle <opk>


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

Attach Files:

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.


    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-06-10 psmith Item GroupBug Enhancement

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code