Hey guys, I'm looking for pointers on managing makefile targets and only linking the necessary binaries.
Specifically, I'm compiling tests, I want to only compile and link the .o files necessary for that test. I believe this means the makefile will need to introspectively look into the source and headers for each object required, infer if any of the dependent files have been modified (including headers of dependencies), re-compile them, and then use those objects when linking the test.
Right now the test file looks like this: https://github.com/MarkOates/fullscore/blob/master/Makefile#L80-L84
And I'm doing testing with Google Test on this project.
Any tips on how to proceed?
Personally, I would probably get CMake involved since it makes scripting for testing, etc that much easier. Of course, you could do it with pure make files but then there will be a lot of manual work getting things to work.
Make handles static dependencies well. What it doesn't do very well is dynamic dependencies. For that you could generate a Makefile dynamically instead. I suppose that's what CMake and other related tools are sort of for. I just haven't found one that seemed worth the investment.