2006-12-18 Paolo Borelli <pborelli@katamail.com>
[nautilus.git] / check-headers-in-Makefile.pl
blob3c92fcdd7fc9ad481f5a785adfca1e03bfbbf530
1 #!/usr/bin/perl -w
2 # -*- Mode: perl; indent-tabs-mode: nil -*-
5 # Nautilus
7 # Copyright (C) 2000 Eazel, Inc.
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of the
12 # License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this library; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # Author: Darin Adler <darin@bentspoon.com>,
26 # check-headers-in-Makefile.pl: Checks the contents of the source
27 # directories against the contents of the Makefile.am files.
29 use diagnostics;
30 use strict;
32 my @directories = (".");
34 my %exceptions =
36 '$(APPLETS_SUBDIRS)' => 'applets',
37 '$(AUTHENTICATE_HELPER_SUBDIRS)' => 'authenticate',
38 '$(INSTALL_SERVICE)' => 'install',
39 '$(MOZILLA_COMPONENT_SUBDIRS)' => 'mozilla',
40 '$(NULL)' => '',
41 '$(RPMVIEW_COMPONENT_SUBDIRS)' => 'rpmview',
42 '$(SERVICE_SUBDIRS)' => 'services',
43 'intl' => '',
44 'po' => '',
47 while (@directories)
49 my $directory = pop @directories;
50 my $prefix = "";
51 $prefix = "$directory/" if $directory ne ".";
53 my $in_subdirs = 0;
55 my $file = $prefix . "Makefile.am";
56 open FILE, $file or die "can't open $file";
57 my %headers;
58 while (<FILE>)
60 if (s/^SUBDIRS\s*=//)
62 $in_subdirs = 1;
64 if ($in_subdirs)
66 while (s/^\s*([^\s\\]+)//)
68 if (defined $exceptions{$1})
70 if ($exceptions{$1})
72 push @directories, $prefix . $exceptions{$1};
75 else
77 push @directories, $prefix . $1;
80 if (/^\s*$/)
82 $in_subdirs = 0;
84 elsif (!/^\s*\\$/)
86 die "can't parse SUBDIRS in $directory\n";
89 while (s/([-_a-zA-Z0-9]+\.[ch])\W//)
91 $headers{$1} = $1;
94 close FILE;
96 if ($directory eq ".")
98 $headers{"acconfig.h"} = "acconfig.h";
99 $headers{"config.h"} = "config.h";
102 opendir DIRECTORY, $directory or die "can't open $directory";
103 foreach my $header (grep /.*\.[ch]$/, readdir DIRECTORY)
105 if (defined $headers{$header})
107 delete $headers{$header};
109 else
111 print "$directory/$header in directory but not Makefile.am\n";
114 closedir DIRECTORY;
116 foreach my $header (keys %headers)
118 print "$directory/$header in Makefile.am but not directory\n";