kalyan wrote: > define test_var > if [ 1 = 0 ];then \ > DUMMY=$(eval $(change_value)); \ > fi; \ > echo $(VAR) > endef > [...] > I expected the output on my console to be 0 but i got 1 ? > Any hints on what might be going wrong here are appreciated.
As the others have said make is performing exactly what is asked of it, namely substituting variables found in the command before invoking it. Perhaps what is confusing you is that the $(eval) was in an 'if' clause that is never true, so you expected it not to be evaluated. But that is an incorrect view of how make treats the contents of commands. The list of commands (i.e. everything that begins with a TAB) might as well be complete gibberish to make. It is a payload which is shipped off wholesale to the shell for execution. Make has no comprehension[1] of its semantics, except that before it sends it to the shell it expands every $(variable) that it sees in the block. It does not have any notion of what that text might mean to the shell, it's just text. It is only after the shell has been invoked and make is out of the picture that the 'if' has any meaning. Brian [1] This is not entirely true, as make does have an optimization whose purpose is to detect whether the command is a simple invocation of one program or whether the shell is in fact required to perform some function like redirection or control flow. But that's just an optimization for speed, it doesn't change the fact that make doesn't fundamentally understand anything of the semantics of what it's invoking. _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
