meillo@234: #!/usr/bin/env awk meillo@234: # meillo@234: # List dependencies in Makefile input, meillo@234: # ignore a set of default targets and 1:1 dependencies meillo@234: # and generate dot graph output meillo@234: meillo@234: BEGIN { meillo@234: FS = " *: *" meillo@234: meillo@234: ignore["all"] = 1 meillo@234: ignore["configure"] = 1 meillo@234: ignore["Makefile"] = 1 meillo@234: ignore["install"] = 1 meillo@234: ignore["uninstall"] = 1 meillo@234: ignore["clean"] = 1 meillo@234: ignore["distclean"] = 1 meillo@234: ignore["realclean"] = 1 meillo@234: ignore["mostlyclean"] = 1 meillo@234: ignore["superclean"] = 1 meillo@234: ignore["mmhdist"] = 1 meillo@234: ignore["lint"] = 1 meillo@234: meillo@234: print "digraph foo {" meillo@234: } meillo@234: meillo@234: /^\t/ { meillo@234: next meillo@234: } meillo@234: meillo@234: $1 ~ /^[a-zA-Z_]+$/ { meillo@234: if ($1 in ignore) { meillo@234: next meillo@234: } meillo@234: split($2, dep, /[ \t]+/) meillo@234: for (i in dep) { meillo@234: if (dep[i] ~ /^\$/) { meillo@234: continue meillo@234: } meillo@234: if (dep[i] ~ "^"$1"\\.(o|sh)$") { meillo@234: continue meillo@234: } meillo@234: sub(/\.o$/, ".c", dep[i]); meillo@234: print "\t\"" dep[i] "\" [shape=box];" meillo@234: print "\t\"" dep[i] "\" -> \"" $1 "\";" meillo@234: } meillo@234: print "" meillo@234: } meillo@234: meillo@234: END { meillo@234: print "}" meillo@234: }