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