+ push(@v_others, $line);
+ $seen_quotes{$quote}++;
+ }
+ close CONFIG_SH;
+}
+
+# This is somewhat grim, but I want the code for parsing config.sh here and
+# now so that I can expand $Config{ivsize} and $Config{ivtype}
+
+my $fetch_string = <<'EOT';
+
+# Search for it in the big string
+sub fetch_string {
+ my($self, $key) = @_;
+
+EOT
+
+if ($seen_quotes{'"'}) {
+ # We need the full ' and " code
+
+$fetch_string .= <<'EOT';
+ return undef unless my ($quote_type, $value) = $Config_SH_expanded =~ /\n$key=(['"])(.*?)\1\n/s;
+
+ # If we had a double-quote, we'd better eval it so escape
+ # sequences and such can be interpolated. Since the incoming
+ # value is supposed to follow shell rules and not perl rules,
+ # we escape any perl variable markers
+
+ # Historically, since " 'support' was added in change 1409, the
+ # interpolation was done before the undef. Stick to this arguably buggy
+ # behaviour as we're refactoring.
+ if ($quote_type eq '"') {
+ $value =~ s/\$/\\\$/g;
+ $value =~ s/\@/\\\@/g;
+ eval "\$value = \"$value\"";
+ }
+
+ # So we can say "if $Config{'foo'}".
+ $self->{$key} = $value eq 'undef' ? undef : $value; # cache it
+}
+EOT
+
+} else {
+ # We only have ' delimited.
+
+$fetch_string .= <<'EOT';
+ return undef unless $Config_SH_expanded =~ /\n$key=\'(.*?)\'\n/s;
+ # So we can say "if $Config{'foo'}".
+ $self->{$key} = $1 eq 'undef' ? undef : $1;
+}
+EOT
+
+}
+
+eval $fetch_string;
+die if $@;
+
+# Calculation for the keys for byteorder
+# This is somewhat grim, but I need to run fetch_string here.
+$Config_SH_expanded = join "\n", '', @v_others;
+
+my $t = fetch_string ({}, 'ivtype');
+my $s = fetch_string ({}, 'ivsize');
+
+# byteorder does exist on its own but we overlay a virtual
+# dynamically recomputed value.
+
+# However, ivtype and ivsize will not vary for sane fat binaries
+
+my $f = $t eq 'long' ? 'L!' : $s == 8 ? 'Q': 'I';
+
+my $byteorder_code;
+if ($s == 4 || $s == 8) {
+ my $list = join ',', reverse(1..$s-1);
+ my $format = 'a'x$s;
+ $byteorder_code = <<"EOT";
+
+my \$i = ord($s);
+foreach my \$c ($list) { \$i <<= 8; \$i |= ord(\$c); }
+our \$byteorder = join('', unpack('$format', pack('$f', \$i)));
+EOT
+} else {
+ $byteorder_code = "our \$byteorder = '?'x$s;\n";
+}
+
+my @need_relocation;
+
+if (fetch_string({},'userelocatableinc')) {
+ foreach my $what (qw(prefixexp
+
+ archlibexp
+ html1direxp
+ html3direxp
+ man1direxp
+ man3direxp
+ privlibexp
+ scriptdirexp
+ sitearchexp
+ sitebinexp
+ sitehtml1direxp
+ sitehtml3direxp
+ sitelibexp
+ siteman1direxp
+ siteman3direxp
+ sitescriptexp
+ vendorarchexp
+ vendorbinexp
+ vendorhtml1direxp
+ vendorhtml3direxp
+ vendorlibexp
+ vendorman1direxp
+ vendorman3direxp
+ vendorscriptexp
+
+ siteprefixexp
+ sitelib_stem
+ vendorlib_stem
+
+ installarchlib
+ installhtml1dir
+ installhtml3dir
+ installman1dir
+ installman3dir
+ installprefix
+ installprefixexp
+ installprivlib
+ installscript
+ installsitearch
+ installsitebin
+ installsitehtml1dir
+ installsitehtml3dir
+ installsitelib
+ installsiteman1dir
+ installsiteman3dir
+ installsitescript
+ installvendorarch
+ installvendorbin
+ installvendorhtml1dir
+ installvendorhtml3dir
+ installvendorlib
+ installvendorman1dir
+ installvendorman3dir
+ installvendorscript
+ )) {
+ push @need_relocation, $what if fetch_string({}, $what) =~ m!^\.\.\./!;