I'm trying to have a makefile variable for the content of a directory after that directory has been updated by a recipe.
Why does this not work:
A_FILE = $(wildcard subdir/*)
all: a
@echo $(A_FILE)
a:
@mkdir ./subdir
@touch subdir/b
@touch a
$ rm -rf ./subdir && make
$
...whereas this does:
A_FILE = $(wildcard subdir/*)
all: a
@echo $(A_FILE)
a: subdir/b
@touch a
subdir/b:
@mkdir ./subdir
@touch subdir/b
$ rm -rf ./subdir && make
subdir/b
$
?
I thought lazy-evaluation meant the variable was not evaluated until actually used. In both versions, $(A_FILE)
is used in the same recipe, and after a prereq has been evaluated. In fact, I'd struggle to articulate a meaningful difference between the two rules, other than the superficial: the first is a chain of two rules/prereqs, and the second is a chain of three.