The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
a) PERL_SYS_INIT and PERL_SYS_TERM should pair inside the same block
   on OS/2 (to install exception handlers, one needs some space on
   stack);

b) OS/2 has executable extension .exe, but it should not be used on
   linker command line.

c) I put code to find the DLL on OS/2, though I have no idea why all this
   is done anyway...  I disable the construction of dynperl on OS/2 - at least
   until I have some idea what it is used for.

d) ??? PERL_LDFLAGS...

e) More robust support of S_ISLNK;

f) More robust support of O_BINARY.

g) This patch does not include one more chunk: currently you link static.exe
   with LDFLAGS which suite building of perl.exe.  Somehow the extra flags
   put there by Embed.pm were breaking the build (I do not remember the
   details now, when static.exe is not needed any more).

g') Similarly, perlsig.pl supposes that the contents of an executable file has
    as substrings all the static strings defined in C files.  On OS/2 the
    pages of executables are (may be) compressed, thus this is not true.
    Again, this is not relevant any more...

--- ./myldr/main.c-pre	Wed Oct 22 20:24:56 2003
+++ ./myldr/main.c	Mon Dec  8 19:35:40 2003
@@ -131,14 +131,9 @@ int main ( int argc, char **argv, char *
     exitstatus = perl_parse(my_perl, par_xs_init, argc + options_count - 1,
                             fakeargv, env);
 
-    if (exitstatus) {
-        perl_destruct(my_perl);
-        perl_free(my_perl);
-        PERL_SYS_TERM();
-        return exitstatus;
-    }
+    if (exitstatus == 0)
+	exitstatus = perl_run( my_perl );
 
-    exitstatus = perl_run( my_perl );
     perl_destruct( my_perl );
 
     if ( getenv("PAR_SPAWNED") == NULL ) {
--- ./myldr/Makefile.PL-pre	Wed Oct 22 20:42:14 2003
+++ ./myldr/Makefile.PL	Tue Dec  9 00:24:06 2003
@@ -18,6 +18,7 @@ my $debug = 0;
 my $chunk_size = 30000;
 my $perl = $^X;
 my $exe = $Config{_exe};
+my $link_exe = ($^O eq 'os2' and $Config{ldflags} =~ /-Zexe/ ? '' : $exe);
 my $o = $Config{obj_ext};
 my $gccversion = $Config{gccversion};
 my $pccflags = ccopts;
@@ -29,8 +30,10 @@ my $dynperl = $Config{useshrplib} && ($C
 my $f2c = File::Spec->catfile(".", "file2c.pl");
 my $par_pl = File::Spec->catfile('..', 'script', "par.pl");
 my $par_exe = File::Spec->catfile('.', "par$exe");
+my $par_exe_link = File::Spec->catfile('.', "par$link_exe");
 my $static_exe = File::Spec->catfile('.', "static$exe");
+my $static_exe_link = File::Spec->catfile('.', "static$link_exe");
 my $parl_exe = File::Spec->catfile('..', 'script', "parl$exe");
 my $parldyn_exe = File::Spec->catfile('..', 'script', "parldyn$exe");
 my $lib_path = join(' ', map qq(-I"$_"), map { $^O eq 'MSWin32' ? Win32::GetShortPathName($_) : $_ } @INC);
 
@@ -57,10 +61,11 @@ if ($dynperl) {
 	last if -e $libperl;
     }
 
-    die "Can't find $file in (@paths) -- please contact the author!" unless -e $libperl;
+    die "Can't find $file in (@paths) -- please contact the author!" unless -e $libperl or $^O eq 'os2';
+    $libperl = OS2::DLLname if $^O eq 'os2';
 }
 
-my $par = ($dynperl ? $static_exe : $par_exe);
+my $par = (($dynperl && $^O ne 'os2') ? $static_exe : $par_exe);
 my $all = ($dynperl ? "$parl_exe $parldyn_exe" : $parl_exe);
 
 $perl = Win32::GetShortPathName($perl)
@@ -114,7 +119,8 @@ PERL=$perl
 LD=$ld
 CC=$cc
 CFLAGS=$cflags
-LDFLAGS=$ldflags
+LDFLAGS=$Config{ldflags}
+PERL_LDFLAGS=$ldflags
 NOOP=\$(PERL) -e1
 
 OBJECTS=main$o my_par_pl$o $res
@@ -143,13 +149,13 @@ distclean: clean
 	-\$(RM) Makefile Makefile.old
 
 $par_exe: \$(OBJECTS) my_par_pl$o
-	\$(LD) \$(OBJECTS) \$(LDFLAGS) $out\$@
+	\$(LD) \$(OBJECTS) \$(PERL_LDFLAGS) $out$par_exe_link
 
 my_par_pl.c:
 	\$(PERL) $f2c $par_pl \$@ load_me_2 $long_literal
 
 $parl_exe: $par
 	$par $lib_path -I../myldr/.. -I../blib/lib -B -O\$@
 
 disttest:
 	-\$(NOOP)
@@ -170,7 +176,7 @@ $parldyn_exe: $par_exe
 	$par_exe -I../myldr/.. -I../blib/lib $lib_path -B -O\$@
 
 $static_exe: my_perl.c my_par.c static$o
-	\$(LD) static$o $res $out\$@
+	\$(LD) \$(LDFLAGS) static$o $res $out$static_exe_link
 	\$(PERL) parlsig.pl $static_exe $par_exe $dynperl $chunk_size
 
 my_perl.c:
--- ./myldr/static.c-pre	Sat Sep 27 16:39:14 2003
+++ ./myldr/static.c	Tue Dec  9 00:25:38 2003
@@ -13,7 +14,6 @@
 #define mkdir(x, y) _mkdir(x)
 #define W_OK 2
 #define S_ISDIR(x) 1
-#define S_ISLNK(x) 0
 
 #else
 #include <unistd.h>
@@ -27,6 +27,17 @@ typedef int Pid_t;
 #include <fcntl.h>
 #include <stdio.h>
 #include <sys/stat.h>
+
+#ifndef S_ISLNK
+#  define S_ISLNK(x) 0
+#endif
+
+#ifdef O_BINARY
+#  define OPEN_O_BINARY O_BINARY
+#else
+#  define OPEN_O_BINARY 0
+#endif
+
 #include "mktmpdir.c"
 #include "my_perl.c"
 #include "my_par.c"
@@ -46,13 +57,8 @@ int my_mkfile (char* argv0, char* stmpdi
     int i;
 
     my_file = (char *)malloc(strlen(stmpdir) + strlen(name) + 1);
-#ifdef WIN32
-    sprintf(my_file, "%s\\%s", stmpdir, name);
-    i = open(my_file, O_CREAT | O_WRONLY | O_BINARY);
-#else
     sprintf(my_file, "%s/%s", stmpdir, name);
-    i = open(my_file, O_CREAT | O_WRONLY);
-#endif
+    i = open(my_file, O_CREAT | O_WRONLY | OPEN_O_BINARY);
     if (i == -1) {
         fprintf(stderr, "%s: creation of %s failed - aborting with %i.\n", argv0, my_file, errno);
         return 0;