I have a project that has a makefile with broken dependencies. Is there any best known way to generate a list of dependencies for the project that I can use in the makefile, other than examining each source file by hand or with a hand written perl script?
Share
GNU make‘s documentation provides a good solution.
Absolutely.
g++ -MM <your file>will generate a GMake compatible list of dependencies. I use something like this:Note:
$(CXX)/gcccommand must be preceded with a hard tabWhat this will do is automatically generate the dependencies for each file that has changed, and compile them according to whatever rule you have in place. This allows me to just dump new files into the
src/directory, and have them compiled automatically, dependencies and all.