This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
missing dependency on i_inttypes
[metaconfig.git] / U / mkglossary
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Cwd "abs_path";
7 use File::Basename;
8 use FindBin;
9
10 my $p5_metaconfig_base = abs_path "$FindBin::Bin/../";
11
12 chdir "$p5_metaconfig_base/perl" or
13     die "Cannot use $p5_metaconfig_base/perl to find config.sh\n";
14 my @config = sort { -M $a <=> -M $b }
15              grep { -s }
16              qw( config.sh uconfig.sh Porting/config.sh );
17 @config or die "Build (and test) perl before generating the Glossary\n";
18 # Get the list of config.sh symbols.  Be sure this is up to date!
19 # (I run the Porting/mksample script first to be sure.)
20 $config[0] eq "config.sh" or warn "Using $config[0] instead of config.sh - Did you build?\n";
21 my $wanted = abs_path $config[0];
22
23 chdir "$p5_metaconfig_base/U" or
24     die "Cannot use $p5_metaconfig_base/U to find the units\n";
25 my @perl_units = map { abs_path $_ } (sort glob "*/*.U"), sort glob "../dist/U/*.U";
26
27 open my $wfh, "<", $wanted or die "$0: open $wanted: $!\n";
28 my @WANTED = map  { $_->[0] }
29              sort { $a->[1] cmp $b->[1] }
30              map  { [ $_, lc $_ ] }
31              <$wfh>;
32 close $wfh;
33
34 print <<'EOM';
35
36 !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
37 This file is built by metaconfig.
38
39 This file contains a description of all the shell variables whose value is
40 determined by the Configure script.  Variables intended for use in C
41 programs (e.g. I_UNISTD) are already described in config_h.SH.  [`configpm'
42 generates pod documentation for Config.pm from this file--please try to keep
43 the formatting regular.]
44
45 EOM
46
47 my ($Loc, %expl, %file, %predef);
48 foreach my $file (@perl_units) {
49     open my $fh, "<", $file or die "$0: open $file: $!";
50     my $base = basename ($file);
51     $Loc = $file, next if $base eq "Loc.U" and not defined $Loc;
52     my @var;
53     while (<$fh>) {
54         if (m/^\?S:\w+[ \t:]/ .. m/^\?S:\.$/) {
55             s/[ \t]+$//;
56             if (m/^\?S:.$/) {
57                 my ($var) = ((shift @var) =~ /^(\w+)/);
58                 unless (exists $expl{$var}) {
59                     $expl{$var} = [ @var, "\n" ];
60                     $file{$var} = $base;
61                     }
62                 @var = ();
63                 }
64             else {
65                 s/^\?S://;              # Remove leading ?S: markers.
66                 s/^\s+(?=.)/\t/;        # Ensure all lines begin with tabs.
67                 push @var, $_;
68                 }
69             }
70         }
71     close $fh or die "$0: close $file: $!";
72     }
73
74 defined $Loc or die "$0: Couldn't locate Loc.U: $!";
75
76 open my $fh, "<", $Loc or die "$0: open $Loc: $!";
77 while (<$fh>) {
78     m/^\?(\w+):\1$/ and ($expl{$1}, $file{$1}) = (1, "Loc.U");
79     }
80 close $fh or die "$0: close $Loc: $!";
81
82 {   local $/ = "\n\n";
83     for (<DATA>) {
84         m/^(\w+)/;
85         $predef{$1} = $_;
86         }
87     }
88
89 for (@WANTED) {
90     chomp;
91     m/^#/ and next;     # Skip comments
92     m/^:/ and next;     # Skip comments
93     m/^$/ and next;     # Skip empty sections
94     my ($var, $val) = split /=/, $_, 2;
95
96     if (exists $expl{$var}) {
97         if ($file{$var} eq "Loc.U") {
98             print "$var (Loc.U):\n";
99             if ($val eq "''") {
100                 # If we didn't have d_portable, this info might be
101                 # useful, but it still won't help with non-standard
102                 # stuff if perl is built on one system but installed
103                 # on others (this is common with Linux distributions,
104                 # for example).
105                 print <<EOE;
106         This variable is defined but not used by Configure.
107         The value is the empty string and is not useful.
108
109 EOE
110                 }
111             else {
112                 print <<EOE;
113         This variable is used internally by Configure to determine the
114         full pathname (if any) of the $var program.  After Configure runs,
115         the value is reset to a plain "$var" and is not useful.
116
117 EOE
118                 }
119             }
120         else {
121             print "$var ($file{$var}):\n";
122             print @{$expl{$var}};
123             }
124         next;
125         }
126
127     # Handle special variables from Oldsyms.U.  Since these start
128     # with capital letters, metalint considers them to be "special
129     # unit" symbols.  It's easier to define them here than to try
130     # to fool metalint any further.   --AD  22 Oct 1999
131     # Similarly, handle the config_arg* variables from Options.U.
132     # -- AD 8 Dec 2009
133     if (exists $predef{$var}) {
134         print  $predef{$var};
135         next;
136         }
137
138     $var =~ /^(Author|Date|Header|Id|Locker|Log|Mcc|RCSfile|Revision|Source|State)$|_cflags$|^config_arg/
139         or warn "$0: couldn't find $var\n"
140     }
141 __END__
142 PERL_REVISION (Oldsyms.U):
143         In a Perl version number such as 5.6.2, this is the 5.
144         This value is manually set in patchlevel.h
145
146 PERL_VERSION (Oldsyms.U):
147         In a Perl version number such as 5.6.2, this is the 6.
148         This value is manually set in patchlevel.h
149
150 PERL_SUBVERSION (Oldsyms.U):
151         In a Perl version number such as 5.6.2, this is the 2.
152         Values greater than 50 represent potentially unstable
153         development subversions.
154         This value is manually set in patchlevel.h
155
156 PERL_APIVERSION (Oldsyms.U):
157         This value is manually set in patchlevel.h and is used
158         to set the Configure apiversion variable.
159
160 CONFIGDOTSH (Oldsyms.U):
161         This is set to 'true' in config.sh so that a shell script
162         sourcing config.sh can tell if it has been sourced already.
163
164 PERL_CONFIG_SH (Oldsyms.U):
165         This is set to 'true' in config.sh so that a shell script
166         sourcing config.sh can tell if it has been sourced already.
167
168 PERL_API_REVISION (patchlevel.h):
169         This number describes the earliest compatible PERL_REVISION of
170         Perl ("compatibility" here being defined as sufficient binary/API
171         compatibility to run XS code built with the older version).
172         Normally this does not change across maintenance releases.
173         Please read the comment in patchlevel.h.
174
175 PERL_API_VERSION (patchlevel.h):
176         This number describes the earliest compatible PERL_VERSION of
177         Perl ("compatibility" here being defined as sufficient binary/API
178         compatibility to run XS code built with the older version).
179         Normally this does not change across maintenance releases.
180         Please read the comment in patchlevel.h.
181
182 PERL_API_SUBVERSION (patchlevel.h):
183         This number describes the earliest compatible PERL_SUBVERSION of
184         Perl ("compatibility" here being defined as sufficient binary/API
185         compatibility to run XS code built with the older version).
186         Normally this does not change across maintenance releases.
187         Please read the comment in patchlevel.h.
188
189 PERL_PATCHLEVEL (Oldsyms.U):
190         This symbol reflects the patchlevel, if available. Will usually
191         come from the .patch file, which is available when the perl
192         source tree was fetched with rsync.
193
194 config_args (Options.U):
195         This variable contains a single string giving the command-line
196         arguments passed to Configure.  Spaces within arguments,
197         quotes, and escaped characters are not correctly preserved.
198         To reconstruct the command line, you must assemble the individual
199         command line pieces, given in config_arg[0-9]*.
200
201 config_arg0 (Options.U):
202         This variable contains the string used to invoke the Configure
203         command, as reported by the shell in the $0 variable.
204
205 config_argc (Options.U):
206         This variable contains the number of command-line arguments
207         passed to Configure, as reported by the shell in the $# variable.
208         The individual arguments are stored as variables config_arg1,
209         config_arg2, etc.
210