This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Updated documentation and README's. Added some locally used
[metaconfig.git] / U / mkglossary
CommitLineData
959f3c4c 1#!/usr/local/bin/perl -w
9f8747e5 2
959f3c4c
JH
3use File::Basename;
4
5# WARNING: This is site-specific. Change to the location
6# where you have installed dist-3.0PL70.
9f8747e5
MB
7@std_units = glob('/pro/3gl/CPAN/lib/dist/U/*.U');
8$PWD = '/pro/3gl/CPAN/perl';
bdf957e2
JH
9# @std_units = glob('/opt/dist/lib/U/*.U');
10# $PWD = '/export/home/doughera/src/perl/p4perl';
959f3c4c
JH
11
12chdir U if -d './U';
13@perl_units = glob("$PWD/U/*/*.U");
14push(@perl_units, @std_units);
15
16# Get the list of config.sh symbols. Be sure this is up to date!
17# (I run the U/mksample script first to be sure.)
9f8747e5
MB
18open (WANTED, "< $PWD/Porting/config.sh") || die "$0: open $PWD/Wanted: $!\n";
19my @WANTED = map { $_->[0] }
20 sort { $a->[1] cmp $b->[1] }
21 map { [ $_, lc $_ ] } <WANTED>;
959f3c4c
JH
22
23print <<'EOM';
cfaaf7e8
JH
24
25!!!!!!! DO NOT EDIT THIS FILE !!!!!!!
26This file is built by metaconfig.
27
959f3c4c
JH
28This file contains a description of all the shell variables whose value is
29determined by the Configure script. Variables intended for use in C
30programs (e.g. I_UNISTD) are already described in config_h.SH. [`configpm'
31generates pod documentation for Config.pm from this file--please try to keep
32the formatting regular.]
33
34EOM
35
36foreach $file (@perl_units) {
37 open(FH, "<$file") || die "$0: open $file: $!";
38 my $base = basename($file);
39 $Loc = $file, next if $base eq 'Loc.U' and not defined $Loc;
40 while (<FH>) {
41 if (/^\?S:\w+[ \t:]/ .. /^\?S:.$/) {
42 if (/^\?S:.$/) {
43 ($var) = ((shift @var) =~ /^(\w+)/);
44 unless (exists $expl{$var}) {
45 $expl{$var} = [ @var, "\n" ];
46 $file{$var} = $base;
47 }
48 @var = ();
49 } else {
50 s/^\?S://; # Remove leading ?S: markers.
23154ddf 51 s/^\s+(?=.)/\t/; # Ensure all lines begin with tabs.
959f3c4c
JH
52 push @var, $_;
53 }
54 }
55 }
56 close(FH) || die "$0: close $file: $!";
57}
58
59die "$0: Couldn't locate Loc.U: $!" unless defined $Loc;
60
61open(FH, "<$Loc") || die "$0: open $Loc: $!";
62while (<FH>) {
63 if (/^\?(\w+):\1$/) {
64 $var = $1;
65 $expl{$var} = 1;
66 $file{$var} = 'Loc.U';
67 }
68}
69close(FH) || die "$0: close $Loc: $!";
70
9f8747e5 71symbol: foreach my $var (@WANTED) {
959f3c4c
JH
72 chomp $var;
73 next symbol if $var =~ /^#/; # Skip comments
74 next symbol if $var =~ /^$/;
75 ($var, $val) = split(/=/, $var, 2);
76 $gotit = 0;
77
78 if (exists $expl{$var}) {
79 if ($file{$var} eq 'Loc.U') {
80 print "$var (Loc.U):\n";
81 if ($val eq "''") {
82 # If we didn't have d_portable, this info might be
83 # useful, but it still won't help with non-standard
84 # stuff if perl is built on one system but installed
85 # on others (this is common with Linux distributions,
86 # for example).
87 print <<EOE;
88 This variable is defined but not used by Configure.
89 The value is a plain '' and is not useful.
90
91EOE
92 } else {
93 print <<EOE;
17784b92 94 This variable is used internally by Configure to determine the
959f3c4c
JH
95 full pathname (if any) of the $var program. After Configure runs,
96 the value is reset to a plain "$var" and is not useful.
97
98EOE
99 }
100 } else {
101 print "$var ($file{$var}):\n";
102 print @{ $expl{$var} };
103 next symbol;
104 }
105 $gotit = 1;
106 }
bdf957e2
JH
107 # Handle special variables from Oldsyms.U. Since these start
108 # with capital letters, metalint considers them to be "special
109 # unit" symbols. It's easier to define them here than to try
110 # to fool metalint any further. --AD 22 Oct 1999
111 elsif ($var eq 'PERL_REVISION') {
112 $gotit = 1;
113 print <<'EOE';
114PERL_REVISION (Oldsyms.U):
115 In a Perl version number such as 5.6.2, this is the 5.
116 This value is manually set in patchlevel.h
117
118EOE
119 }
120 elsif ($var eq 'PERL_VERSION') {
121 $gotit = 1;
122 print <<'EOE';
123PERL_VERSION (Oldsyms.U):
124 In a Perl version number such as 5.6.2, this is the 6.
125 This value is manually set in patchlevel.h
126
127EOE
128 }
129 elsif ($var eq 'PERL_SUBVERSION') {
130 $gotit = 1;
131 print <<'EOE';
132PERL_SUBVERSION (Oldsyms.U):
133 In a Perl version number such as 5.6.2, this is the 2.
134 Values greater than 50 represent potentially unstable
135 development subversions.
136 This value is manually set in patchlevel.h
137
138EOE
139 }
140 elsif ($var eq 'PERL_APIVERSION') {
141 $gotit = 1;
142 print <<'EOE';
143PERL_APIVERSION (Oldsyms.U):
144 This value is manually set in patchlevel.h and is used
145 to set the Configure apiversion variable.
146
147EOE
148 }
149 elsif ($var eq 'CONFIGDOTSH') {
150 $gotit = 1;
151 print <<'EOE';
152CONFIGDOTSH (Oldsyms.U):
153 This is set to 'true' in config.sh so that a shell script
154 sourcing config.sh can tell if it has been sourced already.
155
156EOE
157 }
158
959f3c4c 159 warn "$0: couldn't find $var\n"
bdf957e2 160 if not $gotit and $var !~ /^(Author|Date|Header|Id|Locker|Log|Mcc|RCSfile|Revision|Source|State)$|_cflags$|^config_arg/;
959f3c4c 161}