Subject: bin/10204: .for loop in rules does not handle ${.TARGET}
To: None <gnats-bugs@gnats.netbsd.org>
From: Simon J. Gerraty <sjg@quick.com.au>
List: netbsd-bugs
Date: 05/26/2000 21:31:14
>Number:         10204
>Category:       bin
>Synopsis:       .for loop in rules does not handle ${.TARGET}
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 26 21:32:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Simon J. Gerraty
>Release:        all
>Organization:
Zen Programming...
>Environment:
	
System: NetBSD zen.quick.com.au 1.4.2 NetBSD 1.4.2 (ZEN) #2: Wed Mar 22 01:07:26 EST 2000 root@zen.quick.com.au:/u3/NetBSD/1.4.X/src/sys/arch/i386/compile/ZEN i386


>Description:
	
variables which are local to rules for a given target eg ${.TARGET} are
not processed correctly within .for loop.
>How-To-Repeat:
	
In the makefile below the output for the target bad, 
should be the same as for the target ok. Ie.

$ make ok
t=/path/one/foo-bar.tgz
t:T=foo-bar.tgz
t:R=/path/one/foo-bar
t:R:T=foo-bar
t:R:T:S/foo-//=bar
t=/path/one/foo-bar-debug.tgz
t:T=foo-bar-debug.tgz
t:R=/path/one/foo-bar-debug
t:R:T=foo-bar-debug
t:R:T:S/foo-//=bar-debug

rather than:

$ make bad
t=/path/one/foo-bar.tgz
t:T=/path/one/foo-bar.tgz
t:R=
t:R:T=
t:R:T:S/foo-//=
t=/path/one/foo-bar-debug.tgz
t:T=/path/one/foo-bar-debug.tgz
t:R=/path/one/foo-bar-debug
t:R:T=/path/one/foo-bar-debug
t:R:T:S/foo-//=/path/one/foo-bar-debug

Makefile:

foo=/path/one/foo-bar.tgz

all bad: ${foo}

# this should produce the same output as 'ok' below, but does not.
${foo}:
.for t in ${.TARGET} ${.TARGET:R}-debug.tgz
	@echo t=$t
	@echo t:T=${t:T}
	@echo t:R=${t:R}
	@echo t:R:T=${t:R:T}
	@echo t:R:T:S/foo-//=${t:R:T:S/foo-//}
.endfor

ok:
.for t in ${foo} ${foo:R}-debug.tgz
	@echo t=$t
	@echo t:T=${t:T}
	@echo t:R=${t:R}
	@echo t:R:T=${t:R:T}
	@echo t:R:T:S/foo-//=${t:R:T:S/foo-//}
.endfor

>Fix:
	
I'll see what I can come up with.  This PR is so I don't forget.

>Release-Note:
>Audit-Trail:
>Unformatted: