Fix syscall tracing.
[linux-2.6/linux-mips.git] / scripts / checkconfig.pl
blobfc352e43637275e4d0fa0abc62b49d9ccf5b76d3
1 #! /usr/bin/perl
3 # checkconfig: find uses of CONFIG_* names without matching definitions.
4 # Copyright abandoned, 1998, Michael Elizabeth Chastain <mailto:mec@shout.net>.
6 use integer;
8 $| = 1;
10 foreach $file (@ARGV)
12 # Open this file.
13 open(FILE, $file) || die "Can't open $file: $!\n";
15 # Initialize variables.
16 my $fInComment = 0;
17 my $fUseConfig = 0;
18 my $iLinuxConfig = 0;
19 my %configList = ();
21 LINE: while ( <FILE> )
23 # Strip comments.
24 $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
25 m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
27 # Pick up definitions.
28 if ( m/^\s*#/o )
30 $iLinuxConfig = $. if m/^\s*#\s*include\s*<linux\/config\.h>/o;
31 $configList{uc $1} = 1 if m/^\s*#\s*include\s*<config\/(\S*)\.h>/o;
32 $configList{$1} = 1 if m/^\s*#\s*define\s+CONFIG_(\w*)/o;
33 $configList{$1} = 1 if m/^\s*#\s*undef\s+CONFIG_(\w*)/o;
36 # Look for usages.
37 next unless m/CONFIG_/o;
38 WORD: while ( m/\bCONFIG_(\w+)/og )
40 $fUseConfig = 1;
41 last LINE if $iLinuxConfig;
42 next WORD if exists $configList{$1};
43 print "$file: $.: need CONFIG_$1.\n";
44 $configList{$1} = 0;
48 # Report superfluous includes.
49 if ( $iLinuxConfig && ! $fUseConfig )
50 { print "$file: $iLinuxConfig: <linux/config.h> not needed.\n"; }
52 close(FILE);