* configure.in (arm-*-netbsdelf*): Add target.
[binutils.git] / libiberty / maint-tool
blob75b0c508cd910051a305f5a120a22526ef473b8c
1 #!/usr/bin/perl
2 # -*- perl -*-
4 # Copyright (C) 2001
5 # Free Software Foundation
7 # This file is part of the libiberty library.
8 # Libiberty is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Library General Public
10 # License as published by the Free Software Foundation; either
11 # version 2 of the License, or (at your option) any later version.
13 # Libiberty is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Library General Public License for more details.
18 # You should have received a copy of the GNU Library General Public
19 # License along with libiberty; see the file COPYING.LIB. If not,
20 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 # Boston, MA 02111-1307, USA.
23 # Originally written by DJ Delorie <dj@redhat.com>
26 # This is a trivial script which checks the lists of C and O files in
27 # the Makefile for consistency.
29 $mode = shift;
30 $srcdir = ".";
32 if ($mode eq "-s") {
33 $srcdir = shift;
34 $mode = shift;
37 &missing() if $mode eq "missing";
38 &undoc() if $mode eq "undoc";
40 exit 0;
42 format STDOUT =
43 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~
44 $out
45 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
46 $out
49 ######################################################################
51 sub missing {
53 opendir(S, $srcdir);
54 while ($f = readdir S) {
55 $have{$f} = 1;
57 closedir(S);
58 opendir(S, ".");
59 while ($f = readdir S) {
60 $have{$f} = 1;
62 closedir(S);
64 for $a (@ARGV) {
65 $listed{$a} = 1;
66 $have{$a} = 0;
69 for $f (sort keys %have) {
70 next unless $have{$f};
71 if ($f =~ /\.c$/) {
72 print "S $f\n";
75 for $f (sort keys %listed) {
76 if ($f =~ /(.*)\.c$/) {
77 $base = $1;
78 if (! $listed{"$base.o"}) {
79 print "O $f\n";
85 ######################################################################
87 sub undoc {
89 opendir(S, $srcdir);
90 while ($file = readdir S) {
91 if ($file =~ /\.texi$/) {
92 open(T, "$srcdir/$file");
93 while (<T>) {
94 if (/^\@deftype[^\(]* ([^\s\(]+) *\(/) {
95 $documented{$1} = 1;
98 close(T);
100 if ($file =~ /\.c$/) {
101 open(C, "$srcdir/$file");
102 while (<C>) {
103 if (/\@undocumented (\S+)/) {
104 $documented{$1} = 1;
106 if (/^static /) {
107 if (! /[\(;]/) {
108 s/[\r\n]+$/ /;
109 $_ .= <C>;
111 while ($_ =~ /\([^\)]*$/) {
112 s/[\r\n]+$/ /;
113 $_ .= <C>;
116 s/ VPARAMS([ \(])/$1/;
117 s/PREFIX\(([^\)]*)\)/byte_$1/;
118 if (/^static [^\(]* ([^\s\(]+) *\(.*\)$/) {
119 $documented{$1} = 1;
124 closedir(D);
126 # $out = join(' ', sort keys %documented);
127 # write;
128 # print "\n";
130 system "etags $srcdir/*.c $srcdir/../include/*.h";
131 open(TAGS, "TAGS");
132 while (<TAGS>) {
133 s/[\r\n]+$//;
134 if (/^\014$/) {
135 $filename = <TAGS>;
136 $filename =~ s/[\r\n]+$//;
137 $filename =~ s/,\d+$//;
138 $filename =~ s@.*[/\\]@@;
139 next;
141 if ($filename =~ /\.c$/ ) {
142 next unless /^[_a-zA-Z]/;
143 } else {
144 next unless /^\# *define/;
145 s/\# *define *//;
147 next if $filename =~ /mpw\.c/;
149 s/ VPARAMS//;
150 s/ *\177.*//;
151 s/,$//;
152 s/DEFUN\(//;
153 s/\(//;
155 next if /^static /;
156 next if /\s/;
157 next if /^_/;
158 next if $documented{$_};
159 next if /_H_?$/;
161 if ($seen_in{$_} ne $filename) {
162 $saw{$_} ++;
164 $seen_in{$_} = $filename;
167 for $k (keys %saw) {
168 delete $saw{$k} if $saw{$k} > 1;
171 for $k (sort keys %saw) {
172 $fromfile{$seen_in{$k}} .= " " if $fromfile{$seen_in{$k}};
173 $fromfile{$seen_in{$k}} .= $k;
176 for $f (sort keys %fromfile) {
177 $out = "$f: $fromfile{$f}";
178 write;