tech-toolchain archive

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

make: .for loops in commands

Is there, in make, any sane way to assemble a single shell command using 
.for loops and .if conditionals? I want to do something along the lines of

.for i in ${list}
		echo ${i};\
	} > ${.TARGET}

(of course it's more complicated than the example, wehere I could simply 
echo ${list}, it involves nested loops and conditionals)

I could do

	echo >${.TARGET}
.for i in ${list}
		echo ${i} >>${.TARGET}

but that's certainly more expensive.

I could also try to use the :@ loop construct and :U, :D and :? modifiers, 
but given the structure of the loops and conditional expressions, that's 
going to become unreadable at best.

From reading the man page, I was under the impression that (provided I don't 
use -B)

	exec >${.TARGET}
.for i in ${list}
		echo ${i}

would work, but make calls one shell per echo line.

I also guess it won't work to assemble the shell command into a make variable 
and execute that due to the quoting hell that's going to be.

Home | Main Index | Thread Index | Old Index