views:

152

answers:

4

Large complex make files can be daunting to read and examine. What tools are good for visualizing or otherwise examining a gnu make file?

+3  A: 

There is a Perl library for building GraphViz figures from Makefiles:

http://search.cpan.org/~srezic/GraphViz-Makefile-1.15/Makefile.pm

Joe Carnahan
I found this similarly named one and it's also good for producing png fileshttp://search.cpan.org/~agent/Makefile-GraphViz-0.18/lib/Makefile/GraphViz.pm
Johnny
+1  A: 

I don't know of a tool that can make sense of a set of makefiles. It may indeed be nearly impossible to create one as most large make based build environments are a hodge-podge of random commands, frightening macro substitution, and hugely context dependent control flow.

As an aside, I hear good things about SCons which I'm looking at because I'm involved with a system make environment which has become a maintenance nightmare in its own right.

msw
SCons is my favorite build system, but make has one huge advantage. You can quickly write a make file to execute any program against a set of files. SCons uses various plugins for different build task, it includes plugins for common compilers, but in some cases you might have to write your own.
mikerobi
+1  A: 

I've had good success with the --print-data-base (-p) option.

Combined with --just-print (-n, --dry-run) and redirecting stdout to a file creates a new single makefile containing all the rules and variables in a generic format which you may find easier to understand.

With really bad makefiles I've gone as far as parsing this output in Perl to generate a new build system!

Martin Fido
A: 

I tried to use CPAN's visualizer and failed. So, I've written my own quick-n-dirty Makefile visualizer.

You may want to try it: http://github.com/vak/makefile2dot

vak