--- ./makedef.pl.orig	Tue Sep  9 08:48:18 2003
+++ ./makedef.pl	Wed Oct 29 01:01:54 2003
@@ -378,6 +378,8 @@ elsif ($PLATFORM eq 'os2') {
 		    dlsym
 		    dlerror
 		    dlclose
+		    dup2
+		    dup
 		    my_tmpfile
 		    my_tmpnam
 		    my_flock
@@ -1340,7 +1342,10 @@ foreach my $symbol (sort keys %export) {
 }
 
 if ($PLATFORM eq 'os2') {
-	print "; LAST_ORDINAL=$sym_ord\n";
+	print <<EOP;
+    dll_perlmain=main
+; LAST_ORDINAL=$sym_ord
+EOP
 }
 
 sub emit_symbol {
--- ./perlio.c.orig	Tue Oct 21 12:52:06 2003
+++ ./perlio.c	Wed Oct 29 00:47:52 2003
@@ -2875,6 +2875,10 @@ PerlIOStdio_invalidate_fileno(pTHX_ FILE
      */
     f->_file = -1;
     return 1;
+#  elif defined(__EMX__)
+    /* f->_flags &= ~_IOOPEN; */	/* Will leak stream->_buffer */
+    f->_handle = -1;
+    return 1;
 #  elif defined(__CYGWIN__)
     /* There may be a better way on CYGWIN:
         - we could insert a dummy func in the _close function entry
--- ./ext/DynaLoader/DynaLoader_pm.PL.orig	Sat Sep 13 10:26:32 2003
+++ ./ext/DynaLoader/DynaLoader_pm.PL	Tue Oct 28 20:19:36 2003
@@ -229,6 +229,9 @@ sub bootstrap {
 	"  dynamic loading or has the $module module statically linked into it.)\n")
 	unless defined(&dl_load_file);
 
+    # Can dynaload, but cannot dynaload Perl modules...
+    die 'Dynaloaded Perl modules are not available in this build of Perl' if $OS2::is_aout;
+
     my @modparts = split(/::/,$module);
     my $modfname = $modparts[-1];
 
--- ./ext/DynaLoader/XSLoader_pm.PL.orig	Sat Aug 30 00:26:12 2003
+++ ./ext/DynaLoader/XSLoader_pm.PL	Tue Oct 28 20:19:52 2003
@@ -44,6 +44,8 @@ sub load {
     my $b = "$module\::bootstrap";
     goto &$b if defined &$b;
 
+    # Can dynaload, but cannot dynaload Perl modules...
+    die 'Dynaloaded Perl modules are not available in this build of Perl' if $OS2::is_aout;
     goto retry unless $module and defined &dl_load_file;
 
     my @modparts = split(/::/,$module);
--- ./lib/perl5db.pl.orig	Fri Jul 25 00:22:40 2003
+++ ./lib/perl5db.pl	Tue Oct 28 20:08:16 2003
@@ -1498,7 +1498,7 @@ Console> if not. (Note that Mac OS X ret
 
 Several other systems don't use a specific console. We C<undef $console>
 for those (Windows using a slave editor/graphical debugger, NetWare, OS/2
-with a slave editor, Epoc).
+with a slave editor or xterm, Epoc).
 
 =cut
 
@@ -1512,10 +1512,8 @@ with a slave editor, Epoc).
         $console = undef;
     }
 
-    # In OS/2, we need to use STDIN to get textmode too, even though
-    # it pretty much looks like Unix otherwise.
-    if (defined $ENV{OS2_SHELL} and ($slave_editor or $ENV{WINDOWID}))
-    {    # In OS/2
+    if ($^O eq 'os2' and ($slave_editor or $ENV{WINDOWID}))
+    {    # uncomplete support of /dev/con on xterm and other X terminals
         $console = undef;
     }
     # EPOC also falls into the 'got to use STDIN' camp.
@@ -2054,6 +2052,8 @@ the new command. This is faster, but per
             # No signal is active.
             $signal = 0;
 
+	    $cmd =~ s/\r+\z//;	# Remove spurious \r due to wrong binmode...
+
             # Handle continued commands (ending with \):
             $cmd =~ s/\\$/\n/ && do {
                 $cmd .= &readline("  cont: ");
@@ -2397,7 +2397,10 @@ above the current one and then displays 
                     eval { require PadWalker; PadWalker->VERSION(0.08) }
                       or &warn(
                         $@ =~ /locate/
-                        ? "PadWalker module not found - please install\n"
+                        ? <<EOM
+PadWalker module not found - please install; try the command
+  perl -MCPAN -e "install PadWalker"
+EOM
                         : $@
                       )
                       and next CMD;
@@ -5788,69 +5791,70 @@ qq[3>&1 xterm -title "Daughter Perl debu
 
 XXX It behooves an OS/2 expert to write the necessary documentation for this!
 
+Starts a separate session (so a new console) with a kid Perl program; this
+program mirrors user's input of this session to one filehandle ($out), and
+displays data coming through $in filehandle.
+
+Since this kid program should not be debugged, we massage C<PERL5OPT>
+and C<PERL5LIB> environment variables to make the kid as reliable as possible.
+
+B<LIMITATIONS>: with the current logic the kid should inherit the filehandles
+created by pipe() calls; this we can't start it with C<P_INDEPENDENT> flag.
+However, in any session only one process can start a new session without
+this flag; thus only one window per session can be created.  (To fix this,
+one should communicate via named pipes or sockets...)
+
+Since the depended-sessions are killed when a parent terminates, the kids
+print C<Process terminated by SIGKILL> (?) messages; they are visible for a
+moment before the session closes.
+
 =cut
 
 # This example function resets $IN, $OUT itself
 sub os2_get_fork_TTY {
-    local $^F = 40;     # XXXX Fixme!
-    local $\  = '';
-    my ($in1, $out1, $in2, $out2);
-
     # Having -d in PERL5OPT would lead to a disaster...
     local $ENV{PERL5OPT} = $ENV{PERL5OPT} if $ENV{PERL5OPT};
     $ENV{PERL5OPT} =~ s/(?:^|(?<=\s))-d\b//  if $ENV{PERL5OPT};
     $ENV{PERL5OPT} =~ s/(?:^|(?<=\s))-d\B/-/ if $ENV{PERL5OPT};
     print $OUT "Making kid PERL5OPT->`$ENV{PERL5OPT}'.\n" if $ENV{PERL5OPT};
+
+    # Propagate libraries
     local $ENV{PERL5LIB} = $ENV{PERL5LIB} ? $ENV{PERL5LIB} : $ENV{PERLLIB};
     $ENV{PERL5LIB} = '' unless defined $ENV{PERL5LIB};
-    $ENV{PERL5LIB} = join ';', @ini_INC, split /;/, $ENV{PERL5LIB};
+    $ENV{PERL5LIB} = join ';', @INC, @ini_INC, split /;/, $ENV{PERL5LIB};
+
     (my $name = $0) =~ s,^.*[/\\],,s;
-    my @args;
 
-    if (
-            pipe $in1, $out1
-        and pipe $in2, $out2
-
-        # system P_SESSION will fail if there is another process
-        # in the same session with a "dependent" asynchronous child session.
-        and @args = (
-            $rl, fileno $in1, fileno $out2,
-            "Daughter Perl debugger $pids $name"
-        )
-        and (
-            ($kpid = CORE::system 4, $^X, '-we',
-                <<'ES', @args) >= 0    # P_SESSION
-END {sleep 5 unless $loaded}
-BEGIN {open STDIN,  '</dev/con' or warn "reopen stdin: $!"}
-use OS2::Process;
-
-my ($rl, $in) = (shift, shift);        # Read from $in and pass through
-set_title pop;
-system P_NOWAIT, $^X, '-we', <<EOS or die "Cannot start a grandkid";
-  open IN, '<&=$in' or die "open <&=$in: \$!";
-  \$| = 1; print while sysread IN, \$_, 1<<16;
+    # What follows until <<<<< is mostly almost exactly
+    #  require OS2::Process; my ($in, $out, $pid) = OS2::Process::io_term @args
+    local $^F = 40;     # XXXX Fixme!
+    local $\  = '';
+    my ($in1, $out1, $in2, $out2);
+
+    pipe $in1, $out1 or return;
+    pipe $in2, $out2 or do { close($in1), close($out1), return };
+
+    # system P_SESSION=4 will fail if there is another process
+    # in the same session with a "dependent" asynchronous child session.
+    my @args = (($rl ? (read_by_key => 1) : ()),
+		# scrsize => '40,50',
+		title => "Daughter Perl debugger $pids $name");
+    my $kpid = system 4, $^X, '-we', <<'EOS', fileno $in1, fileno $out2, @args;
+       END {sleep($sleep || 5)}
+       use OS2::Process; $sleep = 1;
+       OS2::Process::__term_mirror(@ARGV);
 EOS
+    close $in1 or warn;
+    close $out2 or warn;
+    warn "system P_SESSION, $^X: $!, $^E" and do { close($in2), close($out1), return }
+      unless $kpid > 0;
+    # <<<<<<<<<<<<<
 
-my $out = shift;
-open OUT, ">&=$out" or die "Cannot open &=$out for writing: $!";
-select OUT;    $| = 1;
-require Term::ReadKey if $rl;
-Term::ReadKey::ReadMode(4) if $rl; # Nodelay on kbd.  Pipe is automatically nodelay...
-print while sysread STDIN, $_, 1<<($rl ? 16 : 0);
-ES
-            or warn "system P_SESSION: $!, $^E" and 0
-        )
-        and close $in1
-        and close $out2
-      )
-    {
-        $pidprompt = '';    # Shown anyway in titlebar
-        reset_IN_OUT($in2, $out1);
-        $tty = '*reset*';
-        return '';          # Indicate that reset_IN_OUT is called
-    } ## end if (pipe $in1, $out1 and...
-    return;
-} ## end sub os2_get_fork_TTY
+    $pidprompt = '';    # Shown anyway in titlebar
+    reset_IN_OUT($in2, $out1);
+    $tty = '*reset*';
+    return '';          # Indicate that reset_IN_OUT is called
+}
 
 =head2 C<create_IN_OUT($flags)>
 
@@ -6763,8 +6767,8 @@ B<m> I<expr>		Evals expression in list c
 		on the first element of the result.
 B<m> I<class>		Prints methods callable via the given class.
 B<M>		Show versions of loaded modules.
-B<y> [I<n> [I<Vars>]]   List lexicals in higher scope <n>.  Vars same as B<V>.
-
+B<y> [I<n> [I<Vars>]]    List lexicals in higher scope <n>.  Vars same as B<V>.
+		Requires the module B<PadWalker>.
 B<<> ?			List Perl commands to run before each prompt.
 B<<> I<expr>		Define Perl command to run before each prompt.
 B<<<> I<expr>		Add to the list of Perl commands to run before each prompt.
@@ -6801,7 +6805,7 @@ B<R>		Pure-man-restart of debugger, some
 		and command-line options may be lost.
 		Currently the following settings are preserved:
 		history, breakpoints and actions, debugger B<O>ptions 
-		and the following command-line options: I<-w>, I<-I>, I<-e>.
+		and the following command-line options: I<-w>, I<-I>, I<-T>, I<-e>.
 
 B<o> [I<opt>] ...	Set boolean option to true
 B<o> [I<opt>B<?>]	Query options
@@ -6869,12 +6873,11 @@ I<Debugger controls:>                   
   B<|>[B<|>]I<db_cmd>  Send output to pager        B<$psh>\[B<$psh>\] I<syscmd> Run cmd in a subprocess
   B<q> or B<^D>     Quit                        B<R>           Attempt a restart
 I<Data Examination:>     B<expr>     Execute perl code, also see: B<s>,B<n>,B<t> I<expr>
-  B<x>|B<m> I<expr>       Evals expr in list context, dumps the result or lists methods.
-  B<p> I<expr>         Print expression (uses script's current package).
-  B<S> [[B<!>]I<pat>]     List subroutine names [not] matching pattern
-  B<V> [I<Pk> [I<Vars>]]  List Variables in Package.  Vars can be ~pattern or !pattern.
-  B<X> [I<Vars>]       Same as \"B<V> I<current_package> [I<Vars>]\".
-  B<y> [I<n> [I<Vars>]]   List lexicals in higher scope <n>.  Vars same as B<V>.
+  B<x>|B<m> I<expr>     Evals I<expr> in list context, dumps the result or lists methods.
+  B<p> I<expr>       Print expression I<expr> (uses script's current package).
+  B<S> [[B<!>]I<pat>]   List subroutine names [not] matching pattern I<pat>.
+  B<X> [I<Vars>]     List Variables in current package.  I<Vars> can be ~pattern or !pat
+  B<V> [I<Pk> [I<Vars>]] Same as B<X> for package I<Pk>.  Type B<h y> for access to lexicals.
 For more help, type B<h> I<cmd_letter>, or run B<$doccmd perldebug> for all docs.
 END_SUM
 
--- ./lib/ExtUtils/MakeMaker.pm.orig	Sun Oct 19 13:10:18 2003
+++ ./lib/ExtUtils/MakeMaker.pm	Tue Oct 28 20:09:02 2003
@@ -618,15 +618,15 @@ sub WriteEmptyMakefile {
 
     my %att = @_;
     my $self = MM->new(\%att);
-    if (-f $self->{MAKEFILE_OLD}) {
-      _unlink($self->{MAKEFILE_OLD}) or 
-        warn "unlink $self->{MAKEFILE_OLD}: $!";
-    }
-    if ( -f $self->{MAKEFILE} ) {
-        _rename($self->{MAKEFILE}, $self->{MAKEFILE_OLD}) or
-          warn "rename $self->{MAKEFILE} => $self->{MAKEFILE_OLD}: $!"
+    my $new = $self->{FIRST_MAKEFILE};
+    my $old = $self->{MAKEFILE_OLD};
+    if (-f $old) {
+      _unlink($old) or warn "unlink $old: $!";
     }
-    open MF, '>'.$self->{MAKEFILE} or die "open $self->{MAKEFILE} for write: $!";
+    if ( -f $new ) {
+        _rename($new, $old) or warn "rename $new => $old: $!"
+    }
+    open MF, '>'.$new or die "open $new for write: $!";
     print MF <<'EOP';
 all:
 
@@ -639,7 +639,7 @@ makemakerdflt:
 test:
 
 EOP
-    close MF or die "close $self->{MAKEFILE} for write: $!";
+    close MF or die "close $new for write: $!";
 }
 
 sub check_manifest {
@@ -864,9 +864,10 @@ sub flush {
     my $self = shift;
     my($chunk);
     local *FH;
-    print STDOUT "Writing $self->{MAKEFILE} for $self->{NAME}\n";
+    my($finalname) = $self->{FIRST_MAKEFILE};
+    print STDOUT "Writing $finalname for $self->{NAME}\n";
 
-    unlink($self->{MAKEFILE}, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
+    unlink($finalname, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : ());
     open(FH,">MakeMaker.tmp") or die "Unable to open MakeMaker.tmp: $!";
 
     for $chunk (@{$self->{RESULT}}) {
@@ -874,7 +875,6 @@ sub flush {
     }
 
     close FH;
-    my($finalname) = $self->{MAKEFILE};
     _rename("MakeMaker.tmp", $finalname) or
       warn "rename MakeMaker.tmp => $finalname: $!";
     chmod 0644, $finalname unless $Is_VMS;
--- ./lib/ExtUtils/MM_Unix.pm.orig	Sun Oct 19 13:10:18 2003
+++ ./lib/ExtUtils/MM_Unix.pm	Tue Oct 28 20:16:48 2003
@@ -3076,6 +3076,7 @@ sub parse_version {
     my $result;
     local *FH;
     local $/ = "\n";
+    local $_;
     open(FH,$parsefile) or die "Could not open '$parsefile': $!";
     my $inpod = 0;
     while (<FH>) {
--- ./lib/File/Path.pm.orig	Wed Aug 13 23:52:38 2003
+++ ./lib/File/Path.pm	Tue Oct 28 20:07:28 2003
@@ -157,7 +157,8 @@ sub mkpath {
  	}
 	print "mkdir $path\n" if $verbose;
 	unless (mkdir($path,$mode)) {
-	    my $e = $!;
+	    my ($e, $e1) = ($!, $^E);
+	    $e .= "; $e1" if $e ne $e1;
 	    # allow for another process to have created it meanwhile
 	    croak "mkdir $path: $e" unless -d $path;
 	}
--- ./os2/Makefile.SHs.orig	Mon Mar 31 22:23:12 2003
+++ ./os2/Makefile.SHs	Tue Oct 28 23:08:00 2003
@@ -43,7 +43,7 @@ AOUT_CLDFLAGS_DLL	= -Zexe -Zmt -Zcrtdll 
 SO_CCCMD	= \$(CC) $ccflags \$(OPTIMIZE)
 
 LD_OPT		= \$(OPTIMIZE)
-PERL_DLL_LD_OPT = -Zmap -Zlinker /map
+PERL_DLL_LD_OPT = -Zmap -Zlinker /map/li
 
 PERL_DLL_BASE	= perl$dll_post
 PERL_DLL	= \$(PERL_DLL_BASE)\$(DLSUFFIX)
@@ -55,11 +55,15 @@ AOUT_EXTRA_LIBS	= $aout_extra_libs
 
 $spitshell >>Makefile <<'!NO!SUBS!'
 PREPLIBRARY_LIBPERL = $(LIBPERL)
-$(LIBPERL): perl.imp $(PERL_DLL) perl5.def libperl_override.lib
+$(LIBPERL): perl.imp perl5.def libperl_override.lib
 	emximp -o $(LIBPERL) perl.imp
 	cp $(LIBPERL) perl.lib
 
-libperl_override.imp: os2/os2add.sym miniperl
+imp_version: $(FIRSTMAKEFILE)
+	echo $(PERL_DLL_BASE) > imp_version.tmp
+	sh mv-if-diff imp_version.tmp $@
+
+libperl_override.imp: os2/os2add.sym miniperl imp_version
 	./miniperl -wnle 'print "$$_\t$(PERL_DLL_BASE)\t$$_\t?"' os2/os2add.sym > tmp.imp
 	echo	'strdup	$(PERL_DLL_BASE)	Perl_strdup	?' >> tmp.imp
 	echo	'putenv	$(PERL_DLL_BASE)	Perl_putenv	?' >> tmp.imp
@@ -68,10 +72,20 @@ libperl_override.imp: os2/os2add.sym min
 libperl_override.lib: libperl_override.imp
 	emximp -o $@ libperl_override.imp
 
+libperl_dllmain.imp: imp_version
+	echo	'main	$(PERL_DLL_BASE)	dll_perlmain	?' >> tmpdll.imp
+	sh mv-if-diff tmpdll.imp $@
+
+libperl_dllmain.lib: libperl_dllmain.imp
+	emximp -o $@ libperl_dllmain.imp
+
+libperl_dllmain.a: libperl_dllmain.imp
+	emximp -o $@ libperl_dllmain.imp
+
 $(AOUT_LIBPERL_DLL): perl.imp $(PERL_DLL) perl5.def
 	emximp -o $(AOUT_LIBPERL_DLL) perl.imp
 
-perl.imp: perl5.def
+perl.imp: perl5.def imp_version
 	emximp -o perl.imp perl5.def
 	echo	'emx_calloc		emxlibcm	400	?' >> $@
 	echo	'emx_free		emxlibcm	401	?' >> $@
@@ -82,7 +96,8 @@ perl.imp: perl5.def
 	perlrexx test_prep_perl_ test_prep_perl_sys test_prep_perl_stat \
 	test_prep_perl_stat_aout test_prep_various \
 	stat_aout_harness aout_harness stat_harness sys_harness all_harness \
-	stat_aout_test aout_test stat_test sys_test all_test
+	stat_aout_test aout_test stat_test sys_test all_test \
+	perl___harness test_harness_redir
 
 perl_dll: $(PERL_DLL)
 
@@ -91,8 +106,8 @@ perl_dll_t: t/$(PERL_DLL)
 t/$(PERL_DLL): $(PERL_DLL)
 	$(LNS) $(PERL_DLL) t/$(PERL_DLL)
 
-$(PERL_DLL): $(obj) perl5.def perl$(OBJ_EXT)
-	$(LD) $(LD_OPT) $(LDDLFLAGS) $(PERL_DLL_LD_OPT) -o $@ perl$(OBJ_EXT) $(obj) $(libs) perl5.def || ( rm $(PERL_DLL) && sh -c false )
+$(PERL_DLL): $(obj) perl5.def perl$(OBJ_EXT) perlmain$(OBJ_EXT) $(DYNALOADER)
+	$(LD) $(LD_OPT) $(LDDLFLAGS) $(PERL_DLL_LD_OPT) -o $@ perl$(OBJ_EXT) $(obj) perlmain$(OBJ_EXT) $(DYNALOADER) $(libs) perl5.def || ( rm $(PERL_DLL) && sh -c false )
 
 perl5.olddef: perl.linkexp
 	echo "LIBRARY '$(PERL_DLL_BASE)' INITINSTANCE TERMINSTANCE"	> $@
@@ -155,9 +170,16 @@ dlfcn.h: os2/dlfcn.h
 	cp -f $< $@
 
 # Non-Forking dynamically loaded perl
+# Make many: they are useful in low-memory conditions (floppy boot?  Lot of shared memory used?)
 
-perl___$(EXE_EXT) perl___: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
-	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl___ perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs) -Zlinker /map/PM:VIO
+perl___$(EXE_EXT) perl___: $& libperl_dllmain$(LIB_EXT)
+	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl___ libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
+	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 8192 -o perl___8 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
+	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 4096 -o perl___4 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
+	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 2048 -o perl___2 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
+	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 1024 -o perl___1 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
+	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 512 -o perl___05 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
+	$(SHRPENV) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -Zstack 320 -o perl___03 libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
 
 # This one is compiled -Zsys, so cannot do many things:
 
@@ -166,16 +188,16 @@ STAT_CLDFLAGS = -Zexe -Zomf -Zmt -Zstack
 
 # Non-forking dynamically loaded perl with a wrong CRT library:
 
-perl_stat: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
-	$(SHRPENV) $(CC) $(STAT_CLDFLAGS) $(CCDLFLAGS) -o $@ perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs) -Zlinker /map/PM:VIO
+perl_stat perl_stat$(EXE_EXT): $& libperl_dllmain$(LIB_EXT)
+	$(SHRPENV) $(CC) $(STAT_CLDFLAGS) $(CCDLFLAGS) -o perl_stat libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
 
 # Remove -Zcrtdll, add -Zsys
 SYS_CLDFLAGS = $(STAT_CLDFLAGS) -Zsys
 
 # Non-Forking dynamically loaded perl without EMX - so with wrong CRT library
 
-perl_sys: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
-	$(SHRPENV) $(CC) $(SYS_CLDFLAGS) $(CCDLFLAGS) -o $@ perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs) -Zlinker /map/PM:VIO
+perl_sys perl_sys$(EXE_EXT): $& libperl_dllmain$(LIB_EXT)
+	$(SHRPENV) $(CC) $(SYS_CLDFLAGS) $(CCDLFLAGS) -o perl_sys libperl_dllmain$(LIB_EXT) -Zlinker /map/PM:VIO
 
 installcmd : 
 	@perl -e 'die qq{Give the option INSTALLCMDDIR=... to make!} if $$ARGV[0] eq ""' $(INSTALLCMDDIR)
@@ -203,7 +225,7 @@ $(DYNALOADER_OBJ) : $(DYNALOADER)
 $(AOUT_LIBPERL) : $(aout_obj) perl$(AOUT_OBJ_EXT)
 	rm -f $@
 	$(AOUT_AR) rcu $@ perl$(AOUT_OBJ_EXT) $(aout_obj)
-	cp $@ perl.a
+	cp $@ perl$(AOUT_LIB_EXT)
 
 .c$(AOUT_OBJ_EXT):
 	$(AOUT_CCCMD) $(PLDLFLAGS) -c $*.c
@@ -214,9 +236,14 @@ opmini$(AOUT_OBJ_EXT): op.c
 perlmain(AOUT_OBJ_EXT): perlmain.c
 	$(AOUT_CCCMD_DLL) $(PLDLFLAGS) -c perlmain.c
 
-aout_perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit)
-	sh writemain $(DYNALOADER) $(aout_static_lib) > tmp
-	sh mv-if-diff tmp aout_perlmain.c
+# Assume that extensions are at most 4 deep (this is so with 5.8.1)
+aout_extlist: $(aout_static_ext)
+	echo lib/auto/*.a lib/auto/*/*.a lib/auto/*/*/*.a lib/auto/*/*/*/*.a | tr ' ' '\n' | grep -v '\*' > $@.tmp
+	sh mv-if-diff $@.tmp $@
+
+aout_perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit) $(aout_static_ext) writemain aout_extlist
+	sh writemain `cat aout_extlist` > aout_perlmain.tmp
+	sh mv-if-diff aout_perlmain.tmp aout_perlmain.c
 
 _preplibrary = miniperl lib/Config.pm lib/lib.pm lib/re.pm
 
@@ -228,35 +255,35 @@ miniperl_: $& miniperlmain$(AOUT_OBJ_EXT
 # Need a miniperl_ dependency, since $(AOUT_DYNALOADER) is build via implicit
 # rules, thus would not rebuild miniperl_ via an explicit rule
 
-perl_$(EXE_EXT) perl_: $& miniperl_ aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(AOUT_DYNALOADER) $(aout_static_ext) ext.libs
-	$(CC) $(AOUT_CLDFLAGS) $(CCDLFLAGS) -o perl_ aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER) $(aout_static_ext) $(AOUT_LIBPERL) `cat ext.libs` $(libs)
+perl_$(EXE_EXT) perl_: $& miniperl_ aout_perlmain$(AOUT_OBJ_EXT) $(AOUT_LIBPERL) $(AOUT_DYNALOADER) $(aout_static_ext) ext.libs aout_extlist
+	$(CC) $(AOUT_CLDFLAGS) $(CCDLFLAGS) $(OPTIMIZE) -o perl_ aout_perlmain$(AOUT_OBJ_EXT) `cat aout_extlist` $(AOUT_LIBPERL) `cat ext.libs` $(libs)
 
 # Remove -Zcrtdll
 STAT_AOUT_CLDFLAGS = -Zexe -Zmt -Zstack 32000
 
 # Forking dynamically loaded perl with a wrong CRT library:
 
-perl_stat_aout$(EXE_EXT) perl_stat_aout: $& perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER_OBJ) $(aout_static_ext_dll) $(AOUT_LIBPERL_DLL) ext.libs
-	$(SHRPENV) $(CC) $(STAT_AOUT_CLDFLAGS) $(CCDLFLAGS) -o $@ perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER_OBJ) $(aout_static_ext_dll) $(AOUT_LIBPERL_DLL) `cat ext.libs` $(libs)
+perl_stat_aout$(EXE_EXT) perl_stat_aout: $& libperl_dllmain$(AOUT_LIB_EXT)
+	$(SHRPENV) $(CC) $(STAT_AOUT_CLDFLAGS) $(CCDLFLAGS) $(OPTIMIZE) -o perl_stat_aout libperl_dllmain$(AOUT_LIB_EXT)
 
 PERLREXX_DLL = perlrexx.dll
 
-perl : perl__ perl___ $(PERLREXX_DLL)
+perl perl$(EXE_EXT) : perl__ perl___ $(PERLREXX_DLL) $(PERL_DLL)
 
 # Dynamically loaded PM-application perl:
 
-perl__$(EXE_EXT) perl__: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs
-	$(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl__ perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LIBPERL) `cat ext.libs` $(libs) -Zlinker /PM:PM
+perl__$(EXE_EXT) perl__: $& libperl_dllmain$(LIB_EXT)
+	$(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl__ libperl_dllmain$(LIB_EXT) -Zlinker /PM:PM
 
 # Forking dynamically loaded perl:
 
-perl$(EXE_EXT) perl: $& perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER_OBJ) $(aout_static_ext_dll) $(AOUT_LIBPERL_DLL) ext.libs
-	$(CC) $(AOUT_CLDFLAGS_DLL) $(CCDLFLAGS) -o perl perlmain$(AOUT_OBJ_EXT) $(AOUT_DYNALOADER_OBJ) $(aout_static_ext_dll) $(AOUT_LIBPERL_DLL) `cat ext.libs` $(libs)
+perl$(EXE_EXT) perl: $& libperl_dllmain$(AOUT_LIB_EXT)
+	$(CC) $(AOUT_CLDFLAGS_DLL) $(CCDLFLAGS) -o perl libperl_dllmain$(AOUT_LIB_EXT)
 
 clean: aout_clean
 
 aout_clean:
-	-rm *perl_.* *.o *.a lib/auto/*/*.a ext/*/Makefile.aout
+	-rm *perl_.* *.o *.a lib/auto/*/*.a lib/auto/*/*/*.a lib/auto/*/*/*/*.a ext/*/Makefile.aout ext/*/*/Makefile.aout  ext/*/*/*/Makefile.aout
 
 aout_install: perl_ aout_install.perl
 
@@ -351,7 +378,10 @@ perl___harness: test_prep_perl___
 
 all_test: test aout_test perl___test sys_test stat_test stat_aout_test
 
-all_harness: test_harness aout_harness perl___harness sys_harness stat_harness stat_aout_harness
+test_harness_redir: test_prep
+	-PERL=./perl $(MAKE) TESTFILE=harness _test $(REDIR_TEST)
+
+all_harness: test_harness_redir aout_harness perl___harness sys_harness stat_harness stat_aout_harness
 
 !NO!SUBS!
 
@@ -385,7 +415,7 @@ do
 		else
 		    # Need to treat subsubdirectories manually
 		    dd_treated=''
-		    for ddd in $dd/*
+		    for ddd in $dd/*		# ext/*/*/*/Makefile.PL
 		    do
 			if test ! -d $ddd; then
 			    continue
@@ -403,6 +433,12 @@ do
 	   done
 	fi
 done
+
+# ext/threads is marked as NORECURS, so we need to specialcase it
+if echo "$static_ext $dynamic_ext" | grep -q threads/shared ; then
+   preci="$preci ext/threads/%/Makefile.aout"
+   dirs="$dirs ext/threads"
+fi
 
 $spitshell >>Makefile <<!GROK!THIS!
 .PRECIOUS : $preci
--- ./os2/os2.c.orig	Thu Sep 18 23:26:44 2003
+++ ./os2/os2.c	Wed Oct 29 01:00:34 2003
@@ -620,6 +620,8 @@ static const struct {
   {&pmwin_handle, NULL, 780},		/* WinLoadPointer */
   {&pmwin_handle, NULL, 828},		/* WinQuerySysPointer */
   {&doscalls_handle, NULL, 417},	/* DosReplaceModule */
+  {&doscalls_handle, NULL, 976},	/* DosPerfSysCall */
+  {&rexxapi_handle, "RexxRegisterSubcomExe", 0},
 };
 
 HMODULE
@@ -759,15 +761,17 @@ get_sysinfo(ULONG pid, ULONG flags)
     ULONG rc, buf_len = QSS_INI_BUFFER;
     PQTOPLEVEL psi;
 
-    if (!pidtid_lookup) {
-	pidtid_lookup = 1;
-	*(PFN*)&pDosVerifyPidTid = loadByOrdinal(ORD_DosVerifyPidTid, 0);
-    }
-    if (pDosVerifyPidTid) {	/* Warp3 or later */
-	/* Up to some fixpak QuerySysState() kills the system if a non-existent
-	   pid is used. */
-	if (CheckOSError(pDosVerifyPidTid(pid, 1)))
-	    return 0;
+    if (pid) {
+	if (!pidtid_lookup) {
+	    pidtid_lookup = 1;
+	    *(PFN*)&pDosVerifyPidTid = loadByOrdinal(ORD_DosVerifyPidTid, 0);
+	}
+	if (pDosVerifyPidTid) {	/* Warp3 or later */
+	    /* Up to some fixpak QuerySysState() kills the system if a non-existent
+	       pid is used. */
+	    if (CheckOSError(pDosVerifyPidTid(pid, 1)))
+		return 0;
+        }
     }
     New(1322, pbuffer, buf_len, char);
     /* QSS_PROCESS | QSS_MODULE | QSS_SEMAPHORES | QSS_SHARED */
@@ -1127,7 +1131,7 @@ do_spawn_ve(pTHX_ SV *really, U32 flag, 
 			   does not append ".exe", so we could have
 			   reached this place). */
 			sv_catpv(scrsv, ".exe");
-	                scr = SvPV(scrsv, n_a);	/* Reload */
+	                PL_Argv[0] = scr = SvPV(scrsv, n_a);	/* Reload */
 			if (PerlLIO_stat(scr,&PL_statbuf) >= 0
 			    && !S_ISDIR(PL_statbuf.st_mode)) {	/* Found */
 				real_name = scr;
@@ -1851,6 +1855,109 @@ XS(XS_OS2_replaceModule)
     XSRETURN_EMPTY;
 }
 
+/* APIRET APIENTRY DosPerfSysCall(ULONG ulCommand, ULONG ulParm1,
+                                  ULONG ulParm2, ULONG ulParm3); */
+
+DeclOSFuncByORD(ULONG,perfSysCall,ORD_DosPerfSysCall,
+		(ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3),
+		(ulCommand, ulParm1, ulParm2, ulParm3))
+
+#ifndef CMD_KI_RDCNT
+#  define CMD_KI_RDCNT	0x63
+#endif
+#ifndef CMD_KI_GETQTY
+#  define CMD_KI_GETQTY 0x41
+#endif
+#ifndef QSV_NUMPROCESSORS
+#  define QSV_NUMPROCESSORS         26
+#endif
+
+typedef unsigned long long myCPUUTIL[4];	/* time/idle/busy/intr */
+
+/*
+NO_OUTPUT ULONG
+perfSysCall(ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3)
+    PREINIT:
+	ULONG rc;
+    POSTCALL:
+	if (!RETVAL)
+	    croak_with_os2error("perfSysCall() error");
+ */
+
+static int
+numprocessors(void)
+{
+    ULONG res;
+
+    if (DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, (PVOID)&res, sizeof(res)))
+	return 1;			/* Old system? */
+    return res;
+}
+
+XS(XS_OS2_perfSysCall); /* prototype to pass -Wmissing-prototypes */
+XS(XS_OS2_perfSysCall)
+{
+    dXSARGS;
+    if (items < 0 || items > 4)
+	Perl_croak(aTHX_ "Usage: OS2::perfSysCall(ulCommand = CMD_KI_RDCNT, ulParm1= 0, ulParm2= 0, ulParm3= 0)");
+    SP -= items;
+    {
+	dXSTARG;
+	ULONG RETVAL, ulCommand, ulParm1, ulParm2, ulParm3, res;
+	myCPUUTIL u[64];
+	int total = 0, tot2 = 0;
+
+	if (items < 1)
+	    ulCommand = CMD_KI_RDCNT;
+	else {
+	    ulCommand = (ULONG)SvUV(ST(0));
+	}
+
+	if (items < 2) {
+	    total = (ulCommand == CMD_KI_RDCNT ? numprocessors() : 0);
+	    ulParm1 = (total ? (ULONG)u : 0);
+
+	    if (total > C_ARRAY_LENGTH(u))
+		croak("Unexpected number of processors: %d", total);
+	} else {
+	    ulParm1 = (ULONG)SvUV(ST(1));
+	}
+
+	if (items < 3) {
+	    tot2 = (ulCommand == CMD_KI_GETQTY);
+	    ulParm2 = (tot2 ? (ULONG)&res : 0);
+	} else {
+	    ulParm2 = (ULONG)SvUV(ST(2));
+	}
+
+	if (items < 4)
+	    ulParm3 = 0;
+	else {
+	    ulParm3 = (ULONG)SvUV(ST(3));
+	}
+
+	RETVAL = perfSysCall(ulCommand, ulParm1, ulParm2, ulParm3);
+	if (!RETVAL)
+	    croak_with_os2error("perfSysCall() error");
+	if (total) {
+	    int i,j;
+
+	    if (GIMME_V != G_ARRAY) {
+		PUSHn(u[0][0]);		/* Total ticks on the first processor */
+		XSRETURN(1);
+	    }
+	    for (i=0; i < total; i++)
+		for (j=0; j < 4; j++)
+		    PUSHs(sv_2mortal(newSVnv(u[i][j])));
+	    XSRETURN(4*total);
+	}
+	if (tot2) {
+	    PUSHu(res);
+	    XSRETURN(1);
+	}
+    }
+    XSRETURN_EMPTY;
+}
 
 #define PERL_PATCHLEVEL_H_IMPLICIT	/* Do not init local_patches. */
 #include "patchlevel.h"
@@ -3503,6 +3610,7 @@ Xs_OS2_init(pTHX)
         newXS("Cwd::sys_cwd", XS_Cwd_sys_cwd, file);
         newXS("Cwd::sys_abspath", XS_Cwd_sys_abspath, file);
         newXS("OS2::replaceModule", XS_OS2_replaceModule, file);
+        newXS("OS2::perfSysCall", XS_OS2_perfSysCall, file);
         newXSproto("OS2::_control87", XS_OS2__control87, file, "$$");
         newXSproto("OS2::get_control87", XS_OS2_get_control87, file, "");
         newXSproto("OS2::set_control87", XS_OS2_set_control87, file, ";$$");
@@ -3516,7 +3624,12 @@ Xs_OS2_init(pTHX)
         newXSproto("OS2::SysValues", XS_OS2_SysValues, file, ";$$");
         newXSproto("OS2::SysValues_set", XS_OS2_SysValues_set, file, "$$;$");
         newXSproto("OS2::Beep", XS_OS2_Beep, file, ";$$");
-	gv = gv_fetchpv("OS2::is_aout", TRUE, SVt_PV);
+	gv = gv_fetchpv("OS2::is_aout", TRUE, SVt_PV);	/* Obsolete alias */
+	GvMULTI_on(gv);
+#ifdef PERL_IS_AOUT
+	sv_setiv(GvSV(gv), 1);
+#endif
+	gv = gv_fetchpv("OS2::is_static", TRUE, SVt_PV);
 	GvMULTI_on(gv);
 #ifdef PERL_IS_AOUT
 	sv_setiv(GvSV(gv), 1);
@@ -3921,6 +4034,40 @@ Perl_OS2_init3(char **env, void **preg, 
     Perl_os2_initial_mode = -1;		/* Uninit */
     /* Some DLLs reset FP flags on load.  We may have been linked with them */
     _control87(MCW_EM, MCW_EM);
+}
+
+int
+fd_ok(int fd)
+{
+    static ULONG max_fh = 0;
+
+    if (!(_emx_env & 0x200)) return 1;		/* not OS/2. */
+    if (fd >= max_fh) {				/* Renew */
+	LONG delta = 0;
+
+	if (DosSetRelMaxFH(&delta, &max_fh))	/* Assume it OK??? */
+	    return 1;
+    }
+    return fd < max_fh;
+}
+
+/* Kernels up to Oct 2003 trap on (invalid) dup(max_fh); [off-by-one + double fault].  */
+int
+dup2(int from, int to)
+{
+    if (fd_ok(from < to ? to : from))
+	return _dup2(from, to);
+    errno = EBADF;
+    return -1;
+}
+
+int
+dup(int from)
+{
+    if (fd_ok(from))
+	return _dup(from);
+    errno = EBADF;
+    return -1;
 }
 
 #undef tmpnam
--- ./os2/os2ish.h.orig	Tue Oct 21 12:52:06 2003
+++ ./os2/os2ish.h	Tue Oct 28 21:10:06 2003
@@ -689,6 +689,8 @@ enum entries_ordinals {
     ORD_WinLoadPointer,
     ORD_WinQuerySysPointer,
     ORD_DosReplaceModule,
+    ORD_DosPerfSysCall,
+    ORD_RexxRegisterSubcomExe,
     ORD_NENTRIES
 };
 
--- ./os2/os2_base.t.orig	Fri Jul 19 16:50:02 2002
+++ ./os2/os2_base.t	Tue Oct 28 20:11:32 2003
@@ -32,10 +32,17 @@ $lpe =~ s#\\#/#g;
 
 like($lpe, qr/\Q$s_cwd/);
 
-is(uc OS2::DLLname(1), uc $Config{dll_name});
-like(OS2::DLLname, qr#\Q/$Config{dll_name}\E\.dll$#i );
-(my $root_cwd = $s_cwd) =~ s,/t$,,;
-like(OS2::DLLname, qr#^\Q$root_cwd\E(/t)?\Q/$Config{dll_name}\E\.dll#i );
+if (uc OS2::DLLname() eq uc $^X) {	# Static build
+  my ($short) = ($^X =~ m,.*[/\\]([^.]+),);
+  is(uc OS2::DLLname(1), uc $short);
+  is(uc OS2::DLLname, uc $^X );		# automatically
+  is(1,1);				# automatically...
+} else {
+  is(uc OS2::DLLname(1), uc $Config{dll_name});
+  like(OS2::DLLname, qr#\Q/$Config{dll_name}\E\.dll$#i );
+  (my $root_cwd = $s_cwd) =~ s,/t$,,;
+  like(OS2::DLLname, qr#^\Q$root_cwd\E(/t)?\Q/$Config{dll_name}\E\.dll#i );
+}
 is(OS2::DLLname, OS2::DLLname(2));
 like(OS2::DLLname(0), qr#^(\d+)$# );
 
--- ./os2/perl2cmd.pl.orig	Fri Jul 19 16:50:02 2002
+++ ./os2/perl2cmd.pl	Tue Oct 28 20:17:46 2003
@@ -16,14 +16,25 @@ EOU
 $idir = $Config{installbin};
 $indir =~ s|\\|/|g ;
 
+my %seen;
+
 foreach $file (<$idir/*>) {
-  next if $file =~ /\.exe/i;
+  next if $file =~ /\.(exe|bak)/i;
   $base = $file;
   $base =~ s/\.$//;		# just in case...
   $base =~ s|.*/||;
-  $file =~ s|/|\\|g ;
+  $base =~ s|\.pl$||;
+  #$file =~ s|/|\\|g ;
+  warn "Clashing output name for $file, skipping" if $seen{$base}++;
   print "Processing $file => $dir\\$base.cmd\n";
-  system 'cmd.exe', '/c', "echo extproc perl -S>$dir\\$base.cmd";
-  system 'cmd.exe', '/c', "type $file >> $dir\\$base.cmd";
+  open IN, '<', $file or warn, next;
+  open OUT, '>', "$dir/$base.cmd" or warn, next;
+  my $firstline = <IN>;
+  my $flags = '';
+  $flags = $2 if $firstline =~ /^#!\s*(\S+)\s+-([^#]+?)\s*(#|$)/;
+  print OUT "extproc perl -S$flags\n$firstline";
+  print OUT $_ while <IN>;
+  close IN or warn, next;
+  close OUT or warn, next;
 }
 
--- ./os2/OS2/Process/Process.pm.orig	Thu Sep 11 14:48:24 2003
+++ ./os2/OS2/Process/Process.pm	Tue Oct 28 20:08:16 2003
@@ -573,6 +573,64 @@ sub kbdhStatus_set {
   _kbdStatus_set($o,$h);
 }
 
+# Large buffer works at least for read from pipes
+sub __term_mirror_screen {   # Read from fd=$in and write to the console
+  my $in = shift;
+  open IN, "<&=$in" or die "open <&=$in: $!";
+  # Attempt to redirect to STDERR/OUT is not very useful, but try this anyway...
+  open OUT, '>', '/dev/con' or open OUT, '>&STDERR' or open OUT, '>&STDOUT'
+        or warn "Cannot reopen STDOUT to /dev/con or STDERR/STDOUT";
+  select OUT; $| = 1; local $SIG{TERM} = sub { die "screenwriter exits...\n"};
+  eval { print while sysread IN, $_, 1<<16; }
+}
+
+sub __term_mirror {   # Read from fd=$in and pass through; same for $out
+  my $pid;
+  local $SIG{TERM} = sub { die "keyreader exits...\n" };
+  my ($in, $out) = (shift, shift);
+  my %in = @_;
+  Title_set $in{title}			if exists $in{title};
+  &scrsize_set(split /,/, $in{scrsize})	if exists $in{scrsize};
+
+  $pid = system 1, $^X, '-MOS2::Process',
+	 '-we', 'OS2::Process::__term_mirror_screen shift', $in;
+  $pid > 0 or die "Cannot start a grandkid";
+
+  open STDIN, '</dev/con' or warn "reopen stdin: $!";
+  open OUT, ">&=$out" or die "Cannot open &=$out for writing: $!";
+  select OUT;    $| = 1;  binmode OUT;	# need binmode since sysread() is bin
+  $SIG{PIPE} = sub { die "writing to a closed pipe" };
+  # Turn Nodelay on kbd.  Pipe is automatically nodelay...
+  if ($in{read_by_key}) {
+    if (eval {require Term::ReadKey; 1}) {
+      Term::ReadKey::ReadMode(4);
+    } else { warn }
+  }
+  print while sysread STDIN, $_, 1<<($flag ? 16 : 0);
+}
+
+sub io_term {	# arguments: hash with keys read_by_key/title/scrsize
+  local $^F = 40;     # XXXX Fixme!
+  local $\  = '';
+  my ($in1, $out1, $in2, $out2);
+
+  pipe $in1, $out1 or return;
+  pipe $in2, $out2 or do { close($in1), close($out1), return };
+
+  # system P_SESSION will fail if there is another process
+  # in the same session with a "dependent" asynchronous child session.
+  my @i = map +('-I', $_), @INC;	# Propagate @INC
+  my $kpid = system 4, $^X, @i, '-we', <<'EOS', fileno $in1, fileno $out2, @_;
+     END {sleep($sleep || 5)}
+     use OS2::Process; $sleep = 1;
+     OS2::Process::__term_mirror(@ARGV);
+EOS
+  close $in1 or warn;
+  close $out2 or warn;
+  warn "system P_SESSION, $^X: $!, $^E" and do { close($in2), close($out1), return }
+    unless $kpid > 0;
+  return ($in2, $out1, $kpid);
+}
 
 # Autoload methods go after __END__, and are processed by the autosplit program.
 
--- ./os2/OS2/REXX/REXX.xs.orig	Sun Dec 22 23:48:34 2002
+++ ./os2/OS2/REXX/REXX.xs	Tue Oct 28 20:11:58 2003
@@ -52,6 +52,8 @@ static LONG    APIENTRY (*pRexxStart) (L
 				    PSZ, LONG, PRXSYSEXIT, PSHORT, PRXSTRING);
 static APIRET  APIENTRY (*pRexxRegisterFunctionExe) (PSZ,
 						  RexxFunctionHandler *);
+static APIRET  APIENTRY (*pRexxRegisterSubcomExe)  (PCSZ pszEnvName, PFN pfnEntryPoint,
+    PUCHAR pUserArea);
 static APIRET  APIENTRY (*pRexxDeregisterFunction) (PSZ);
 
 static ULONG (*pRexxVariablePool) (PSHVBLOCK pRequest);
@@ -313,11 +315,13 @@ initialize(void)
     *(PFN *)&pRexxDeregisterFunction
 	= loadByOrdinal(ORD_RexxDeregisterFunction, 1);
     *(PFN *)&pRexxVariablePool = loadByOrdinal(ORD_RexxVariablePool, 1);
+    *(PFN *)&pRexxRegisterSubcomExe
+	= loadByOrdinal(ORD_RexxRegisterSubcomExe, 1);
     needstrs(8);
     needvars(8);
     trace = getenv("PERL_REXX_DEBUG");
      
-    rc = RexxRegisterSubcomExe("PERLEVAL", (PFN)&SubCommandPerlEval, NULL);
+    rc = pRexxRegisterSubcomExe("PERLEVAL", (PFN)&SubCommandPerlEval, NULL);
 }
 
 static int
