Reputation: 145
I am trying to get all the files inside each folder with Makefile:
Test = $(wildcard */)
install: all
@for dir in $(TEST); do \
echo $$dir; \
echo $(wildcard $$dir); \
done
First echo outputs correctly: folder1/ folder2/ folder3/ but when used with wildcard in second echo I am getting empty output (each folder contains many files). Any suggestions why this doesn't work and how to archive this?
Upvotes: 2
Views: 2015
Reputation: 65928
$(wildcard)
is make function, which is evaluated once while makefile is parsed.
dir
is a shell variable, which exists only when receipt is evaluated (using shell).
Because make is unaware about shell variables, pattern in $(wildcard $$dir)
is interpreted by make literally: $$dir
.
If you want to output list of files in a directory pointed by dir
variable, you should use shell utilities. E.g. ls $$dir
.
Upvotes: 4