user2497792
user2497792

Reputation: 525

Test if files in another directory exist in makefile

How would one test for the existence of files with a certain extension (.cpp in this case) in a directory at a specified location which is several directories down from the location of the makefile? I would like to print(echo) a message out if they are found

Upvotes: 0

Views: 364

Answers (1)

MadScientist
MadScientist

Reputation: 101041

Your question is ambiguous. You mean, inside a make recipe you want to perform this test? If so then just write the appropriate shell scripting to check for the existence of said files.

If you mean outside of any recipe, in the makefile itself, if you're using GNU make you can use the $(wildcard ...) function:

ifneq (,$(wildcard some/sub/directory/*.cpp))
  $(info found some cpp files!)
endif

Upvotes: 1

Related Questions