tech-pkg archive

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

Re: make variable expansion oddity



On Thu, May 26, 2016 at 10:44:51PM +0200, Roland Illig wrote:
 > > 	.for var val in ${SED_SUBSTS}
 > > 	SED_CMD+= -e s,@${var}@,${val},
 > > 	.endfor
 > 
 > In a .for loop, the part after "in" is evaluated at parse time. And
 > there is another quirk. Splitting of the words is done at simple
 > whitespace, ignoring "double" and 'single quotes' completely. This is
 > contrary to all other places in make(1).

Er wut? There isn't anywhere in make that honors shell quotes, except
maybe in some obscure variable substitution modifier.

(Granted escaping and quoting in make is a minor trainwreck...)

 > In summary, these things are evaluated at parse time:
 > 
 > * .if conditions
 > * .for loops
 > * the right-hand side of the != assignment operator
 > * the right-hand side of the := assignment operator
 > * variables in dependency lines, like ${TARGETS}: ${SOURCES}

The last is not quite accurate :-)

You can write omnibus rules of the form

   foo.o bar.o baz.o: $(.TARGET:.o=.c)

and it will evaluate $(.TARGET) in the context of the target it's
currently considering; this happens at runtime.

(there are a number of reasons this feature isn't actually useful in
practice, but it does exist)

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index