[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: deferred evaulation of function calls

From: Noel Yap
Subject: Re: deferred evaulation of function calls
Date: Thu, 27 May 2004 13:52:57 -0400
User-agent: Mozilla Thunderbird 0.5 (Windows/20040212)

Technically, I'm not sure what the output should be since the order in which the 
dependencies will be made is undefined.  This is clearer to see if you consider that 
"-j" can be used.

Here's a better-defined makefile:

$ cat GNUmakefile
def = $(wildcard *.aoeu)
imm := $(wildcard *.aoeu)

.PHONY: main
main: t2

.PHONY: t2
t2: clean
        ls *.aoeu
        @echo "wildcard = $(wildcard *.aoeu)"
        @echo "imm = $(imm)"
        @echo "def = $(def)"

.PHONY: clean
clean: t1
        rm *.aoeu

.PHONY: t1
t1: touch
        ls *.aoeu
        @echo "wildcard = $(wildcard *.aoeu)"
        @echo "imm = $(imm)"
        @echo "def = $(def)"

.PHONY: touch
        touch aoeu.aoeu

$ gmake
touch aoeu.aoeu
ls *.aoeu
wildcard =
imm =
def =
rm *.aoeu
ls *.aoeu
ls: *.aoeu: No such file or directory
gmake: *** [t2] Error 1

Judging from the above, what Paul said about the wildcard caching is the most 
likely suspect.

Robert P. J. Day wrote:

On Thu, 27 May 2004, Noel Yap wrote:

':=' evaluates the RHS at the time of the assignment.  '=' evaluates the
RHS at the time of actual use.

but in my original post, i did mention that my tests seemed to show no
difference. here's a sample makefile i used, in a directory with at least a couple of .o files:


.PHONY: main t1 t2 clean

imm := $(wildcard *.o)
def = $(wildcard *.o)

main:   t1 clean t2

        @echo imm = ${imm}
        @echo def = ${def}

        rm *.o

        @echo imm = ${imm}
        @echo def = ${def}


this is invoked in a directory with some object (*.o) files. based on what you just said, what do you expect as the output? i got the following:

imm = a.o b.o
def = a.o b.o
rm *.o
imm = a.o b.o
def = a.o b.o  ????? why?

given that "def" was a deferred assignment, i would have thought that its second value would be the empty string since, at the "time of actual use", as you put it, there are no .o files left.

  or am i misreading something?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]