[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
order of evaluation
From: |
Dan DeJohn |
Subject: |
order of evaluation |
Date: |
Thu, 05 Sep 2002 16:17:08 -0400 |
After reading the manual section "How make Reads a Makefile" I am still
missing something.
In the list of commands for a rule, I want to execute a particular
command (mv a file) only if one of the previous commands created the file.
In my sample, I use "touch" (which, unlike my real command, always
creates the file). I'd expect the following to print "Xxxx.abcX" and
"YES" in every case, but it always prints "XX" and "NO" unless xxx.abc
exists prior to running gnumake. So clearly the $(if . . .) is being
evaluated before the touch is executed. I don't understand why, and
don't know how to get the proper conditional execution of my mv command.
makefile:
all:
touch xxx.abc
echo X$(wildcard *.abc)X
$(if $(wildcard *.abc), @echo YES, @echo NO)
execution:
% /bin/rm xxx.abc
% make all
touch xxx.abc
echo XX
XX
NO
% make all
touch xxx.abc
echo Xxxx.abcX
Xxxx.abcX
YES
--
Dan DeJohn
address@hidden
- order of evaluation,
Dan DeJohn <=