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