Are there any good tools for examining Makefiles? [closed]
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this questionLarge complex make files can be daunting to read and examine. What tools are good for visualizing or otherwise examining a gnu make file?
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
There is a Perl library for building GraphViz figures from Makefiles:
https://metacpan.org/pod/GraphViz::Makefile
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!
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.
精彩评论