all: $(addprefix target,1 2 3 4 5 6 7 8 9 10)
@echo glob: $(wildcard target*)
target%:
touch $@
To wit:
$ make
touch target1
touch target2
touch target3
touch target4
touch target5
touch target6
touch target7
touch target8
touch target9
touch target10
glob:
$ make
glob: target10 target3 target8 target7 target6 target5 target1 target2 target9 target4
This is not a weird or contrived use case: this is wildcard not finding targets in a recipe executed after they've been built as explicit prerequisites.
I understand the performance argument in favor of caching, but the existing behavior is incorrect and entirely counter to expectations: no one writing a makefile wants or expects wildcard to behave this way. $(shell echo target*) is a fine workaround for now, but it's frankly inane to have to do that. I spent several hours tracking down the problem here, time that likely exceeds years of builds with some extra readdirs.
Why not refresh the cache when the directory's mtime has changed?