File: depgraph.pl

package info (click to toggle)
radare2 0.9.6-3.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 17,496 kB
  • ctags: 45,959
  • sloc: ansic: 240,999; sh: 3,645; makefile: 2,520; python: 1,212; asm: 312; ruby: 214; awk: 209; perl: 188; lisp: 169; java: 23; xml: 17; php: 6
file content (52 lines) | stat: -rw-r--r-- 1,060 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
#
# Usage : perl depgraph.pl | dot -Tpng /dev/stdin > deps.png
#
grep -e DEPS */Makefile | sed -e 's,/Makefile,,' > /tmp/rdeps.txt

MODE=dot
#MODE=gml

if [ $MODE = "dot" ]; then

echo "digraph G {";
cat /tmp/rdeps.txt | perl -ne '
/(.*):(.*)=(.*)$/;
my $lib=$1;
@deps=split(/ /, $3);
foreach $dep (@deps) {
  print " $dep -> r_$lib;\n";
}';
echo "}";

else

echo "graph [";
#cat /tmp/rdeps.txt | cut -d : -f 1 | perl -ne '
#  /(.*)/
#';
cat /tmp/rdeps.txt | perl -ne '
BEGIN { $id = 0; my %libs={}; }
/(.*):(.*)=(.*)$/;
my $lib=$1;
$id++;
  unless($libs{"r_$lib"}) {
	print "node [\n  id \"r_$lib\"\n  label \"r_$lib\"\n]\n";
	print STDERR "r_$lib\n";
	$libs{"r_$lib"}=1;
  }
$libs["r_$lib"]=1;
@deps=split(/ /, $3);
foreach $dep (@deps) {
  unless ($libs{$dep}) {
print STDERR "$dep ***\n";
    print "node [\n  id \"$dep\"\n  label \"$dep\"\n]\n";
    $libs{$dep} = 1;
  }
  #print "edge [\n  source \"r_$lib\"\n  target \"$dep\"\n]\n"
  print "edge [\n  source \"$dep\"\n  target \"r_$lib\"\n]\n"
  #print " $dep -> r_$lib;\n";
}';
echo "]";

fi