views:

60

answers:

2

I need to add some capabilities to very complex, multi-layered makefile (lots of include files, lots of targets, lots of variables) that was written by someone else who of course is no longer with the company. There are some folks here who understand some of it, but not the whole thing.

Is there a Make debugger where I can single-step through it, or some equivalent way to follow the execution through the many files and targets that a compile flows through? Or is there some other way to get a handle on how this thing works?

+2  A: 

You might want to look at this article http://oreilly.com/catalog/make3/book/ch12.pdf (A chapter "Debugging Makefiles" from Oreilly's "Managing Projects with GNU Make, Third Edition")

AmirW
+1  A: 

GNU Make has various options for printing out some debugging information while running. -d will print out a whole lot of debugging information; perhaps too much, and perhaps not what you need, but you might try sifting through that. There are also options like -n for doing a dry run, -p for printing the database of rules, -w for printing out which directory you're in to help track down issues in complicated recursive makes, and --warn-undefined-variables for tracking down certain problems with variables.

If none of that works, you might want to try Remake, which claims to be a patched GNU make with a debugger. I haven't used it, but from the documentation, it looks like it might help you out, and it has some more advice on trying to track down bugs in Makefiles.

Brian Campbell