4 # Copyright (C) 2001, 2007, 2010
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., 51 Franklin Street - Fifth Floor,
21 # Boston, MA 02110-1301, 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.
37 &missing() if $mode eq "missing";
38 &undoc() if $mode eq "undoc";
39 &deps() if $mode eq "deps";
44 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~
46 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
50 ######################################################################
55 while ($f = readdir S) {
60 while ($f = readdir S) {
70 for $f (sort keys %have) {
71 next unless $have{$f};
76 for $f (sort keys %listed) {
77 if ($f =~ /(.*)\.c$/) {
79 if (! $listed{"./$base.o"}) {
86 ######################################################################
91 while ($file = readdir S) {
92 if ($file =~ /\.texi$/) {
93 open(T, "$srcdir/$file");
95 if (/^\@deftype[^\(]* ([^\s\(]+) *\(/) {
101 if ($file =~ /\.c$/) {
102 open(C, "$srcdir/$file");
104 if (/\@undocumented (\S+)/) {
112 while ($_ =~ /\([^\)]*$/) {
117 s/ VPARAMS([ \(])/$1/;
118 s/PREFIX\(([^\)]*)\)/byte_$1/;
119 if (/^static [^\(]* ([^\s\(]+) *\(.*\)$/) {
127 # $out = join(' ', sort keys %documented);
131 system "etags $srcdir/*.c $srcdir/../include/*.h";
137 $filename =~ s/[\r\n]+$//;
138 $filename =~ s/,\d+$//;
139 $filename =~ s@.*[/\\]@@;
142 if ($filename =~ /\.c$/ ) {
143 next unless /^[_a-zA-Z]/;
145 next unless /^\# *define/;
158 next if $documented{$_};
161 if ($seen_in{$_} ne $filename) {
164 $seen_in{$_} = $filename;
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}";
182 ######################################################################
190 if (/^#\s*include\s+["<](.*)[">]/) {
200 0 while $p =~ s@/\./@/@g;
201 0 while $p =~ s@^\./@@g;
202 0 while $p =~ s@/[^/]+/\.\./@/@g;
208 return -1 if $a eq "config.h";
209 return 1 if $b eq "config.h";
215 $crule = "\tif [ x\"\$(PICFLAG)\" != x ]; then \\\n";
216 $crule .= "\t \$(COMPILE.c) \$(PICFLAG) \$< -o pic/\$@; \\\n";
217 $crule .= "\telse true; fi\n";
218 $crule .= "\t\$(COMPILE.c) \$< \$(OUTPUT_OPTION)\n";
221 $incdir = shift @ARGV;
223 opendir(INC, $incdir);
224 while ($f = readdir INC) {
225 next unless $f =~ /\.h$/ || $f =~ /\.def$/;
226 $mine{$f} = "\$(INCDIR)/$f";
227 $deps{$f} = join(' ', &deps_for("$incdir/$f"));
229 $mine{'config.h'} = "config.h";
231 opendir(INC, $srcdir);
232 while ($f = readdir INC) {
233 next unless $f =~ /\.h$/;
234 $mine{$f} = "\$(srcdir)/$f";
235 $deps{$f} = join(' ', &deps_for("$srcdir/$f"));
237 $mine{'config.h'} = "config.h";
239 open(IN, "$srcdir/Makefile.in");
240 open(OUT, ">$srcdir/Makefile.tmp");
242 last if /remainder of this file/;
245 print OUT "# The dependencies in the remainder of this file are automatically\n";
246 print OUT "# generated by \"make maint-deps\". Manual edits will be lost.\n\n";
249 for $f (sort readdir S) {
253 @pending = &deps_for("$srcdir/$f");
258 next unless $mine{$p};
260 push(@pending, split(' ', $deps{$p}));
265 @deps = sort { &locals_first($a,$b) } keys %scanned;
267 $obj =~ s/\.c$/.\$(objext)/;
270 print OUT "$obj \$(srcdir)/$f";
271 $len = length("$obj $f");
274 if ($len + length($d) > 70) {
275 printf OUT " \\\n\t$d";
276 $len = 8 + length($d);
279 $len += length($d) + 1;
284 print OUT "$obj \$(srcdir)/$f\n";
287 $c =~ s@\$\<@\$\(srcdir\)\/$f@g;
295 rename("$srcdir/Makefile.tmp", "$srcdir/Makefile.in");