bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with secondary expansion and target specific variables


From: Thomas Daniel
Subject: Problem with secondary expansion and target specific variables
Date: Sun, 30 Dec 2012 10:27:04 -0800
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0

The following makefile.1 produces correct results:
-------------------------------
target1 : var := one
target2 : var := two

targets := target1 target2

all : $(targets)

.SECONDEXPANSION:
$(targets) : foo/$$(var)/bar

foo/%/bar :
    mkdir -p $(dir $@)
    touch $@

.PHONY : target1 target2
-------------------------

> make -f makefile.1
mkdir -p foo/one/
touch foo/one/bar
mkdir -p foo/two/
touch foo/two/bar

However, makefile.2 does not pick up var:
-----------------------------------------
target1 : var := one
target2 : var := two

targets := target1 target2

all : $(targets)

.SECONDEXPANSION:
$(targets) : test/$$@

$(targets:%=test/%) : foo/$$(var)/bar

foo/%/bar :
    mkdir -p $(dir $@)
    touch $@

.PHONY : $(targets) $(targets:%=test/%)
------------------------------------

> make -f makefile.2
make: *** No rule to make target `foo//bar', needed by `test/target1'. Stop.

According to make documentation:
"when you define a target-specific variable that variable value is also in effect for all prerequisites of this target, and all their prerequisites, etc."

Since test/target1 is a prerequisite for target1 and var is defined for target1, it should be available also for test/target1. Secondary expansion works when expanding 'var' for target1 and target2 in makefile.1, but it doesn't when expanding it in makefile.2

Am I doing something incorrect here or is it an unimplemented functionality, specifically that target specific variables are not inherited in prerequisites of prerequisite?

The behavior is the same in 3.81 and 3.82.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]