aix: TLS DWARF symbol decorations.
[official-gcc.git] / libiberty / gather-docs
blob400eb540f74c31b9605e633b8a81924689a6fa60
1 #!/usr/bin/perl
2 # -*- perl -*-
4 # Copyright (C) 2001-2021 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>
26 # This program looks for texinfo snippets in source files and other
27 # files, and builds per-category files with entries sorted in
28 # alphabetical order.
30 # The syntax it looks for is lines starting with '@def' in *.c and
31 # other files (see TEXIFILES in Makefile.in). Entries are terminated
32 # at the next @def* (which begins a new entry) or, for C files, a line
33 # that begins with '*/' without leading spaces (this assumes that the
34 # texinfo snippet is within a C-style /* */ comment).
40 if ($ARGV[0] eq "-v") {
41 $verbose = 1;
42 shift;
45 $srcdir = shift;
46 $outfile = shift;
48 if ($outfile !~ /\S/ || ! -f "$srcdir/Makefile.in" ) {
49 print STDERR "Usage: gather-docs [-v] srcdir outfile.txi [files with snippets in them ...]\n";
50 exit 1;
53 $errors = 0;
55 for $in (@ARGV) {
57 if (!open(IN, "$srcdir/$in")) {
58 print STDERR "Cannot open $srcdir/$in for reading: $!\n";
59 $errors ++;
61 } else {
62 $first = 1;
63 $pertinent = 0;
64 $man_mode = 0;
65 $line = 0;
67 while (<IN>) {
68 $line ++;
69 $pertinent = 1 if /^\@def[a-z]*[a-wyz] /;
70 $pertinent = 0 if /^\*\//;
71 next unless $pertinent;
73 if (/^\@def[a-z]*[a-wyz] /) {
75 ($name) = m/[^\(]* ([^\( \t\r\n\@]+) *(\(|\@?$)/;
76 $name =~ s/[ ]*\@?$//;
77 $key = $name;
78 $key =~ tr/A-Z/a-z/;
79 $key =~ s/[^a-z0-9]+/ /g;
80 $name{$key} = $node;
81 $lines{$key} = '';
82 $src_file{$key} = $in;
83 $src_line{$key} = $line;
84 print "\nReading $in :" if $verbose && $first;
85 $first = 0;
86 print " $name" if $verbose;
87 $node_lines{$key} .= $_;
89 } else {
90 $node_lines{$key} .= $_;
93 $pertinent = 0 if /^\@end def/;
95 close (IN);
99 print "\n" if $verbose;
100 exit $errors if $errors;
102 if (!open (OUT, "> $outfile")) {
103 print STDERR "Cannot open $outfile for writing: $!\n";
104 $errors ++;
105 next;
107 print "Writing $outfile\n" if $verbose;
109 print OUT "\@c Automatically generated from *.c and others (the comments before\n";
110 print OUT "\@c each entry tell you which file and where in that file). DO NOT EDIT!\n";
111 print OUT "\@c Edit the *.c files, configure with --enable-maintainer-mode,\n";
112 print OUT "\@c run 'make stamp-functions' and gather-docs will build a new copy.\n\n";
114 for $key (sort keys %name) {
115 print OUT "\@c $src_file{$key}:$src_line{$key}\n";
116 print OUT $node_lines{$key};
117 print OUT "\n";
120 if (! print OUT "\n") {
121 print STDERR "Disk full writing $srcdir/$cat.texi\n";
122 $errors ++;
125 close (OUT);
127 exit $errors;