GNU make problem with foreach construct - TechRepublic
General discussion
June 19, 2005 at 02:35 PM
godhner

GNU make problem with foreach construct

by godhner . Updated 20 years, 11 months ago

I’ve been having difficulties using the “foreach” construct in GNU
make, and I’m hoping someone has some insight to help me
understand why I can’t get consistently productive behavior from
it. In the Make manual section 8.8 it says the “eval” function
may be used to create new rules, among other things. It also
gives an example of the combined use of “foreach”, “eval”, and
“call” to create a template for a command which is used in the
example to apply in rules for a list of programs. In my makefiles
I have tried with mixed success to use this same template
system to create rules for lists of specific targets. If my
template specifies that a depends on a.o and a.o depends on
a.c, then the rules remain unseen consistently. But if I create a
rule for a depending on a.c directly, then in some cases I find
that the template-created rule works, and in other cases I find it
doesn’t. I can’t find the difference, and of course the
documentation goes no further to clarify the requirements (so
far as I can find). Is there perchance anyone reading this who
knows the special incantations which will sort the working
templates from the non-working templates? Does anyone have
the ear of the elusive make-genie and will ask it a favor on my
behalf?

This discussion is locked

All Comments