3 # Walk through source, add labels and make classes
9 #open class file and write preamble
10 open(CLASS
, ">tommath_class.h") or die "Couldn't open tommath_class.h for writing\n";
11 print CLASS
"#if !(defined(LTM1) && defined(LTM2) && defined(LTM3))\n#if defined(LTM2)\n#define LTM3\n#endif\n#if defined(LTM1)\n#define LTM2\n#endif\n#define LTM1\n\n#if defined(LTM_ALL)\n";
13 foreach my $filename (glob "bn*.c") {
14 my $define = $filename;
16 print "Processing $filename\n";
18 # convert filename to upper case so we can use it as a define
19 $define =~ tr/[a-z]/[A-Z]/;
21 print CLASS
"#define $define\n";
23 # now copy text and apply #ifdef as required
25 open(SRC
, "<$filename");
28 # first line will be the #ifdef
30 if ($line =~ /include/) {
33 print OUT
"#include <tommath.h>\n#ifdef $define\n$line";
37 if (!($_ =~ /tommath\.h/)) {
48 rename("tmp", $filename);
50 print CLASS
"#endif\n\n";
54 foreach my $filename (glob "bn*.c") {
55 open(SRC
, "<$filename") or die "Can't open source file!\n";
57 # convert filename to upper case so we can use it as a define
58 $filename =~ tr/[a-z]/[A-Z]/;
59 $filename =~ tr/\./_/;
61 print CLASS
"#if defined($filename)\n";
64 # scan for mp_* and make classes
67 while ($line =~ m/(fast_)*(s_)*mp\_[a-z_0-9]*/) {
69 # now $& is the match, we want to skip over LTM keywords like
70 # mp_int, mp_word, mp_digit
71 if (!($& eq "mp_digit") && !($& eq "mp_word") && !($& eq "mp_int")) {
73 $a =~ tr/[a-z]/[A-Z]/;
74 $a = "BN_" . $a . "_C";
75 if (!($list =~ /$a/)) {
76 print CLASS " #define $a\n";
78 $list = $list . "," . $a;
82 @deplist{$filename} = $list;
84 print CLASS "#endif\n\n";
88 print CLASS "#ifdef LTM3\n#define LTM_LAST\n#endif\n#include <tommath_superclass.h>\n#include <tommath_class.h>\n#else\n#define LTM_LAST\n#endif\n";
91 #now let's make a cool call graph
...
93 open(OUT
,">callgraph.txt");
95 foreach (keys %deplist) {
97 draw_func
(@deplist{$_});
104 my @funcs = split(",", $_[0]);
105 if ($list =~ /@funcs[0]/) {
108 $list = $list . @funcs[0];
110 if ($indent == 0) { }
111 elsif ($indent >= 1) { print OUT
"| " x
($indent - 1) . "+--->"; }
112 print OUT
@funcs[0] . "\n";
115 foreach my $i (@funcs) {
117 draw_func
(@deplist{$i});