On Sun, Jun 21, 2009 at 1:48 PM, jacques<soliton1...@yahoo.fr> wrote: > By writing a simple program (program_a), I was able to see some strange > behaviours of 'ifeq' > > program_a: > ifeq("foo","foo") \ > TOOL = tool \ > endif > > start: > @echo $TOOL > > > whose execution by "make -f program_a" yields a newline.
"make -f program_a" tells make to ignore your Makefile and instead read the file "program_a" as a Makefile. Did you *really* do that, or did you instead run make program_a ? When I try "make program_a", I get the following: $ make make: Nothing to be done for `program_a'. $ > First question: The gmake on-line manual states that the syntax of a > conditional test follows the following template (7.2): > > conditional-directive > text-if-true > else > text-if-false > endif > > Notice that there is no backslash character in the definition. In > 'program_a', if I don't put the backslashes, the program gives execution > errors. So backslashes are compulsory eventhough the manual says otherwise. > Is it just a bug that will be fixed in later versions or is there a deeper > significance ( the 'ifdef' and 'ifndef' conditionals behave syntatically > according to the gmakeon-line manual !!) ? Where to start.. 1) you did not actually write a ifeq conditional: to be an ifeq conditional, there MUST be a space after the word "ifeq"! 2) ending a line with a backslash tells make to join the line with the following line. By ending those two lines with backslashes, you effectively gave make the following: ifeq("foo","foo") TOOL = tool endif That's a variable assignment! Yes, the name of the variable is ifeq("foo","foo") TOOL as can be confirmed by adding this to the 'start' target: @echo ${ifeq("foo","foo") TOOL} You'll find that "make start" then echos "tool endif" So: insert a space after 'ifeq' and remove the backslashes. You'll then find that it still doesn't work...because you didn't use the TOOL variable properly. To make, "$TOOL" means "the value of the 'T' variable, followed by 'OOL'". If a variable has more than one character in it's name, you must enclose the name in either brackets or parens. Use ${TOOL} or $(TOOL). I'm not sure what the "program_a" target is supposed to be doing in your example Makefile. You _do_ understand that the assignment to TOOL will *not* be specific to that target, don't you? Philip Guenther _______________________________________________ Help-make mailing list Help-make@gnu.org http://lists.gnu.org/mailman/listinfo/help-make