s4-nbt: use private_data instead of private.
[Samba/gbeck.git] / source4 / script / find_unused_makefilevars.pl
blob23fc36ef6a5a0c43801253b14e4213361b22d861
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>
6 # Arguments:
7 # 1: Makefile.in
10 my %references;
11 my %defines;
13 # First, make a list of defines in configure
14 $in = shift;
16 sub process_file($)
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;
25 while($line =~ /\$\(([a-zA-Z0-9_][a-zA-Z0-9_]*)\)/sgm) {
26 $references{$1} = 1;
28 while ($line =~ /^include (.*)/sgm) {
29 process_file($1);
32 close IN;
35 process_file($in);
37 print "##### DEFINED BUT UNUSED: #####\n";
38 foreach(%defines) {
39 # print $_." defined\n";
41 if ($_ != 1) {
42 if ($references{$_} != 1) {
43 print $_."\n";
48 print "##### USED BUT UNDEFINED: #####\n";
49 foreach(%references) {
50 if ($_ != 1) {
51 if ($defines{$_} != 1) {
52 print $_."\n";