From some path, I use
PATHS = $(wildcard $(SOME_PATH)/*)
to get all sub-paths.
I need to know whether it’s a file or a directory.
How to do it in make?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
John Marshall has a way that will work, but there’s a safer way. All directories always have a single entry that is well known, and that’s “.”. So, what you have to do is:
The wildcard will match all directories, and only directories, since only directories contain “.”. This is robust.
Yehnan’s way works as well but is less efficient because you’re invoking a shell for each element in PATHS. Most likely this won’t impact your runtime much overall but if it can be done inside make rather than by running shell, I would prefer that. Also it helps portability to avoid $(shell …).