4 # Copyright (C) 2001-2023 Free Software Foundation, Inc.
6 # This file is part of the libiberty library.
7 # Libiberty is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Library General Public
9 # License as published by the Free Software Foundation; either
10 # version 2 of the License, or (at your option) any later version.
12 # Libiberty is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Library General Public License for more details.
17 # You should have received a copy of the GNU Library General Public
18 # License along with libiberty; see the file COPYING.LIB. If not,
19 # write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20 # Boston, MA 02110-1301, USA.
22 # Originally written by DJ Delorie <dj@redhat.com>
25 # This is a trivial script which checks the lists of C and O files in
26 # the Makefile for consistency.
36 &missing
() if $mode eq "missing";
37 &undoc
() if $mode eq "undoc";
38 &deps
() if $mode eq "deps";
43 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~
45 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
49 ######################################################################
54 while ($f = readdir S
) {
59 while ($f = readdir S
) {
69 for $f (sort keys %have) {
70 next unless $have{$f};
75 for $f (sort keys %listed) {
76 if ($f =~ /(.*)\.c$/) {
78 if (! $listed{"./$base.o"}) {
85 ######################################################################
90 while ($file = readdir S
) {
91 if ($file =~ /\.texi$/) {
92 open(T
, "$srcdir/$file");
94 if (/^\@deftype[^\(]* ([^\s\(]+) *\(/) {
100 if ($file =~ /\.c$/) {
101 open(C
, "$srcdir/$file");
103 if (/\@undocumented (\S+)/) {
111 while ($_ =~ /\([^\)]*$/) {
116 s/ VPARAMS([ \(])/$1/;
117 s/PREFIX\(([^\)]*)\)/byte_$1/;
118 if (/^static [^\(]* ([^\s\(]+) *\(.*\)$/) {
126 # $out = join(' ', sort keys %documented);
130 system "etags $srcdir/*.c $srcdir/../include/*.h";
136 $filename =~ s/[\r\n]+$//;
137 $filename =~ s/,\d+$//;
138 $filename =~ s@
.*[/\\]@@
;
141 if ($filename =~ /\.c$/ ) {
142 next unless /^[_a-zA-Z]/;
144 next unless /^\# *define/;
157 next if $documented{$_};
160 if ($seen_in{$_} ne $filename) {
163 $seen_in{$_} = $filename;
167 delete $saw{$k} if $saw{$k} > 1;
170 for $k (sort keys %saw) {
171 $fromfile{$seen_in{$k}} .= " " if $fromfile{$seen_in{$k}};
172 $fromfile{$seen_in{$k}} .= $k;
175 for $f (sort keys %fromfile) {
176 $out = "$f: $fromfile{$f}";
181 ######################################################################
189 if (/^#\s*include\s+["<](.*)[">]/) {
199 0 while $p =~ s@
/\./@
/@g;
200 0 while $p =~ s@
^\
./@
@g;
201 0 while $p =~ s@
/[^/]+/\.\./@
/@g;
207 return -1 if $a eq "config.h";
208 return 1 if $b eq "config.h";
214 $crule = "\tif [ x\"\$(PICFLAG)\" != x ]; then \\\n";
215 $crule .= "\t \$(COMPILE.c) \$(PICFLAG) \$< -o pic/\$@; \\\n";
216 $crule .= "\telse true; fi\n";
217 $crule .= "\tif [ x\"\$(NOASANFLAG)\" != x ]; then \\\n";
218 $crule .= "\t \$(COMPILE.c) \$(PICFLAG) \$(NOASANFLAG) \$< -o noasan/\$@; \\\n";
219 $crule .= "\telse true; fi\n";
220 $crule .= "\t\$(COMPILE.c) \$< \$(OUTPUT_OPTION)\n";
223 $incdir = shift @ARGV;
225 opendir(INC
, $incdir);
226 while ($f = readdir INC
) {
227 next unless $f =~ /\.h$/ || $f =~ /\.def$/;
228 $mine{$f} = "\$(INCDIR)/$f";
229 $deps{$f} = join(' ', &deps_for
("$incdir/$f"));
231 $mine{'config.h'} = "config.h";
233 opendir(INC
, $srcdir);
234 while ($f = readdir INC
) {
235 next unless $f =~ /\.h$/;
236 $mine{$f} = "\$(srcdir)/$f";
237 $deps{$f} = join(' ', &deps_for
("$srcdir/$f"));
239 $mine{'config.h'} = "config.h";
241 open(IN
, "$srcdir/Makefile.in");
242 open(OUT
, ">$srcdir/Makefile.tmp");
244 last if /remainder of this file/;
247 print OUT
"# The dependencies in the remainder of this file are automatically\n";
248 print OUT
"# generated by \"make maint-deps\". Manual edits will be lost.\n\n";
251 for $f (sort readdir S
) {
255 @pending = &deps_for
("$srcdir/$f");
260 next unless $mine{$p};
262 push(@pending, split(' ', $deps{$p}));
267 @deps = sort { &locals_first
($a,$b) } keys %scanned;
269 $obj =~ s/\.c$/.\$(objext)/;
272 print OUT
"$obj \$(srcdir)/$f";
273 $len = length("$obj $f");
276 if ($len + length($d) > 70) {
277 printf OUT
" \\\n\t$d";
278 $len = 8 + length($d);
281 $len += length($d) + 1;
286 print OUT
"$obj \$(srcdir)/$f\n";
289 $c =~ s@\
$\
<@\
$\
(srcdir\
)\
/$f@g;
297 rename("$srcdir/Makefile.tmp", "$srcdir/Makefile.in");