Subject: make: asignment modifiers
To: None <>
From: Simon J. Gerraty <>
List: current-users
Date: 05/27/2000 16:14:19
I'm thinking of adding a new make variable modifier '=' (and '+=',
etc).  This message is to solicit feedback on the idea.


PR bin/10204 shows that the following does not work
due to the way that .for loops are implemented.

.for t in ${.TARGET} ${.TARGET:R}-blah.gz
	@echo t:T=${t:T}
	@echo t:R:T=${t:R:T}

As the makefile is read, ${.TARGET} has no value, but t is expanded at
this point so ${t:T} comes out as nothing.  Using a variable
assignment modifier, the above .for loop could be read as.

	@echo t:T=${t:T}
	@echo t:R:T=${t:R:T}
	@echo t:T=${t:T}
	@echo t:R:T=${t:R:T}

and work as expected (I think ;-).  No expansion would be needed as
the makefile is parsed.  Obviously this is only of benefit to .for
loops appearing in target rules.  And one might need to do something
to ensure that lines with the assignments (which I believe should
expand to nothing) don't cause a problem.

In another case,  I have need of the += version within a .USE
target's rules.  It adds ${.TARGET} to a which
initializes a variable when read eg.

	echo FOO+=${.TARGET} >>

and the rules test for ${FOO:M${.TARGET}} = '', obviously it would be
handy if the above snipet were.

	echo FOO+=${.TARGET} >>; ${FOO:+=${.TARGET}}

so that the test would work correctly within the same make run.

Oh and doing =+ =? etc would be much simpler to parse than += ?=.

If anyone has any comments/suggestions I'd like to hear.