--- configpm-pre	Sun Nov 28 07:48:14 2004
+++ configpm	Sat Sep  3 23:07:26 2005
@@ -475,51 +475,60 @@ sub launcher {
 1;
 ENDOFEND
 
-if ($^O eq 'os2') {
-    print CONFIG <<'ENDOFSET';
-my %preconfig;
-if ($OS2::is_aout) {
-    my ($value, $v) = $Config_SH_expanded =~ m/^used_aout='(.*)'\s*$/m;
-    for (split ' ', $value) {
-        ($v) = $Config_SH_expanded =~ m/^aout_$_='(.*)'\s*$/m;
-        $preconfig{$_} = $v eq 'undef' ? undef : $v;
+sub quote_pair ($$) {
+    my ($key, $value) = (shift, shift);
+    # Is it safe on the LHS of => ?
+    my $qkey = $key =~ /^[A-Za-z_][A-Za-z0-9_]*$/ ? $key : "'$key'";
+    if (defined $value) {
+	# Quote things for a '' string
+	$value =~ s!\\!\\\\!g;
+	$value =~ s!'!\\'!g;
+	$value = "'$value'";
+    } else {
+	$value = "undef";
     }
+    "$qkey => $value";
 }
-$preconfig{d_fork} = undef unless $OS2::can_fork; # Some funny cases can't
-sub TIEHASH { bless {%preconfig} }
-ENDOFSET
+
+my ($Extra, %Extra) = '';
+if ($^O eq 'os2') {
+    my $used_aout = fetch_string ({}, 'used_aout');
+    for my $k (split ' ', $used_aout) {
+        my ($v) = fetch_string ({}, "aout_$k");
+	$Extra{$k} = quote_pair($k, $v);
+    }
     # Extract the name of the DLL from the makefile to avoid duplication
     my ($f) = grep -r, qw(GNUMakefile Makefile);
-    my $dll;
+    my $dll = '';
     if (open my $fh, '<', $f) {
 	while (<$fh>) {
 	    $dll = $1, last if /^PERL_DLL_BASE\s*=\s*(\S*)\s*$/;
 	}
+	$dll = "    " . quote_pair(dll_name => $dll) . ",\n" if $dll;
     }
-    print CONFIG <<ENDOFSET if $dll;
-\$preconfig{dll_name} = '$dll';
-ENDOFSET
-} else {
-    print CONFIG <<'ENDOFSET';
+    my $fill_Extra = join '', map { "\t$_,\n" } sort values %Extra;
+    printf CONFIG <<'ENDOFPAT', $dll, $fill_Extra;
+my @Extra_aout;
+my @Extra = (
+    d_fork => $OS2::can_fork || undef, # Some funny cases can't
+%s);
+if ($OS2::is_aout) {
+    @Extra_aout = (
+%s    );
+}
+ENDOFPAT
+    $Extra = "    \@Extra, \@Extra_aout\n";
+}
+
+print CONFIG <<'ENDOFSET';
 sub TIEHASH {
     bless $_[1], $_[0];
 }
 ENDOFSET
-}
 
 foreach my $key (keys %Common) {
     my $value = fetch_string ({}, $key);
-    # Is it safe on the LHS of => ?
-    my $qkey = $key =~ /^[A-Za-z_][A-Za-z0-9_]*$/ ? $key : "'$key'";
-    if (defined $value) {
-	# Quote things for a '' string
-	$value =~ s!\\!\\\\!g;
-	$value =~ s!'!\\'!g;
-	$value = "'$value'";
-    } else {
-	$value = "undef";
-    }
-    $Common{$key} = "$qkey => $value";
+    $Common{$key} = quote_pair($key, $value);
 }
 
 if ($Common{byteorder}) {
@@ -527,7 +536,7 @@ if ($Common{byteorder}) {
 }
 my $fast_config = join '', map { "    $_,\n" } sort values %Common;
 
-print CONFIG sprintf <<'ENDOFTIE', $fast_config;
+print CONFIG sprintf <<'ENDOFTIE', $fast_config, $Extra;
 
 sub DESTROY { }
 
@@ -538,7 +547,7 @@ sub AUTOLOAD {
 }
 
 tie %%Config, 'Config', {
-%s};
+%s%s};
 
 1;
 ENDOFTIE
