Please don't top-post to the mailing list; thanks. > From: Philip Guenther [mailto:[email protected]] > > On Tuesday, February 9, 2010, Mark Galeck (CW) <[email protected]> wrote: > > define FOOBAR > > FOO:=foo > > BAR:=$(FOO) > > endef > > > > $(eval $(call FOOBAR)) > > Conside the output if you instead write > $(info $(call FOOBAR)) > > That shows you what $(eval) is seeing. Make more sense?
On Tue, 2010-02-09 at 21:06 -0800, Mark Galeck (CW) wrote: > Thank you Philip! But... I already knew that... that is, the BAR > gets nothing assigned, that's obvious, and info just confirms that. > The question is, why doesn't it get anything assigned?? It is only > inside eval that this happens... if I just do > > FOO:=foo > BAR:=$(FOO) > > bar: > echo $(BAR) > > everything is fine... that is my question, what is the > difference??? You aren't thinking deeply enough. What Philip is trying to point out is that this doesn't have anything to do with the $(eval). How can it, when you see the same thing when you don't use $(eval) at all? Without the $(eval), what's left? The $(call). What does $(call) do? It evaluates the value of the variable it's given, with some arguments assigned to $1, $2, etc. What does evaluation do? It expands the value. What is the value? The value of FOOBAR is the string: FOO:=foo BAR:=$(FOO) Remember, to $(call) this is just a string. $(call) doesn't think of this as makefile syntax, it's expanding this value exactly as if it were something like "$(CC) $(CFLAGS)" or whatever. At this point, what's the value of the variable FOO? It doesn't have any value. So, what's the result of the expansion? Just as you saw from the $(info) output, it's: FOO:=foo BAR:= And so when you pass that expanded string to $(eval), that's exactly what you get. If you want to defer the expansion of the $(FOO) variable so it's expanded by the $(eval) and not by $(call), you have to escape it so that $(call) doesn't expand it: define FOOBAR FOO:=foo BAR:=$$(FOO) endef Of course in this case, the $(call) is completely useless since you're not assigning any arguments like $1, $2. You might as well just use: $(eval $(FOOBAR)) directly. And, since you don't want to expand any part of the value of FOOBAR before $(eval) gets it, you can avoid escaping $(FOO) by using the $(value) function: $(eval $(value FOOBAR)) However, in real life this isn't often very useful since if there were no variable values in FOOBAR that you wanted to replace, you might as well not bother to use $(eval) anyway. -- ------------------------------------------------------------------------------- Paul D. Smith <[email protected]> Find some GNU make tips at: http://www.gnu.org http://make.mad-scientist.net "Please remain calm...I may be mad, but I am a professional." --Mad Scientist _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
