Commit | Line | Data |
---|---|---|
bc84095b MB |
1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
9f8747e5 | 5 | |
8ec4d993 | 6 | use Cwd "abs_path"; |
959f3c4c | 7 | use File::Basename; |
a8ae8817 DH |
8 | use FindBin; |
9 | ||
8ec4d993 | 10 | my $p5_metaconfig_base = abs_path "$FindBin::Bin/../"; |
959f3c4c | 11 | |
b29c35a3 MBT |
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 | ||
8ec4d993 MBT |
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"; | |
959f3c4c | 26 | |
8ec4d993 | 27 | open my $wfh, "<", $wanted or die "$0: open $wanted: $!\n"; |
9f8747e5 MB |
28 | my @WANTED = map { $_->[0] } |
29 | sort { $a->[1] cmp $b->[1] } | |
8ec4d993 MBT |
30 | map { [ $_, lc $_ ] } |
31 | <$wfh>; | |
32 | close $wfh; | |
53068161 | 33 | |
959f3c4c | 34 | print <<'EOM'; |
cfaaf7e8 JH |
35 | |
36 | !!!!!!! DO NOT EDIT THIS FILE !!!!!!! | |
37 | This file is built by metaconfig. | |
38 | ||
959f3c4c JH |
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 | ||
bc84095b MB |
47 | my ($Loc, %expl, %file, %predef); |
48 | foreach my $file (@perl_units) { | |
8ec4d993 | 49 | open my $fh, "<", $file or die "$0: open $file: $!"; |
bc84095b MB |
50 | my $base = basename ($file); |
51 | $Loc = $file, next if $base eq "Loc.U" and not defined $Loc; | |
52 | my @var; | |
53 | while (<$fh>) { | |
53068161 | 54 | if (m/^\?S:\w+[ \t:]/ .. m/^\?S:\.$/) { |
bc84095b MB |
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 | } | |
959f3c4c | 70 | } |
bc84095b | 71 | close $fh or die "$0: close $file: $!"; |
959f3c4c | 72 | } |
959f3c4c | 73 | |
bc84095b MB |
74 | defined $Loc or die "$0: Couldn't locate Loc.U: $!"; |
75 | ||
8ec4d993 | 76 | open my $fh, "<", $Loc or die "$0: open $Loc: $!"; |
bc84095b MB |
77 | while (<$fh>) { |
78 | m/^\?(\w+):\1$/ and ($expl{$1}, $file{$1}) = (1, "Loc.U"); | |
79 | } | |
80 | close $fh or die "$0: close $Loc: $!"; | |
959f3c4c | 81 | |
bc84095b MB |
82 | { local $/ = "\n\n"; |
83 | for (<DATA>) { | |
84 | m/^(\w+)/; | |
85 | $predef{$1} = $_; | |
86 | } | |
959f3c4c | 87 | } |
959f3c4c | 88 | |
bc84095b MB |
89 | for (@WANTED) { |
90 | chomp; | |
91 | m/^#/ and next; # Skip comments | |
6b8f0cae | 92 | m/^:/ and next; # Skip comments |
bc84095b MB |
93 | m/^$/ and next; # Skip empty sections |
94 | my ($var, $val) = split /=/, $_, 2; | |
959f3c4c JH |
95 | |
96 | if (exists $expl{$var}) { | |
bc84095b MB |
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; | |
959f3c4c | 106 | This variable is defined but not used by Configure. |
3b790b13 | 107 | The value is the empty string and is not useful. |
959f3c4c JH |
108 | |
109 | EOE | |
bc84095b MB |
110 | } |
111 | else { | |
112 | print <<EOE; | |
17784b92 | 113 | This variable is used internally by Configure to determine the |
959f3c4c JH |
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 | |
bc84095b MB |
118 | } |
119 | } | |
120 | else { | |
121 | print "$var ($file{$var}):\n"; | |
122 | print @{$expl{$var}}; | |
123 | } | |
124 | next; | |
125 | } | |
126 | ||
bdf957e2 JH |
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 | |
6b8f0cae AD |
131 | # Similarly, handle the config_arg* variables from Options.U. |
132 | # -- AD 8 Dec 2009 | |
bc84095b MB |
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__ | |
bdf957e2 JH |
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 | ||
bdf957e2 JH |
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 | ||
bdf957e2 JH |
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 | ||
bdf957e2 JH |
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 | ||
bdf957e2 JH |
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 | ||
bc84095b MB |
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. | |
bdf957e2 | 193 | |
6b8f0cae AD |
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): | |
4dd7201d | 206 | This variable contains the number of command-line arguments |
6b8f0cae | 207 | passed to Configure, as reported by the shell in the $# variable. |
f53c5a67 AD |
208 | The individual arguments are stored as variables config_arg1, |
209 | config_arg2, etc. | |
6b8f0cae | 210 |