Commit | Line | Data |
---|---|---|
a0d0e21e | 1 | #!./miniperl -w |
962e59f3 DM |
2 | # |
3 | # configpm | |
4 | # | |
8ed6d636 VK |
5 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
6 | # 2002, 2003, 2004, 2005, 2006, 2007 Larry Wall and others. | |
962e59f3 DM |
7 | # |
8 | # | |
9 | # Regenerate the files | |
10 | # | |
11 | # lib/Config.pm | |
12 | # lib/Config_heavy.pl | |
13 | # lib/Config.pod | |
14 | # lib/Cross.pm (optionally) | |
15 | # | |
8ed6d636 | 16 | # |
962e59f3 DM |
17 | # from the contents of the static files |
18 | # | |
19 | # Porting/Glossary | |
20 | # myconfig.SH | |
21 | # | |
22 | # and from the contents of the Configure-generated file | |
23 | # | |
24 | # config.sh | |
25 | # | |
8ed6d636 VK |
26 | # Note that output directory is xlib/[cross-name]/ for cross-compiling |
27 | # | |
962e59f3 DM |
28 | # It will only update Config.pm and Config_heavy.pl if the contents of |
29 | # either file would be different. Note that *both* files are updated in | |
30 | # this case, since for example an extension makefile that has a dependency | |
31 | # on Config.pm should trigger even if only Config_heavy.pl has changed. | |
32 | ||
33 | sub usage { die <<EOF } | |
d2d98f31 | 34 | usage: $0 [ options ] |
962e59f3 DM |
35 | --cross=PLATFORM cross-compile for a different platform |
36 | --no-glossary don't include Porting/Glossary in lib/Config.pod | |
4e73d6a4 | 37 | --chdir=dir change directory before writing files |
962e59f3 DM |
38 | EOF |
39 | ||
2f4f46ad NC |
40 | use strict; |
41 | use vars qw(%Config $Config_SH_expanded); | |
8990e307 | 42 | |
a8e1d30b NC |
43 | my $how_many_common = 22; |
44 | ||
45 | # commonly used names to precache (and hence lookup fastest) | |
46 | my %Common; | |
47 | ||
48 | while ($how_many_common--) { | |
49 | $_ = <DATA>; | |
50 | chomp; | |
51 | /^(\S+):\s*(\d+)$/ or die "Malformed line '$_'"; | |
52 | $Common{$1} = $1; | |
53 | } | |
5435c704 | 54 | |
d50f1408 NC |
55 | # Post 37589e1eefb1bd62 DynaLoader defaults to reading these at runtime. |
56 | # Ideally we're redo the data below, but Fotango's build system made it | |
57 | # wonderfully easy to instrument, and no longer exists. | |
58 | $Common{$_} = $_ foreach qw(dlext so); | |
59 | ||
5435c704 NC |
60 | # names of things which may need to have slashes changed to double-colons |
61 | my %Extensions = map {($_,$_)} | |
62 | qw(dynamic_ext static_ext extensions known_extensions); | |
63 | ||
64 | # allowed opts as well as specifies default and initial values | |
65 | my %Allowed_Opts = ( | |
2d9d8159 NC |
66 | 'cross' => '', # --cross=PLATFORM - crosscompiling for PLATFORM |
67 | 'glossary' => 1, # --no-glossary - no glossary file inclusion, | |
5435c704 | 68 | # for compactness |
4e73d6a4 | 69 | 'chdir' => '', # --chdir=dir - change directory before writing files |
18f68570 | 70 | ); |
18f68570 | 71 | |
5435c704 NC |
72 | sub opts { |
73 | # user specified options | |
74 | my %given_opts = ( | |
75 | # --opt=smth | |
76 | (map {/^--([\-_\w]+)=(.*)$/} @ARGV), | |
77 | # --opt --no-opt --noopt | |
78 | (map {/^no-?(.*)$/i?($1=>0):($_=>1)} map {/^--([\-_\w]+)$/} @ARGV), | |
79 | ); | |
80 | ||
81 | my %opts = (%Allowed_Opts, %given_opts); | |
82 | ||
83 | for my $opt (grep {!exists $Allowed_Opts{$_}} keys %given_opts) { | |
962e59f3 DM |
84 | warn "option '$opt' is not recognized"; |
85 | usage; | |
5435c704 NC |
86 | } |
87 | @ARGV = grep {!/^--/} @ARGV; | |
88 | ||
89 | return %opts; | |
90 | } | |
18f68570 | 91 | |
5435c704 NC |
92 | |
93 | my %Opts = opts(); | |
94 | ||
4e73d6a4 NC |
95 | if ($Opts{chdir}) { |
96 | chdir $Opts{chdir} or die "$0: could not chdir $Opts{chdir}: $!" | |
97 | } | |
98 | ||
8ed6d636 | 99 | my ($Config_SH, $Config_PM, $Config_heavy, $Config_POD); |
d2d98f31 | 100 | my $Glossary = 'Porting/Glossary'; |
5435c704 NC |
101 | |
102 | if ($Opts{cross}) { | |
18f68570 VK |
103 | # creating cross-platform config file |
104 | mkdir "xlib"; | |
5435c704 | 105 | mkdir "xlib/$Opts{cross}"; |
d2d98f31 | 106 | $Config_PM = "xlib/$Opts{cross}/Config.pm"; |
8ed6d636 VK |
107 | $Config_POD = "xlib/$Opts{cross}/Config.pod"; |
108 | $Config_SH = "Cross/config-$Opts{cross}.sh"; | |
18f68570 VK |
109 | } |
110 | else { | |
d2d98f31 | 111 | $Config_PM = "lib/Config.pm"; |
8ed6d636 VK |
112 | $Config_POD = "lib/Config.pod"; |
113 | $Config_SH = "config.sh"; | |
18f68570 | 114 | } |
d2d98f31 VK |
115 | ($Config_heavy = $Config_PM) =~ s/\.pm$/_heavy.pl/; |
116 | die "Can't automatically determine name for Config_heavy.pl from '$Config_PM'" | |
117 | if $Config_heavy eq $Config_PM; | |
8990e307 | 118 | |
962e59f3 DM |
119 | my $config_txt; |
120 | my $heavy_txt; | |
2d9d8159 | 121 | |
962e59f3 | 122 | $heavy_txt .= <<'ENDOFBEG'; |
2d9d8159 NC |
123 | # This file was created by configpm when Perl was built. Any changes |
124 | # made to this file will be lost the next time perl is built. | |
125 | ||
126 | package Config; | |
127 | use strict; | |
128 | # use warnings; Pulls in Carp | |
129 | # use vars pulls in Carp | |
4a5df386 | 130 | |
3acb769b NC |
131 | sub bincompat_options { |
132 | return sort split ' ', (Internals::V())[0]; | |
133 | } | |
134 | ||
135 | sub non_bincompat_options { | |
136 | return sort split ' ', (Internals::V())[1]; | |
137 | } | |
138 | ||
139 | sub compile_date { | |
140 | return (Internals::V())[2] | |
141 | } | |
142 | ||
143 | sub local_patches { | |
144 | my (undef, undef, undef, @patches) = Internals::V(); | |
145 | return @patches; | |
146 | } | |
147 | ||
4a5df386 | 148 | sub _V { |
2dc296d2 | 149 | my ($bincompat, $non_bincompat, $date, @patches) = Internals::V(); |
4a5df386 NC |
150 | |
151 | my $opts = join ' ', sort split ' ', "$bincompat $non_bincompat"; | |
152 | ||
153 | # wrap at 76 columns. | |
154 | ||
155 | $opts =~ s/(?=.{53})(.{1,53}) /$1\n /mg; | |
156 | ||
157 | print Config::myconfig(); | |
158 | if ($^O eq 'VMS') { | |
159 | print "\nCharacteristics of this PERLSHR image: \n"; | |
160 | } else { | |
161 | print "\nCharacteristics of this binary (from libperl): \n"; | |
162 | } | |
163 | ||
164 | print " Compile-time options: $opts\n"; | |
165 | ||
166 | if (@patches) { | |
167 | print " Locally applied patches:\n"; | |
168 | print "\t$_\n" foreach @patches; | |
169 | } | |
170 | ||
2dc296d2 | 171 | print " Built under $^O\n"; |
4a5df386 NC |
172 | |
173 | print " $date\n" if defined $date; | |
174 | ||
175 | my @env = map { "$_=\"$ENV{$_}\"" } sort grep {/^PERL/} keys %ENV; | |
176 | push @env, "CYGWIN=\"$ENV{CYGWIN}\"" if $^O eq 'cygwin'; | |
177 | ||
178 | if (@env) { | |
179 | print " \%ENV:\n"; | |
180 | print " $_\n" foreach @env; | |
181 | } | |
182 | print " \@INC:\n"; | |
183 | print " $_\n" foreach @INC; | |
184 | } | |
185 | ||
2d9d8159 | 186 | ENDOFBEG |
fec02dd3 | 187 | |
c6b7b56c NC |
188 | my $export_funcs = <<'EOT'; |
189 | my %Export_Cache = (myconfig => 1, | |
3acb769b NC |
190 | config_sh => 1, config_vars => 1, config_re => 1, |
191 | bincompat_options => 1, non_bincompat_options => 1, | |
192 | compile_date => 1, local_patches => 1); | |
c6b7b56c | 193 | EOT |
a0d0e21e | 194 | |
c6b7b56c NC |
195 | my %export_ok = eval $export_funcs or die; |
196 | ||
197 | $config_txt .= sprintf << 'EOT', $export_funcs; | |
5435c704 NC |
198 | # This file was created by configpm when Perl was built. Any changes |
199 | # made to this file will be lost the next time perl is built. | |
3c81428c | 200 | |
3acf89b2 MB |
201 | # for a description of the variables, please have a look at the |
202 | # Glossary file, as written in the Porting folder, or use the url: | |
203 | # http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/Glossary | |
204 | ||
8990e307 | 205 | package Config; |
2f4f46ad NC |
206 | use strict; |
207 | # use warnings; Pulls in Carp | |
208 | # use vars pulls in Carp | |
c6b7b56c NC |
209 | |
210 | # Skip @Config::EXPORT because it only contains %%Config, which we special | |
211 | # case below as it's not a function. @Config::EXPORT won't change in the | |
212 | # lifetime of Perl 5. | |
213 | %s | |
2f4f46ad | 214 | @Config::EXPORT = qw(%%Config); |
c6b7b56c | 215 | @Config::EXPORT_OK = keys %%Export_Cache; |
a48f8c77 | 216 | |
43d06990 NC |
217 | # Need to stub all the functions to make code such as print Config::config_sh |
218 | # keep working | |
219 | ||
c6b7b56c | 220 | EOT |
43d06990 | 221 | |
c6b7b56c | 222 | $config_txt .= "sub $_;\n" foreach sort keys %export_ok; |
2f4f46ad | 223 | |
c6b7b56c NC |
224 | my $myver = sprintf "%vd", $^V; |
225 | ||
226 | $config_txt .= sprintf <<'ENDOFBEG', ($myver) x 3; | |
2f4f46ad | 227 | our %%Config; |
e3d0cac0 IZ |
228 | |
229 | # Define our own import method to avoid pulling in the full Exporter: | |
230 | sub import { | |
a5094cb0 | 231 | shift; |
2f4f46ad | 232 | @_ = @Config::EXPORT unless @_; |
5435c704 | 233 | |
a48f8c77 MS |
234 | my @funcs = grep $_ ne '%%Config', @_; |
235 | my $export_Config = @funcs < @_ ? 1 : 0; | |
5435c704 | 236 | |
2f4f46ad | 237 | no strict 'refs'; |
a48f8c77 MS |
238 | my $callpkg = caller(0); |
239 | foreach my $func (@funcs) { | |
a5094cb0 NC |
240 | die qq{"$func" is not exported by the Config module\n} |
241 | unless $Export_Cache{$func}; | |
a48f8c77 MS |
242 | *{$callpkg.'::'.$func} = \&{$func}; |
243 | } | |
5435c704 | 244 | |
a48f8c77 MS |
245 | *{"$callpkg\::Config"} = \%%Config if $export_Config; |
246 | return; | |
e3d0cac0 IZ |
247 | } |
248 | ||
b982c5de | 249 | die "Perl lib version (%s) doesn't match executable '$0' version ($])" |
5435c704 | 250 | unless $^V; |
de98c553 | 251 | |
5435c704 | 252 | $^V eq %s |
b982c5de | 253 | or die "Perl lib version (%s) doesn't match executable '$0' version (" . |
a48f8c77 | 254 | sprintf("v%%vd",$^V) . ")"; |
a0d0e21e | 255 | |
8990e307 LW |
256 | ENDOFBEG |
257 | ||
16d20bd9 | 258 | |
5435c704 | 259 | my @non_v = (); |
5435c704 NC |
260 | my @v_others = (); |
261 | my $in_v = 0; | |
262 | my %Data = (); | |
263 | ||
a0d0e21e | 264 | |
1a9ca827 | 265 | my %seen_quotes; |
2f4f46ad NC |
266 | { |
267 | my ($name, $val); | |
8ed6d636 | 268 | open(CONFIG_SH, $Config_SH) || die "Can't open $Config_SH: $!"; |
2f4f46ad | 269 | while (<CONFIG_SH>) { |
a0d0e21e | 270 | next if m:^#!/bin/sh:; |
5435c704 | 271 | |
a02608de | 272 | # Catch PERL_CONFIG_SH=true and PERL_VERSION=n line from Configure. |
d4de4258 | 273 | s/^(\w+)=(true|\d+)\s*$/$1='$2'\n/ or m/^(\w+)='(.*)'$/; |
3905a40f | 274 | my($k, $v) = ($1, $2); |
5435c704 | 275 | |
2000072c | 276 | # grandfather PATCHLEVEL and SUBVERSION and CONFIG |
cceca5ed GS |
277 | if ($k) { |
278 | if ($k eq 'PERL_VERSION') { | |
279 | push @v_others, "PATCHLEVEL='$v'\n"; | |
280 | } | |
281 | elsif ($k eq 'PERL_SUBVERSION') { | |
282 | push @v_others, "SUBVERSION='$v'\n"; | |
283 | } | |
a02608de | 284 | elsif ($k eq 'PERL_CONFIG_SH') { |
2000072c JH |
285 | push @v_others, "CONFIG='$v'\n"; |
286 | } | |
cceca5ed | 287 | } |
5435c704 | 288 | |
435ec615 HM |
289 | # We can delimit things in config.sh with either ' or ". |
290 | unless ($in_v or m/^(\w+)=(['"])(.*\n)/){ | |
a0d0e21e LW |
291 | push(@non_v, "#$_"); # not a name='value' line |
292 | next; | |
293 | } | |
2f4f46ad | 294 | my $quote = $2; |
5435c704 NC |
295 | if ($in_v) { |
296 | $val .= $_; | |
297 | } | |
298 | else { | |
299 | ($name,$val) = ($1,$3); | |
300 | } | |
435ec615 | 301 | $in_v = $val !~ /$quote\n/; |
44a8e56a | 302 | next if $in_v; |
a0d0e21e | 303 | |
5435c704 | 304 | s,/,::,g if $Extensions{$name}; |
a0d0e21e | 305 | |
5435c704 | 306 | $val =~ s/$quote\n?\z//; |
3c81428c | 307 | |
5435c704 | 308 | my $line = "$name=$quote$val$quote\n"; |
deeea481 | 309 | push(@v_others, $line); |
1a9ca827 | 310 | $seen_quotes{$quote}++; |
2f4f46ad NC |
311 | } |
312 | close CONFIG_SH; | |
5435c704 | 313 | } |
2f4f46ad | 314 | |
1a9ca827 NC |
315 | # This is somewhat grim, but I want the code for parsing config.sh here and |
316 | # now so that I can expand $Config{ivsize} and $Config{ivtype} | |
317 | ||
318 | my $fetch_string = <<'EOT'; | |
319 | ||
320 | # Search for it in the big string | |
321 | sub fetch_string { | |
322 | my($self, $key) = @_; | |
323 | ||
324 | EOT | |
325 | ||
326 | if ($seen_quotes{'"'}) { | |
327 | # We need the full ' and " code | |
1a9ca827 | 328 | |
b46acf92 NC |
329 | $fetch_string .= <<'EOT'; |
330 | return undef unless my ($quote_type, $value) = $Config_SH_expanded =~ /\n$key=(['"])(.*?)\1\n/s; | |
1a9ca827 NC |
331 | |
332 | # If we had a double-quote, we'd better eval it so escape | |
333 | # sequences and such can be interpolated. Since the incoming | |
334 | # value is supposed to follow shell rules and not perl rules, | |
335 | # we escape any perl variable markers | |
b46acf92 NC |
336 | |
337 | # Historically, since " 'support' was added in change 1409, the | |
338 | # interpolation was done before the undef. Stick to this arguably buggy | |
339 | # behaviour as we're refactoring. | |
1a9ca827 NC |
340 | if ($quote_type eq '"') { |
341 | $value =~ s/\$/\\\$/g; | |
342 | $value =~ s/\@/\\\@/g; | |
343 | eval "\$value = \"$value\""; | |
344 | } | |
b46acf92 NC |
345 | |
346 | # So we can say "if $Config{'foo'}". | |
347 | $self->{$key} = $value eq 'undef' ? undef : $value; # cache it | |
1a9ca827 | 348 | } |
b46acf92 NC |
349 | EOT |
350 | ||
351 | } else { | |
352 | # We only have ' delimted. | |
353 | ||
1a9ca827 | 354 | $fetch_string .= <<'EOT'; |
b46acf92 | 355 | return undef unless $Config_SH_expanded =~ /\n$key=\'(.*?)\'\n/s; |
1a9ca827 | 356 | # So we can say "if $Config{'foo'}". |
b46acf92 | 357 | $self->{$key} = $1 eq 'undef' ? undef : $1; |
1a9ca827 NC |
358 | } |
359 | EOT | |
360 | ||
b46acf92 NC |
361 | } |
362 | ||
1a9ca827 NC |
363 | eval $fetch_string; |
364 | die if $@; | |
3c81428c | 365 | |
8468119f NC |
366 | # Calculation for the keys for byteorder |
367 | # This is somewhat grim, but I need to run fetch_string here. | |
deeea481 | 368 | our $Config_SH_expanded = join "\n", '', @v_others; |
8468119f NC |
369 | |
370 | my $t = fetch_string ({}, 'ivtype'); | |
371 | my $s = fetch_string ({}, 'ivsize'); | |
372 | ||
373 | # byteorder does exist on its own but we overlay a virtual | |
374 | # dynamically recomputed value. | |
375 | ||
376 | # However, ivtype and ivsize will not vary for sane fat binaries | |
377 | ||
378 | my $f = $t eq 'long' ? 'L!' : $s == 8 ? 'Q': 'I'; | |
379 | ||
380 | my $byteorder_code; | |
381 | if ($s == 4 || $s == 8) { | |
382 | my $list = join ',', reverse(2..$s); | |
383 | my $format = 'a'x$s; | |
384 | $byteorder_code = <<"EOT"; | |
2855b621 | 385 | |
8468119f NC |
386 | my \$i = 0; |
387 | foreach my \$c ($list) { \$i |= ord(\$c); \$i <<= 8 } | |
388 | \$i |= ord(1); | |
2d9d8159 | 389 | our \$byteorder = join('', unpack('$format', pack('$f', \$i))); |
8468119f NC |
390 | EOT |
391 | } else { | |
2d9d8159 | 392 | $byteorder_code = "our \$byteorder = '?'x$s;\n"; |
8468119f NC |
393 | } |
394 | ||
88fe16b2 NC |
395 | my @need_relocation; |
396 | ||
397 | if (fetch_string({},'userelocatableinc')) { | |
4d20abad NC |
398 | foreach my $what (qw(prefixexp |
399 | ||
400 | archlibexp | |
401 | html1direxp | |
402 | html3direxp | |
403 | man1direxp | |
404 | man3direxp | |
91f668c3 | 405 | privlibexp |
4d20abad | 406 | scriptdirexp |
91f668c3 | 407 | sitearchexp |
4d20abad NC |
408 | sitebinexp |
409 | sitehtml1direxp | |
410 | sitehtml3direxp | |
91f668c3 | 411 | sitelibexp |
4d20abad NC |
412 | siteman1direxp |
413 | siteman3direxp | |
414 | sitescriptexp | |
91f668c3 | 415 | vendorarchexp |
4d20abad NC |
416 | vendorbinexp |
417 | vendorhtml1direxp | |
418 | vendorhtml3direxp | |
91f668c3 | 419 | vendorlibexp |
4d20abad NC |
420 | vendorman1direxp |
421 | vendorman3direxp | |
422 | vendorscriptexp | |
423 | ||
424 | siteprefixexp | |
425 | sitelib_stem | |
1d230ada NC |
426 | vendorlib_stem |
427 | ||
428 | installarchlib | |
429 | installhtml1dir | |
430 | installhtml3dir | |
431 | installman1dir | |
432 | installman3dir | |
433 | installprefix | |
434 | installprefixexp | |
435 | installprivlib | |
436 | installscript | |
437 | installsitearch | |
438 | installsitebin | |
439 | installsitehtml1dir | |
440 | installsitehtml3dir | |
441 | installsitelib | |
442 | installsiteman1dir | |
443 | installsiteman3dir | |
444 | installsitescript | |
445 | installvendorarch | |
446 | installvendorbin | |
447 | installvendorhtml1dir | |
448 | installvendorhtml3dir | |
449 | installvendorlib | |
450 | installvendorman1dir | |
451 | installvendorman3dir | |
452 | installvendorscript | |
453 | )) { | |
88fe16b2 NC |
454 | push @need_relocation, $what if fetch_string({}, $what) =~ m!^\.\.\./!; |
455 | } | |
88fe16b2 NC |
456 | } |
457 | ||
458 | my %need_relocation; | |
459 | @need_relocation{@need_relocation} = @need_relocation; | |
460 | ||
91f668c3 NC |
461 | # This can have .../ anywhere: |
462 | if (fetch_string({}, 'otherlibdirs') =~ m!\.\.\./!) { | |
463 | $need_relocation{otherlibdirs} = 'otherlibdirs'; | |
464 | } | |
465 | ||
88fe16b2 NC |
466 | my $relocation_code = <<'EOT'; |
467 | ||
468 | sub relocate_inc { | |
469 | my $libdir = shift; | |
470 | return $libdir unless $libdir =~ s!^\.\.\./!!; | |
471 | my $prefix = $^X; | |
472 | if ($prefix =~ s!/[^/]*$!!) { | |
473 | while ($libdir =~ m!^\.\./!) { | |
474 | # Loop while $libdir starts "../" and $prefix still has a trailing | |
475 | # directory | |
476 | last unless $prefix =~ s!/([^/]+)$!!; | |
477 | # but bail out if the directory we picked off the end of $prefix is . | |
478 | # or .. | |
479 | if ($1 eq '.' or $1 eq '..') { | |
480 | # Undo! This should be rare, hence code it this way rather than a | |
481 | # check each time before the s!!! above. | |
482 | $prefix = "$prefix/$1"; | |
483 | last; | |
484 | } | |
485 | # Remove that leading ../ and loop again | |
486 | substr ($libdir, 0, 3, ''); | |
487 | } | |
488 | $libdir = "$prefix/$libdir"; | |
489 | } | |
490 | $libdir; | |
491 | } | |
492 | EOT | |
493 | ||
91f668c3 | 494 | if (%need_relocation) { |
88fe16b2 | 495 | my $relocations_in_common; |
91f668c3 NC |
496 | # otherlibdirs only features in the hash |
497 | foreach (keys %need_relocation) { | |
88fe16b2 NC |
498 | $relocations_in_common++ if $Common{$_}; |
499 | } | |
500 | if ($relocations_in_common) { | |
962e59f3 | 501 | $config_txt .= $relocation_code; |
88fe16b2 | 502 | } else { |
962e59f3 | 503 | $heavy_txt .= $relocation_code; |
88fe16b2 NC |
504 | } |
505 | } | |
506 | ||
962e59f3 | 507 | $heavy_txt .= join('', @non_v) . "\n"; |
3c81428c | 508 | |
5435c704 | 509 | # copy config summary format from the myconfig.SH script |
962e59f3 | 510 | $heavy_txt .= "our \$summary = <<'!END!';\n"; |
3b5ca523 | 511 | open(MYCONFIG,"<myconfig.SH") || die "open myconfig.SH failed: $!"; |
54310121 | 512 | 1 while defined($_ = <MYCONFIG>) && !/^Summary of/; |
962e59f3 | 513 | do { $heavy_txt .= $_ } until !defined($_ = <MYCONFIG>) || /^\s*$/; |
3c81428c | 514 | close(MYCONFIG); |
a0d0e21e | 515 | |
962e59f3 | 516 | $heavy_txt .= "\n!END!\n" . <<'EOT'; |
90ec21fb | 517 | my $summary_expanded; |
3c81428c | 518 | |
519 | sub myconfig { | |
90ec21fb EM |
520 | return $summary_expanded if $summary_expanded; |
521 | ($summary_expanded = $summary) =~ s{\$(\w+)} | |
46807d8e YO |
522 | { |
523 | my $c; | |
524 | if ($1 eq 'git_ancestor_line') { | |
525 | if ($Config::Config{git_ancestor}) { | |
526 | $c= "\n Ancestor: $Config::Config{git_ancestor}"; | |
527 | } else { | |
528 | $c= ""; | |
529 | } | |
530 | } else { | |
531 | $c = $Config::Config{$1}; | |
532 | } | |
533 | defined($c) ? $c : 'undef' | |
534 | }ge; | |
90ec21fb | 535 | $summary_expanded; |
3c81428c | 536 | } |
5435c704 | 537 | |
8468119f NC |
538 | local *_ = \my $a; |
539 | $_ = <<'!END!'; | |
3c81428c | 540 | EOT |
541 | ||
962e59f3 | 542 | $heavy_txt .= join('', sort @v_others) . "!END!\n"; |
2855b621 NC |
543 | |
544 | # Only need the dynamic byteorder code in Config.pm if 'byteorder' is one of | |
545 | # the precached keys | |
546 | if ($Common{byteorder}) { | |
962e59f3 | 547 | $config_txt .= $byteorder_code; |
2855b621 | 548 | } else { |
962e59f3 | 549 | $heavy_txt .= $byteorder_code; |
2855b621 | 550 | } |
5435c704 | 551 | |
88fe16b2 | 552 | if (@need_relocation) { |
962e59f3 DM |
553 | $heavy_txt .= 'foreach my $what (qw(' . join (' ', @need_relocation) . |
554 | ")) {\n" . <<'EOT'; | |
8d962fa1 | 555 | s/^($what=)(['"])(.*?)\2/$1 . $2 . relocate_inc($3) . $2/me; |
88fe16b2 NC |
556 | } |
557 | EOT | |
91f668c3 NC |
558 | # Currently it only makes sense to do the ... relocation on Unix, so there's |
559 | # no need to emulate the "which separator for this platform" logic in perl.c - | |
560 | # ':' will always be applicable | |
561 | if ($need_relocation{otherlibdirs}) { | |
962e59f3 | 562 | $heavy_txt .= << 'EOT'; |
91f668c3 NC |
563 | s{^(otherlibdirs=)(['"])(.*?)\2} |
564 | {$1 . $2 . join ':', map {relocate_inc($_)} split ':', $3 . $2}me; | |
565 | EOT | |
566 | } | |
88fe16b2 NC |
567 | } |
568 | ||
962e59f3 | 569 | $heavy_txt .= <<'EOT'; |
2d9d8159 | 570 | s/(byteorder=)(['"]).*?\2/$1$2$Config::byteorder$2/m; |
43d06990 NC |
571 | |
572 | my $config_sh_len = length $_; | |
3be00128 | 573 | |
e935c5a4 | 574 | our $Config_SH_expanded = "\n$_" . << 'EOVIRTUAL'; |
8468119f NC |
575 | EOT |
576 | ||
06482b90 NC |
577 | foreach my $prefix (qw(ccflags ldflags)) { |
578 | my $value = fetch_string ({}, $prefix); | |
579 | my $withlargefiles = fetch_string ({}, $prefix . "_uselargefiles"); | |
27da23d5 JH |
580 | if (defined $withlargefiles) { |
581 | $value =~ s/\Q$withlargefiles\E\b//; | |
962e59f3 | 582 | $heavy_txt .= "${prefix}_nolargefiles='$value'\n"; |
27da23d5 | 583 | } |
06482b90 | 584 | } |
5435c704 | 585 | |
06482b90 NC |
586 | foreach my $prefix (qw(libs libswanted)) { |
587 | my $value = fetch_string ({}, $prefix); | |
27da23d5 JH |
588 | my $withlf = fetch_string ({}, 'libswanted_uselargefiles'); |
589 | next unless defined $withlf; | |
06482b90 NC |
590 | my @lflibswanted |
591 | = split(' ', fetch_string ({}, 'libswanted_uselargefiles')); | |
592 | if (@lflibswanted) { | |
593 | my %lflibswanted; | |
594 | @lflibswanted{@lflibswanted} = (); | |
595 | if ($prefix eq 'libs') { | |
596 | my @libs = grep { /^-l(.+)/ && | |
597 | not exists $lflibswanted{$1} } | |
598 | split(' ', fetch_string ({}, 'libs')); | |
599 | $value = join(' ', @libs); | |
600 | } else { | |
601 | my @libswanted = grep { not exists $lflibswanted{$_} } | |
602 | split(' ', fetch_string ({}, 'libswanted')); | |
603 | $value = join(' ', @libswanted); | |
4b2ec495 | 604 | } |
435ec615 | 605 | } |
962e59f3 | 606 | $heavy_txt .= "${prefix}_nolargefiles='$value'\n"; |
5435c704 NC |
607 | } |
608 | ||
962e59f3 | 609 | $heavy_txt .= "EOVIRTUAL\n"; |
06482b90 | 610 | |
46807d8e | 611 | $heavy_txt .= <<'ENDOFGIT'; |
505afc73 | 612 | eval { |
12d7e04d YO |
613 | # do not have hairy conniptions if this isnt available |
614 | require 'Config_git.pl'; | |
615 | $Config_SH_expanded .= $Config::Git_Data; | |
505afc73 YO |
616 | 1; |
617 | } or warn "Warning: failed to load Config_git.pl, something strange about this perl...\n"; | |
46807d8e YO |
618 | ENDOFGIT |
619 | ||
962e59f3 | 620 | $heavy_txt .= $fetch_string; |
06482b90 | 621 | |
962e59f3 | 622 | $config_txt .= <<'ENDOFEND'; |
06482b90 | 623 | |
2d9d8159 | 624 | sub FETCH { |
5435c704 NC |
625 | my($self, $key) = @_; |
626 | ||
627 | # check for cached value (which may be undef so we use exists not defined) | |
628 | return $self->{$key} if exists $self->{$key}; | |
629 | ||
06482b90 | 630 | return $self->fetch_string($key); |
a0d0e21e | 631 | } |
2d9d8159 NC |
632 | ENDOFEND |
633 | ||
962e59f3 | 634 | $heavy_txt .= <<'ENDOFEND'; |
1a9ca827 | 635 | |
3c81428c | 636 | my $prevpos = 0; |
637 | ||
a0d0e21e LW |
638 | sub FIRSTKEY { |
639 | $prevpos = 0; | |
2ddb7828 | 640 | substr($Config_SH_expanded, 1, index($Config_SH_expanded, '=') - 1 ); |
a0d0e21e LW |
641 | } |
642 | ||
643 | sub NEXTKEY { | |
1a9ca827 NC |
644 | ENDOFEND |
645 | if ($seen_quotes{'"'}) { | |
962e59f3 | 646 | $heavy_txt .= <<'ENDOFEND'; |
435ec615 | 647 | # Find out how the current key's quoted so we can skip to its end. |
3be00128 NC |
648 | my $quote = substr($Config_SH_expanded, |
649 | index($Config_SH_expanded, "=", $prevpos)+1, 1); | |
650 | my $pos = index($Config_SH_expanded, qq($quote\n), $prevpos) + 2; | |
1a9ca827 NC |
651 | ENDOFEND |
652 | } else { | |
653 | # Just ' quotes, so it's much easier. | |
962e59f3 | 654 | $heavy_txt .= <<'ENDOFEND'; |
1a9ca827 NC |
655 | my $pos = index($Config_SH_expanded, qq('\n), $prevpos) + 2; |
656 | ENDOFEND | |
657 | } | |
962e59f3 | 658 | $heavy_txt .= <<'ENDOFEND'; |
3be00128 | 659 | my $len = index($Config_SH_expanded, "=", $pos) - $pos; |
a0d0e21e | 660 | $prevpos = $pos; |
3be00128 | 661 | $len > 0 ? substr($Config_SH_expanded, $pos, $len) : undef; |
85e6fe83 | 662 | } |
a0d0e21e | 663 | |
2ddb7828 | 664 | sub EXISTS { |
5435c704 NC |
665 | return 1 if exists($_[0]->{$_[1]}); |
666 | ||
1a9ca827 NC |
667 | return(index($Config_SH_expanded, "\n$_[1]='") != -1 |
668 | ENDOFEND | |
669 | if ($seen_quotes{'"'}) { | |
962e59f3 | 670 | $heavy_txt .= <<'ENDOFEND'; |
1a9ca827 NC |
671 | or index($Config_SH_expanded, "\n$_[1]=\"") != -1 |
672 | ENDOFEND | |
673 | } | |
962e59f3 | 674 | $heavy_txt .= <<'ENDOFEND'; |
5435c704 | 675 | ); |
a0d0e21e LW |
676 | } |
677 | ||
3c81428c | 678 | sub STORE { die "\%Config::Config is read-only\n" } |
5435c704 NC |
679 | *DELETE = \&STORE; |
680 | *CLEAR = \&STORE; | |
a0d0e21e | 681 | |
3c81428c | 682 | |
683 | sub config_sh { | |
43d06990 | 684 | substr $Config_SH_expanded, 1, $config_sh_len; |
748a9306 | 685 | } |
9193ea20 | 686 | |
687 | sub config_re { | |
688 | my $re = shift; | |
3be00128 NC |
689 | return map { chomp; $_ } grep eval{ /^(?:$re)=/ }, split /^/, |
690 | $Config_SH_expanded; | |
9193ea20 | 691 | } |
692 | ||
3c81428c | 693 | sub config_vars { |
307dc113 | 694 | # implements -V:cfgvar option (see perlrun -V:) |
a48f8c77 | 695 | foreach (@_) { |
307dc113 | 696 | # find optional leading, trailing colons; and query-spec |
4a305f6a | 697 | my ($notag,$qry,$lncont) = m/^(:)?(.*?)(:)?$/; # flags fore and aft, |
307dc113 JC |
698 | # map colon-flags to print decorations |
699 | my $prfx = $notag ? '': "$qry="; # tag-prefix for print | |
700 | my $lnend = $lncont ? ' ' : ";\n"; # line ending for print | |
4a305f6a | 701 | |
307dc113 | 702 | # all config-vars are by definition \w only, any \W means regex |
4a305f6a JC |
703 | if ($qry =~ /\W/) { |
704 | my @matches = config_re($qry); | |
705 | print map "$_$lnend", @matches ? @matches : "$qry: not found" if !$notag; | |
706 | print map { s/\w+=//; "$_$lnend" } @matches ? @matches : "$qry: not found" if $notag; | |
a48f8c77 | 707 | } else { |
2d9d8159 NC |
708 | my $v = (exists $Config::Config{$qry}) ? $Config::Config{$qry} |
709 | : 'UNKNOWN'; | |
a48f8c77 | 710 | $v = 'undef' unless defined $v; |
4a305f6a | 711 | print "${prfx}'${v}'$lnend"; |
a48f8c77 | 712 | } |
3c81428c | 713 | } |
714 | } | |
715 | ||
2d9d8159 NC |
716 | # Called by the real AUTOLOAD |
717 | sub launcher { | |
718 | undef &AUTOLOAD; | |
719 | goto \&$Config::AUTOLOAD; | |
720 | } | |
721 | ||
722 | 1; | |
9193ea20 | 723 | ENDOFEND |
724 | ||
725 | if ($^O eq 'os2') { | |
962e59f3 | 726 | $config_txt .= <<'ENDOFSET'; |
9193ea20 | 727 | my %preconfig; |
728 | if ($OS2::is_aout) { | |
3be00128 | 729 | my ($value, $v) = $Config_SH_expanded =~ m/^used_aout='(.*)'\s*$/m; |
9193ea20 | 730 | for (split ' ', $value) { |
3be00128 | 731 | ($v) = $Config_SH_expanded =~ m/^aout_$_='(.*)'\s*$/m; |
9193ea20 | 732 | $preconfig{$_} = $v eq 'undef' ? undef : $v; |
733 | } | |
734 | } | |
764df951 | 735 | $preconfig{d_fork} = undef unless $OS2::can_fork; # Some funny cases can't |
9193ea20 | 736 | sub TIEHASH { bless {%preconfig} } |
737 | ENDOFSET | |
a48f8c77 MS |
738 | # Extract the name of the DLL from the makefile to avoid duplication |
739 | my ($f) = grep -r, qw(GNUMakefile Makefile); | |
740 | my $dll; | |
741 | if (open my $fh, '<', $f) { | |
742 | while (<$fh>) { | |
743 | $dll = $1, last if /^PERL_DLL_BASE\s*=\s*(\S*)\s*$/; | |
744 | } | |
30500b05 | 745 | } |
962e59f3 | 746 | $config_txt .= <<ENDOFSET if $dll; |
30500b05 IZ |
747 | \$preconfig{dll_name} = '$dll'; |
748 | ENDOFSET | |
9193ea20 | 749 | } else { |
962e59f3 | 750 | $config_txt .= <<'ENDOFSET'; |
5435c704 NC |
751 | sub TIEHASH { |
752 | bless $_[1], $_[0]; | |
753 | } | |
9193ea20 | 754 | ENDOFSET |
755 | } | |
756 | ||
a8e1d30b NC |
757 | foreach my $key (keys %Common) { |
758 | my $value = fetch_string ({}, $key); | |
759 | # Is it safe on the LHS of => ? | |
760 | my $qkey = $key =~ /^[A-Za-z_][A-Za-z0-9_]*$/ ? $key : "'$key'"; | |
761 | if (defined $value) { | |
762 | # Quote things for a '' string | |
763 | $value =~ s!\\!\\\\!g; | |
764 | $value =~ s!'!\\'!g; | |
765 | $value = "'$value'"; | |
91f668c3 NC |
766 | if ($key eq 'otherlibdirs') { |
767 | $value = "join (':', map {relocate_inc(\$_)} split (':', $value))"; | |
768 | } elsif ($need_relocation{$key}) { | |
88fe16b2 NC |
769 | $value = "relocate_inc($value)"; |
770 | } | |
a8e1d30b NC |
771 | } else { |
772 | $value = "undef"; | |
773 | } | |
774 | $Common{$key} = "$qkey => $value"; | |
775 | } | |
2855b621 NC |
776 | |
777 | if ($Common{byteorder}) { | |
778 | $Common{byteorder} = 'byteorder => $byteorder'; | |
779 | } | |
780 | my $fast_config = join '', map { " $_,\n" } sort values %Common; | |
5435c704 | 781 | |
938af39e NC |
782 | # Sanity check needed to stop an infite loop if Config_heavy.pl fails to define |
783 | # &launcher for some reason (eg it got truncated) | |
962e59f3 | 784 | $config_txt .= sprintf <<'ENDOFTIE', $fast_config; |
9193ea20 | 785 | |
fb73857a | 786 | sub DESTROY { } |
787 | ||
2d9d8159 | 788 | sub AUTOLOAD { |
c1b2b415 | 789 | require 'Config_heavy.pl'; |
938af39e | 790 | goto \&launcher unless $Config::AUTOLOAD =~ /launcher$/; |
2d9d8159 NC |
791 | die "&Config::AUTOLOAD failed on $Config::AUTOLOAD"; |
792 | } | |
793 | ||
2c165900 | 794 | # tie returns the object, so the value returned to require will be true. |
5435c704 | 795 | tie %%Config, 'Config', { |
a8e1d30b | 796 | %s}; |
5435c704 NC |
797 | ENDOFTIE |
798 | ||
748a9306 | 799 | |
8ed6d636 | 800 | open(CONFIG_POD, ">$Config_POD") or die "Can't open $Config_POD: $!"; |
5435c704 | 801 | print CONFIG_POD <<'ENDOFTAIL'; |
3c81428c | 802 | =head1 NAME |
a0d0e21e | 803 | |
3c81428c | 804 | Config - access Perl configuration information |
805 | ||
806 | =head1 SYNOPSIS | |
807 | ||
808 | use Config; | |
63f18be6 NC |
809 | if ($Config{usethreads}) { |
810 | print "has thread support\n" | |
3c81428c | 811 | } |
812 | ||
a48f8c77 | 813 | use Config qw(myconfig config_sh config_vars config_re); |
3c81428c | 814 | |
815 | print myconfig(); | |
816 | ||
817 | print config_sh(); | |
818 | ||
a48f8c77 MS |
819 | print config_re(); |
820 | ||
3c81428c | 821 | config_vars(qw(osname archname)); |
822 | ||
823 | ||
824 | =head1 DESCRIPTION | |
825 | ||
826 | The Config module contains all the information that was available to | |
827 | the C<Configure> program at Perl build time (over 900 values). | |
828 | ||
829 | Shell variables from the F<config.sh> file (written by Configure) are | |
830 | stored in the readonly-variable C<%Config>, indexed by their names. | |
831 | ||
832 | Values stored in config.sh as 'undef' are returned as undefined | |
1fef88e7 | 833 | values. The perl C<exists> function can be used to check if a |
3c81428c | 834 | named variable exists. |
835 | ||
3acf89b2 MB |
836 | For a description of the variables, please have a look at the |
837 | Glossary file, as written in the Porting folder, or use the url: | |
838 | http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/Glossary | |
839 | ||
3c81428c | 840 | =over 4 |
841 | ||
842 | =item myconfig() | |
843 | ||
844 | Returns a textual summary of the major perl configuration values. | |
845 | See also C<-V> in L<perlrun/Switches>. | |
846 | ||
847 | =item config_sh() | |
848 | ||
849 | Returns the entire perl configuration information in the form of the | |
850 | original config.sh shell variable assignment script. | |
851 | ||
a48f8c77 MS |
852 | =item config_re($regex) |
853 | ||
854 | Like config_sh() but returns, as a list, only the config entries who's | |
855 | names match the $regex. | |
856 | ||
3c81428c | 857 | =item config_vars(@names) |
858 | ||
859 | Prints to STDOUT the values of the named configuration variable. Each is | |
860 | printed on a separate line in the form: | |
861 | ||
862 | name='value'; | |
863 | ||
864 | Names which are unknown are output as C<name='UNKNOWN';>. | |
865 | See also C<-V:name> in L<perlrun/Switches>. | |
866 | ||
3acb769b NC |
867 | =item bincompat_options() |
868 | ||
869 | Returns a list of C pre-processor options used when compiling this F<perl> | |
870 | binary, which affect its binary compatibility with extensions. | |
871 | C<bincompat_options()> and C<non_bincompat_options()> are shown together in | |
872 | the output of C<perl -V> as I<Compile-time options>. | |
873 | ||
874 | =item non_bincompat_options() | |
875 | ||
876 | Returns a list of C pre-processor options used when compiling this F<perl> | |
877 | binary, which do not affect binary compatibility with extensions. | |
878 | ||
879 | =item compile_date() | |
880 | ||
881 | Returns the compile date (as a string), equivalent to what is shown by | |
882 | C<perl -V> | |
883 | ||
884 | =item local_patches() | |
885 | ||
886 | Returns a list of the names of locally applied patches, equivalent to what | |
887 | is shown by C<perl -V>. | |
888 | ||
3c81428c | 889 | =back |
890 | ||
891 | =head1 EXAMPLE | |
892 | ||
893 | Here's a more sophisticated example of using %Config: | |
894 | ||
895 | use Config; | |
743c51bc W |
896 | use strict; |
897 | ||
898 | my %sig_num; | |
899 | my @sig_name; | |
900 | unless($Config{sig_name} && $Config{sig_num}) { | |
901 | die "No sigs?"; | |
902 | } else { | |
903 | my @names = split ' ', $Config{sig_name}; | |
904 | @sig_num{@names} = split ' ', $Config{sig_num}; | |
905 | foreach (@names) { | |
906 | $sig_name[$sig_num{$_}] ||= $_; | |
907 | } | |
908 | } | |
3c81428c | 909 | |
743c51bc W |
910 | print "signal #17 = $sig_name[17]\n"; |
911 | if ($sig_num{ALRM}) { | |
912 | print "SIGALRM is $sig_num{ALRM}\n"; | |
3c81428c | 913 | } |
914 | ||
915 | =head1 WARNING | |
916 | ||
917 | Because this information is not stored within the perl executable | |
918 | itself it is possible (but unlikely) that the information does not | |
919 | relate to the actual perl binary which is being used to access it. | |
920 | ||
921 | The Config module is installed into the architecture and version | |
922 | specific library directory ($Config{installarchlib}) and it checks the | |
923 | perl version number when loaded. | |
924 | ||
435ec615 HM |
925 | The values stored in config.sh may be either single-quoted or |
926 | double-quoted. Double-quoted strings are handy for those cases where you | |
927 | need to include escape sequences in the strings. To avoid runtime variable | |
928 | interpolation, any C<$> and C<@> characters are replaced by C<\$> and | |
929 | C<\@>, respectively. This isn't foolproof, of course, so don't embed C<\$> | |
930 | or C<\@> in double-quoted strings unless you're willing to deal with the | |
931 | consequences. (The slashes will end up escaped and the C<$> or C<@> will | |
932 | trigger variable interpolation) | |
933 | ||
ebc74a4b GS |
934 | =head1 GLOSSARY |
935 | ||
936 | Most C<Config> variables are determined by the C<Configure> script | |
937 | on platforms supported by it (which is most UNIX platforms). Some | |
938 | platforms have custom-made C<Config> variables, and may thus not have | |
939 | some of the variables described below, or may have extraneous variables | |
940 | specific to that particular port. See the port specific documentation | |
941 | in such cases. | |
942 | ||
c90cd22b RGS |
943 | =cut |
944 | ||
ebc74a4b GS |
945 | ENDOFTAIL |
946 | ||
5435c704 NC |
947 | if ($Opts{glossary}) { |
948 | open(GLOS, "<$Glossary") or die "Can't open $Glossary: $!"; | |
18f68570 | 949 | } |
2f4f46ad NC |
950 | my %seen = (); |
951 | my $text = 0; | |
fb87c415 IZ |
952 | $/ = ''; |
953 | ||
954 | sub process { | |
aade5aff YST |
955 | if (s/\A(\w*)\s+\(([\w.]+)\):\s*\n(\t?)/=item C<$1>\n\nFrom F<$2>:\n\n/m) { |
956 | my $c = substr $1, 0, 1; | |
957 | unless ($seen{$c}++) { | |
5435c704 | 958 | print CONFIG_POD <<EOF if $text; |
fb87c415 | 959 | =back |
ebc74a4b | 960 | |
c90cd22b RGS |
961 | =cut |
962 | ||
fb87c415 | 963 | EOF |
5435c704 | 964 | print CONFIG_POD <<EOF; |
fb87c415 IZ |
965 | =head2 $c |
966 | ||
bbc7dcd2 | 967 | =over 4 |
fb87c415 | 968 | |
c90cd22b RGS |
969 | =cut |
970 | ||
fb87c415 | 971 | EOF |
aade5aff YST |
972 | $text = 1; |
973 | } | |
974 | } | |
975 | elsif (!$text || !/\A\t/) { | |
976 | warn "Expected a Configure variable header", | |
977 | ($text ? " or another paragraph of description" : () ); | |
fb87c415 IZ |
978 | } |
979 | s/n't/n\00t/g; # leave can't, won't etc untouched | |
9b22980b | 980 | s/^\t\s+(.*)/\n$1/gm; # Indented lines ===> new paragraph |
fb87c415 IZ |
981 | s/^(?<!\n\n)\t(.*)/$1/gm; # Not indented lines ===> text |
982 | s{([\'\"])(?=[^\'\"\s]*[./][^\'\"\s]*\1)([^\'\"\s]+)\1}(F<$2>)g; # '.o' | |
983 | s{([\'\"])([^\'\"\s]+)\1}(C<$2>)g; # "date" command | |
984 | s{\'([A-Za-z_\- *=/]+)\'}(C<$1>)g; # 'ln -s' | |
985 | s{ | |
986 | (?<! [\w./<\'\"] ) # Only standalone file names | |
987 | (?! e \. g \. ) # Not e.g. | |
988 | (?! \. \. \. ) # Not ... | |
989 | (?! \d ) # Not 5.004 | |
a1151a3c RGS |
990 | (?! read/ ) # Not read/write |
991 | (?! etc\. ) # Not etc. | |
992 | (?! I/O ) # Not I/O | |
993 | ( | |
994 | \$ ? # Allow leading $ | |
995 | [\w./]* [./] [\w./]* # Require . or / inside | |
996 | ) | |
997 | (?<! \. (?= [\s)] ) ) # Do not include trailing dot | |
fb87c415 IZ |
998 | (?! [\w/] ) # Include all of it |
999 | } | |
1000 | (F<$1>)xg; # /usr/local | |
1001 | s/((?<=\s)~\w*)/F<$1>/g; # ~name | |
1002 | s/(?<![.<\'\"])\b([A-Z_]{2,})\b(?![\'\"])/C<$1>/g; # UNISTD | |
1003 | s/(?<![.<\'\"])\b(?!the\b)(\w+)\s+macro\b/C<$1> macro/g; # FILE_cnt macro | |
1004 | s/n[\0]t/n't/g; # undo can't, won't damage | |
ebc74a4b GS |
1005 | } |
1006 | ||
5435c704 | 1007 | if ($Opts{glossary}) { |
7701ffb5 JH |
1008 | <GLOS>; # Skip the "DO NOT EDIT" |
1009 | <GLOS>; # Skip the preamble | |
18f68570 VK |
1010 | while (<GLOS>) { |
1011 | process; | |
5435c704 | 1012 | print CONFIG_POD; |
18f68570 | 1013 | } |
fb87c415 | 1014 | } |
ebc74a4b | 1015 | |
5435c704 | 1016 | print CONFIG_POD <<'ENDOFTAIL'; |
ebc74a4b GS |
1017 | |
1018 | =back | |
1019 | ||
58ab6743 RS |
1020 | =head1 GIT DATA |
1021 | ||
1022 | Information on the git commit from which the current perl binary was compiled | |
1023 | can be found in the variable C<$Config::Git_Data>. The variable is a | |
1024 | structured string that looks something like this: | |
1025 | ||
1026 | git_commit_id='ea0c2dbd5f5ac6845ecc7ec6696415bf8e27bd52' | |
1027 | git_describe='GitLive-blead-1076-gea0c2db' | |
1028 | git_branch='smartmatch' | |
1029 | git_uncommitted_changes='' | |
1030 | git_commit_id_title='Commit id:' | |
1031 | git_commit_date='2009-05-09 17:47:31 +0200' | |
1032 | ||
1033 | Its format is not guaranteed not to change over time. | |
1034 | ||
3c81428c | 1035 | =head1 NOTE |
1036 | ||
1037 | This module contains a good example of how to use tie to implement a | |
1038 | cache and an example of how to make a tied variable readonly to those | |
1039 | outside of it. | |
1040 | ||
1041 | =cut | |
a0d0e21e | 1042 | |
9193ea20 | 1043 | ENDOFTAIL |
a0d0e21e | 1044 | |
962e59f3 | 1045 | close(GLOS) if $Opts{glossary}; |
5435c704 | 1046 | close(CONFIG_POD); |
8ed6d636 | 1047 | print "written $Config_POD\n"; |
962e59f3 DM |
1048 | |
1049 | my $orig_config_txt = ""; | |
1050 | my $orig_heavy_txt = ""; | |
1051 | { | |
1052 | local $/; | |
1053 | my $fh; | |
1054 | $orig_config_txt = <$fh> if open $fh, "<", $Config_PM; | |
1055 | $orig_heavy_txt = <$fh> if open $fh, "<", $Config_heavy; | |
1056 | } | |
1057 | ||
1058 | if ($orig_config_txt ne $config_txt or $orig_heavy_txt ne $heavy_txt) { | |
1059 | open CONFIG, ">", $Config_PM or die "Can't open $Config_PM: $!\n"; | |
1060 | open CONFIG_HEAVY, ">", $Config_heavy or die "Can't open $Config_heavy: $!\n"; | |
1061 | print CONFIG $config_txt; | |
1062 | print CONFIG_HEAVY $heavy_txt; | |
1063 | close(CONFIG_HEAVY); | |
1064 | close(CONFIG); | |
1065 | print "updated $Config_PM\n"; | |
1066 | print "updated $Config_heavy\n"; | |
1067 | } | |
1068 | ||
a0d0e21e | 1069 | |
18f68570 | 1070 | # Now create Cross.pm if needed |
5435c704 | 1071 | if ($Opts{cross}) { |
18f68570 | 1072 | open CROSS, ">lib/Cross.pm" or die "Can not open >lib/Cross.pm: $!"; |
47bcb90d VK |
1073 | my $cross = <<'EOS'; |
1074 | # typical invocation: | |
1075 | # perl -MCross Makefile.PL | |
1076 | # perl -MCross=wince -V:cc | |
1077 | package Cross; | |
1078 | ||
1079 | sub import { | |
1080 | my ($package,$platform) = @_; | |
1081 | unless (defined $platform) { | |
1082 | # if $platform is not specified, then use last one when | |
1083 | # 'configpm; was invoked with --cross option | |
1084 | $platform = '***replace-marker***'; | |
1085 | } | |
1086 | @INC = map {/\blib\b/?(do{local $_=$_;s/\blib\b/xlib\/$platform/;$_},$_):($_)} @INC; | |
e2a02c1e | 1087 | $::Cross::platform = $platform; |
18f68570 | 1088 | } |
47bcb90d | 1089 | |
18f68570 VK |
1090 | 1; |
1091 | EOS | |
5435c704 | 1092 | $cross =~ s/\*\*\*replace-marker\*\*\*/$Opts{cross}/g; |
47bcb90d | 1093 | print CROSS $cross; |
18f68570 | 1094 | close CROSS; |
962e59f3 | 1095 | print "written lib/Cross.pm\n"; |
42d1cefd | 1096 | unshift(@INC,"xlib/$Opts{cross}"); |
18f68570 VK |
1097 | } |
1098 | ||
a0d0e21e LW |
1099 | # Now do some simple tests on the Config.pm file we have created |
1100 | unshift(@INC,'lib'); | |
27da23d5 | 1101 | unshift(@INC,'xlib/symbian') if $Opts{cross}; |
5435c704 | 1102 | require $Config_PM; |
ae7e4cc1 | 1103 | require $Config_heavy; |
a0d0e21e LW |
1104 | import Config; |
1105 | ||
5435c704 | 1106 | die "$0: $Config_PM not valid" |
a02608de | 1107 | unless $Config{'PERL_CONFIG_SH'} eq 'true'; |
a0d0e21e | 1108 | |
5435c704 | 1109 | die "$0: error processing $Config_PM" |
a0d0e21e | 1110 | if defined($Config{'an impossible name'}) |
a02608de | 1111 | or $Config{'PERL_CONFIG_SH'} ne 'true' # test cache |
a0d0e21e LW |
1112 | ; |
1113 | ||
5435c704 | 1114 | die "$0: error processing $Config_PM" |
a0d0e21e LW |
1115 | if eval '$Config{"cc"} = 1' |
1116 | or eval 'delete $Config{"cc"}' | |
1117 | ; | |
1118 | ||
1119 | ||
85e6fe83 | 1120 | exit 0; |
a8e1d30b NC |
1121 | # Popularity of various entries in %Config, based on a large build and test |
1122 | # run of code in the Fotango build system: | |
1123 | __DATA__ | |
1124 | path_sep: 8490 | |
1125 | d_readlink: 7101 | |
1126 | d_symlink: 7101 | |
1127 | archlibexp: 4318 | |
1128 | sitearchexp: 4305 | |
1129 | sitelibexp: 4305 | |
1130 | privlibexp: 4163 | |
1131 | ldlibpthname: 4041 | |
1132 | libpth: 2134 | |
1133 | archname: 1591 | |
1134 | exe_ext: 1256 | |
1135 | scriptdir: 1155 | |
1136 | version: 1116 | |
1137 | useithreads: 1002 | |
1138 | osvers: 982 | |
1139 | osname: 851 | |
1140 | inc_version_list: 783 | |
1141 | dont_use_nlink: 779 | |
1142 | intsize: 759 | |
1143 | usevendorprefix: 642 | |
1144 | dlsrc: 624 | |
1145 | cc: 541 | |
1146 | lib_ext: 520 | |
1147 | so: 512 | |
1148 | ld: 501 | |
1149 | ccdlflags: 500 | |
1150 | ldflags: 495 | |
1151 | obj_ext: 495 | |
1152 | cccdlflags: 493 | |
1153 | lddlflags: 493 | |
1154 | ar: 492 | |
1155 | dlext: 492 | |
1156 | libc: 492 | |
1157 | ranlib: 492 | |
1158 | full_ar: 491 | |
1159 | vendorarchexp: 491 | |
1160 | vendorlibexp: 491 | |
1161 | installman1dir: 489 | |
1162 | installman3dir: 489 | |
1163 | installsitebin: 489 | |
1164 | installsiteman1dir: 489 | |
1165 | installsiteman3dir: 489 | |
1166 | installvendorman1dir: 489 | |
1167 | installvendorman3dir: 489 | |
1168 | d_flexfnam: 474 | |
1169 | eunicefix: 360 | |
1170 | d_link: 347 | |
1171 | installsitearch: 344 | |
1172 | installscript: 341 | |
1173 | installprivlib: 337 | |
1174 | binexp: 336 | |
1175 | installarchlib: 336 | |
1176 | installprefixexp: 336 | |
1177 | installsitelib: 336 | |
1178 | installstyle: 336 | |
1179 | installvendorarch: 336 | |
1180 | installvendorbin: 336 | |
1181 | installvendorlib: 336 | |
1182 | man1ext: 336 | |
1183 | man3ext: 336 | |
1184 | sh: 336 | |
1185 | siteprefixexp: 336 | |
1186 | installbin: 335 | |
1187 | usedl: 332 | |
1188 | ccflags: 285 | |
1189 | startperl: 232 | |
1190 | optimize: 231 | |
1191 | usemymalloc: 229 | |
1192 | cpprun: 228 | |
1193 | sharpbang: 228 | |
1194 | perllibs: 225 | |
1195 | usesfio: 224 | |
1196 | usethreads: 220 | |
1197 | perlpath: 218 | |
1198 | extensions: 217 | |
1199 | usesocks: 208 | |
1200 | shellflags: 198 | |
1201 | make: 191 | |
1202 | d_pwage: 189 | |
1203 | d_pwchange: 189 | |
1204 | d_pwclass: 189 | |
1205 | d_pwcomment: 189 | |
1206 | d_pwexpire: 189 | |
1207 | d_pwgecos: 189 | |
1208 | d_pwpasswd: 189 | |
1209 | d_pwquota: 189 | |
1210 | gccversion: 189 | |
1211 | libs: 186 | |
1212 | useshrplib: 186 | |
1213 | cppflags: 185 | |
1214 | ptrsize: 185 | |
1215 | shrpenv: 185 | |
1216 | static_ext: 185 | |
1217 | use5005threads: 185 | |
1218 | uselargefiles: 185 | |
1219 | alignbytes: 184 | |
1220 | byteorder: 184 | |
1221 | ccversion: 184 | |
1222 | config_args: 184 | |
1223 | cppminus: 184 |