Mark C
Mark C

Reputation: 129

Run Make on multiple folders

I have the following structure to my makefile:

FOLDERS = folder

Currently, I am able to create a release and debug version in folder/rel and folder/dbg. I would like to extend this so that I can change FOLDERS to

FOLDERS = folder1 folder2 folder3

And for every folder in the variable, it should compile all cpp files and move object files to /rel or /dbg (whichever is specified such as Makefile release or Makefile debug)

Additionally, the Makefile is one level above all the FOLDERS.

So, currently, I generate SOURCES using $(wildcard $(FOLDERS)/*.cpp) which only works when FOLDERS contains one folder but not with two. --> example of it failing would be like folder1 folder2/*.cpp when the intention is folder1/*.cpp and folder2/*.cpp

Please let me know if more details are needed. I am new to this.

Upvotes: 0

Views: 212

Answers (1)

HolyBlackCat
HolyBlackCat

Reputation: 96166

You want $(wildcard $(foo:=/*.cpp)).

Upvotes: 1

Related Questions