From: Gurusamy Sarathy Date: Sun, 22 Oct 2000 11:47:32 +0000 (-0700) Subject: Expand %Config variables only if explicitly so requested X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e9c6cca7affc8f1a686236b954e87e5fa39d5127;p=p5sagit%2Fp5-mst-13.2.git Expand %Config variables only if explicitly so requested during build time by PERL_BUILD_EXPAND_CONFIG_VARS. Subject: Re: PATCH $Config::Config{ldlibpthname} in ext/DynaLoader/DynaLoader_pm.PL Message-Id: <200010221847.LAA02167@smtp3.ActiveState.com> p4raw-id: //depot/perl@7401 --- diff --git a/lib/lib_pm.PL b/lib/lib_pm.PL index bb02106..66b4944 100644 --- a/lib/lib_pm.PL +++ b/lib/lib_pm.PL @@ -8,10 +8,30 @@ chdir dirname($0); my $file = basename($0, '.PL'); $file =~ s!_(pm)$!.$1!i; -my $Config_archname = defined($Config{'archname'}) ? $Config{'archname'} : ''; -my $Config_ver = defined($Config{'version'}) ? $Config{'version'} : ''; -my @Config_inc_version_list = defined($Config{'inc_version_list'}) ? - reverse split / /, $Config{'inc_version_list'} : (); +my $useConfig; +my $Config_archname; +my $Config_version; +my $Config_inc_version_list; + +# Expand the variables only if explicitly requested because +# otherwise relocating Perl becomes much harder. + +if ($ENV{PERL_BUILD_EXPAND_CONFIG_VARS}) { + $useConfig = ''; + $Config_archname = qq('$Config{archname}'); + $Config_version = qq('$Config{version}'); + my @Config_inc_version_list = + reverse split / /, $Config{inc_version_list}; + $Config_inc_version_list = + @Config_inc_version_list ? + qq(@Config_inc_version_list) : q(()); +} else { + $useConfig = 'use Config;'; + $Config_archname = q($Config{archname}); + $Config_version = q($Config{version}); + $Config_inc_version_list = + q(reverse split / /, qw($Config{inc_version_list})); +} open OUT,">$file" or die "Can't create $file: $!"; @@ -26,9 +46,11 @@ package lib; # THIS FILE IS AUTOMATICALLY GENERATED FROM lib_pm.PL. # ANY CHANGES TO THIS FILE WILL BE OVERWRITTEN BY THE NEXT PERL BUILD. -my \$archname = "$Config_archname"; -my \$ver = "$Config_ver"; -my \@inc_version_list = qw(@Config_inc_version_list); +$useConfig + +my \$archname = $Config_archname; +my \$version = $Config_version; +my \@inc_version_list = $Config_inc_version_list; !GROK!THIS! print OUT <<'!NO!SUBS!'; @@ -57,9 +79,9 @@ sub import { } # Put a corresponding archlib directory infront of $_ if it # looks like $_ has an archlib directory below it. - unshift(@INC, "$_/$archname") if -d "$_/$archname/auto"; - unshift(@INC, "$_/$ver") if -d "$_/$ver"; - unshift(@INC, "$_/$ver/$archname") if -d "$_/$ver/$archname"; + unshift(@INC, "$_/$archname") if -d "$_/$archname/auto"; + unshift(@INC, "$_/$version") if -d "$_/$version"; + unshift(@INC, "$_/$version/$archname") if -d "$_/$version/$archname"; } # remove trailing duplicates @@ -74,9 +96,9 @@ sub unimport { my %names; foreach (@_) { ++$names{$_}; - ++$names{"$_/$archname"} if -d "$_/$archname/auto"; - ++$names{"$_/$ver"} if -d "$_/$ver"; - ++$names{"$_/$ver/$archname"} if -d "$_/$ver/$archname"; + ++$names{"$_/$archname"} if -d "$_/$archname/auto"; + ++$names{"$_/$version"} if -d "$_/$version"; + ++$names{"$_/$version/$archname"} if -d "$_/$version/$archname"; } # Remove ALL instances of each named directory.