• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/samba-3.5.8/source4/script/
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
10my %references;
11my %defines;
12
13# First, make a list of defines in configure
14$in = shift;
15
16sub 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
35process_file($in);
36
37print "##### DEFINED BUT UNUSED: #####\n";
38foreach(%defines) {
39#    print $_." defined\n";
40
41	if ($_ != 1) {
42		if ($references{$_} != 1) {
43			print $_."\n";
44		}
45	}
46}
47
48print "##### USED BUT UNDEFINED: #####\n";
49foreach(%references) {
50	if ($_ != 1) {
51		if ($defines{$_} != 1) {
52			print $_."\n";
53		}
54	}
55}
56