From f0b0a4d296551cb3df320db39ea6327996961d9c Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Tue, 19 Jun 2012 16:50:47 +0200 Subject: Expand $^O at build time when generating Config::_V() Config::_V() is how perl -V is implemented internally, and is called called directly from the interpreter's switch passing routine. Hence the value of $^O at runtime will always be the same as the value of $^O at build time, so conditionals dependent on the value of $^O will always take the same execution path. So only generate the relevant code, and hence avoid shipping VMS and Cygwin specific code except on those platforms. (But add a sanity test in Config::_V() to ensure that the runtime $^O has the correct value - ie that the Perl code and the perl binary correspond.) --- configpm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'configpm') diff --git a/configpm b/configpm index ec81bfc8cf..6ea7419852 100755 --- a/configpm +++ b/configpm @@ -149,7 +149,10 @@ die "Can't automatically determine name for Config_heavy.pl from '$Config_PM'" my $config_txt; my $heavy_txt; -$heavy_txt .= sprintf <<'ENDOFBEG'; +my $from = $^O eq 'VMS' ? 'PERLSHR image' : 'binary (from libperl)'; +my $env_cygwin = $^O eq 'cygwin' + ? 'push @env, "CYGWIN=\"$ENV{CYGWIN}\"" if $ENV{CYGWIN};' . "\n" : ""; +$heavy_txt .= sprintf <<'ENDOFBEG', $^O, $^O, $from, $^O, $env_cygwin; # This file was created by configpm when Perl was built. Any changes # made to this file will be lost the next time perl is built. @@ -176,6 +179,9 @@ sub local_patches { } sub _V { + die "Perl lib was built for '%s' but is being run on '$^O'" + unless "%s" eq $^O; + my ($bincompat, $non_bincompat, $date, @patches) = Internals::V(); my $opts = join ' ', sort split ' ', "$bincompat $non_bincompat"; @@ -185,11 +191,7 @@ sub _V { $opts =~ s/(?=.{53})(.{1,53}) /$1\n /mg; print Config::myconfig(); - if ($^O eq 'VMS') { - print "\nCharacteristics of this PERLSHR image: \n"; - } else { - print "\nCharacteristics of this binary (from libperl): \n"; - } + print "\nCharacteristics of this %s: \n"; print " Compile-time options: $opts\n"; @@ -198,13 +200,12 @@ sub _V { print "\t$_\n" foreach @patches; } - print " Built under $^O\n"; + print " Built under %s\n"; print " $date\n" if defined $date; my @env = map { "$_=\"$ENV{$_}\"" } sort grep {/^PERL/} keys %%ENV; - push @env, "CYGWIN=\"$ENV{CYGWIN}\"" if $^O eq 'cygwin' and $ENV{CYGWIN}; - +%s if (@env) { print " \%%ENV:\n"; print " $_\n" foreach @env; -- cgit v1.2.1