I am working on a project in which the Makefile are used in haphazard manner. Project structure is shown as below
ProjectX ---- AppA
---- AppB
---- LibC
---- LibD
---- ToolE ---- AppF
---- LibG
All these folders and sub-folders have their own Makefiles. They are invoked one by one from ProjectX, ToolE etc. In this setup, AppA may be dependent on LibC/LibD etc. But since they have different Makefile, the dependencies are not properly mentioned in the target recipe.
Now the problem at hand is that, I would like to make this project compile in parallel(make -jN
)
I have tried generating the dependency files using gcc -M
option and include
ing these dependency files in the Makefile. But at times what I see is the only the .o
are created but not the lib or the App. This may be because make sees the dependency and waits for the dependency to be ready. But doesn't know how to resume?
What is the best approach to fix this.
UPDATE
I understand that recursive make is a bad thing. But if you stuck with it due to legacy reasons, it's difficult to get the parallel make working.
For more on why recursive make is bad see this