ACPI: thinkpad-acpi: add development version tag
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / scripts / headers_check.pl
blob15d53a6b1a1f99901b9bdf07e052331ce2a86a2e
1 #!/usr/bin/perl
3 # headers_check.pl execute a number of trivial consistency checks
5 # Usage: headers_check.pl dir [files...]
6 # dir: dir to look for included files
7 # arch: architecture
8 # files: list of files to check
10 # The script reads the supplied files line by line and:
12 # 1) for each include statement it checks if the
13 # included file actually exists.
14 # Only include files located in asm* and linux* are checked.
15 # The rest are assumed to be system include files.
17 # 2) TODO: check for leaked CONFIG_ symbols
19 use strict;
20 use warnings;
22 my ($dir, $arch, @files) = @ARGV;
24 my $ret = 0;
25 my $line;
26 my $lineno = 0;
27 my $filename;
29 foreach my $file (@files) {
30 $filename = $file;
31 open(my $fh, '<', "$filename") or die "$filename: $!\n";
32 $lineno = 0;
33 while ($line = <$fh>) {
34 $lineno++;
35 check_include();
37 close $fh;
39 exit $ret;
41 sub check_include
43 if ($line =~ m/^\s*#\s*include\s+<((asm|linux).*)>/) {
44 my $inc = $1;
45 my $found;
46 $found = stat($dir . "/" . $inc);
47 if (!$found) {
48 $inc =~ s#asm/#asm-$arch/#;
49 $found = stat($dir . "/" . $inc);
51 if (!$found) {
52 printf STDERR "$filename:$lineno: included file '$inc' is not exported\n";
53 $ret = 1;