Line | |
---|
1 | #!/usr/bin/perl
|
---|
2 | # Script that reads in Makefile.in and outputs the names of all
|
---|
3 | # used but undefined vars and all defined but unused vars
|
---|
4 | # Copyright Jelmer Vernooij <jelmer@samba.org>
|
---|
5 |
|
---|
6 | # Arguments:
|
---|
7 | # 1: Makefile.in
|
---|
8 | #
|
---|
9 |
|
---|
10 | my %references;
|
---|
11 | my %defines;
|
---|
12 |
|
---|
13 | # First, make a list of defines in configure
|
---|
14 | $in = shift;
|
---|
15 |
|
---|
16 | sub process_file($)
|
---|
17 | {
|
---|
18 | my ($fn) = @_;
|
---|
19 | open(IN, $fn);
|
---|
20 | while(<IN>) {
|
---|
21 | my $line = $_;
|
---|
22 | while($line =~ /^\b([a-zA-Z0-9_][a-zA-Z0-9_]*)\b[ \t]*=.*/sgm) {
|
---|
23 | $defines{$1} = 1;
|
---|
24 | }
|
---|
25 | while($line =~ /\$\(([a-zA-Z0-9_][a-zA-Z0-9_]*)\)/sgm) {
|
---|
26 | $references{$1} = 1;
|
---|
27 | }
|
---|
28 | while ($line =~ /^include (.*)/sgm) {
|
---|
29 | process_file($1);
|
---|
30 | }
|
---|
31 | }
|
---|
32 | close IN;
|
---|
33 | }
|
---|
34 |
|
---|
35 | process_file($in);
|
---|
36 |
|
---|
37 | print "##### DEFINED BUT UNUSED: #####\n";
|
---|
38 | foreach(%defines) {
|
---|
39 | # print $_." defined\n";
|
---|
40 |
|
---|
41 | if ($_ != 1) {
|
---|
42 | if ($references{$_} != 1) {
|
---|
43 | print $_."\n";
|
---|
44 | }
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | print "##### USED BUT UNDEFINED: #####\n";
|
---|
49 | foreach(%references) {
|
---|
50 | if ($_ != 1) {
|
---|
51 | if ($defines{$_} != 1) {
|
---|
52 | print $_."\n";
|
---|
53 | }
|
---|
54 | }
|
---|
55 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.