- Online Community Forums » Programming Questions » Make, only with dependencies

This thread is locked; no one can reply to it. rss feed Print
Make, only with dependencies
Mark Oates
Member #1,146
March 2001

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:

And I'm doing testing with Google Test on this project.

Any tips on how to proceed?

Member #12,636
March 2011

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.

Member #7,536
July 2006

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.

Go to: