diff scripts/makedeps2dot @ 234:eba3744fb238

Added my set of helper scripts. Removes the spell makefile target as it was not use{d,ful} anyway. Btw: I should have ran script/doubles before I printed the document. :-/
author markus schnalke <meillo@marmaro.de>
date Mon, 16 Jul 2012 11:23:30 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/makedeps2dot	Mon Jul 16 11:23:30 2012 +0200
@@ -0,0 +1,51 @@
+#!/usr/bin/env awk
+#
+# List dependencies in Makefile input,
+# ignore a set of default targets and 1:1 dependencies
+# and generate dot graph output
+
+BEGIN {
+	FS = " *: *"
+
+	ignore["all"] = 1
+	ignore["configure"] = 1
+	ignore["Makefile"] = 1
+	ignore["install"] = 1
+	ignore["uninstall"] = 1
+	ignore["clean"] = 1
+	ignore["distclean"] = 1
+	ignore["realclean"] = 1
+	ignore["mostlyclean"] = 1
+	ignore["superclean"] = 1
+	ignore["mmhdist"] = 1
+	ignore["lint"] = 1
+
+	print "digraph foo {"
+}
+
+/^\t/ {
+	next
+}
+
+$1 ~ /^[a-zA-Z_]+$/ {
+	if ($1 in ignore) {
+		next
+	}
+	split($2, dep, /[ \t]+/)
+	for (i in dep) {
+		if (dep[i] ~ /^\$/) {
+			continue
+		}
+		if (dep[i] ~ "^"$1"\\.(o|sh)$") {
+			continue
+		}
+		sub(/\.o$/, ".c", dep[i]);
+		print "\t\"" dep[i] "\" [shape=box];"
+		print "\t\"" dep[i] "\" -> \"" $1 "\";"
+	}
+	print ""
+}
+
+END {
+	print "}"
+}