I wonder how to write clever makefile for serious C project. This task which may seems to be trivial is actually not so easy, here is why (IMHO):
1. We can compile all source files by seraching for *.c, *.cpp, *.c. Looks like this quick and nice sloution however what if we later one decide that some or all components have "variants" - now we are in trap. This solution have also obvious disadvantage of compilling files that may not even be used.
2. The soultion to above problem would be to create a small makefiles in each module/folder which defines what needs to be compiled. But this solution also have drawback, if we change compiler or sth else system level then we need to change maybe 1000 makefiles.
So, what good practices are recomended for such a case?