#!/usr/bin/perl

# cinclude2dot v0.2 (C) Darxus@ChaosReigns.com, released under the GPL
# Download from http://www.chaosreigns.com/code/cinclude2dot/
#
# Graphs #include relationships between every .c, .cc, and .h file under
# the current directory using graphviz 
# (http://www.research.att.com/sw/tools/graphviz/) like so:
#
# ./cinclude2dot > source.dot
# neato -Tps source.dot > source.pl
# gv source.pl
# 
# v0.1 2000-09-14 10:24 initial version
# v0.2 2000-09-14 10:49 strip leading ./ off files

#include <Disks.h>
#include "macutils.h"

open (FILES,"find . -iname '*.c' -print;find . -iname '*.cc' -print;find . -iname '*.h'|");
#open (FILES,"find . -iname '*.c' -print|");

print "digraph \"source tree\" {\n";

while ($file = <FILES>)
{
  chomp $file;
  #strip "./" off off $file
  $file =~ s#^./##g;
  #print "$file\n";
  open (INPUT,"<$file");
  while ($line = <INPUT>)
  {
    if ($line =~ m#^\#include\s(\S+)#)
    {
      $included = $1;
      # strip quotes & anglebrackets
      $included =~ s/[\<\>"]//g;
      print "\"$file\" -> \"$included\" [len=5]\n";
    }
  }

  close INPUT;
}

print "}\n";

