Make a number of changes to the OS/2 build. Submitter's comment below.
authorRichard Levitte <levitte@openssl.org>
Fri, 28 Nov 2003 14:51:30 +0000 (14:51 +0000)
committerRichard Levitte <levitte@openssl.org>
Fri, 28 Nov 2003 14:51:30 +0000 (14:51 +0000)
PR: 732
Submitted by: Ilya Zakharevich <nospam-abuse@ilyaz.org>

Submitter's comment:

This patch:

a) Introduces a new file os2/backwardify.pl.

b) Introduces a new mk1mf.pl variable $preamble.  As you can see, it may
   be used also to move some OS-specific code to VC-CE too (the the
   first chunk of the patch);

c) The DESCRIPTION specifier of the .def file is made more informative:
   now it contains the version number too.  On OS/2 it is made conformant
   to OS/2 conventions; in particular, when one runs the standard command
BLDLEVEL this.DLL
   one can see:

   Vendor:      www.openssl.org/
   Revision:    0.9.7c
   Description: OpenSSL: implementation of Secure Socket Layer; DLL for library crypto.  Build for EMX -Zmtd

   [I did not make Win32 descriptions as informative as this - I'm afraid to
    break something.  Be welcome to fix this.]

d) On OS/2 the generated DLL was hardly usable (it had a shared initialized
   data segment).

e) On OS/2 the generated DLLs had names like ssl.dll.  However, DLL names on
   OS/2 are "global data".  It is hard to have several DLLs with the same
   name on the system.  Thus this precluded coexistence of OpenSSL with DLLs
   for other SLL implementations - or other name clashes.  I transparently
   changed the names of the DLLs to open_ssl.dll and cryptssl.dll.

f) The file added in (a) is used to create "forwarder" DLLs, so the
   applications expecting the "old" DLL names may use the new DLLs
   transparently.  (A presence of these DLLs on the system nullifies (e),
   but makes old applications work.  This is a stopgap measure until the
   old applications are relinked.  Systems with no old applications do not
   need these DLLs, so may enjoy all the benefits of (e).)

   The new DLLs are placed in os2/ and os2/noname subdirectories.

g) The makefiles created with os2/OS2-EMX.cmd did not work (some mysterious
   meaningless failures).  The change to util/pl/OS2-EMX.pl uses the
   variable introduced in (b) to switch the Makefiles to SHELL=sh syntax.
   All these backslashes are removed, and the generated Makefiles started to
   work.

h) Running os2/OS2-EMX.cmd now prints out what to do next.

os2/OS2-EMX.cmd
os2/backwardify.pl [new file with mode: 0644]
util/mk1mf.pl
util/mkdef.pl
util/pl/OS2-EMX.pl

index acab99ac393f929424b99fadd746d78d9a1adb1b..5924b50b6d018d412a5f7173881fc5bed9e8ed0d 100644 (file)
@@ -64,3 +64,39 @@ echo RC5\32
 cd crypto\rc5\asm
 perl rc5-586.pl a.out > r5-os2.asm
 cd ..\..\..
 cd crypto\rc5\asm
 perl rc5-586.pl a.out > r5-os2.asm
 cd ..\..\..
+
+cd os2
+
+if exist noname\backward_ssl.def goto nomkdir
+mkdir noname
+:nomkdir
+
+perl backwardify.pl            crypto.def      >backward_crypto.def
+perl backwardify.pl            ssl.def         >backward_ssl.def
+perl backwardify.pl -noname    crypto.def      >noname\backward_crypto.def
+perl backwardify.pl -noname    ssl.def         >noname\backward_ssl.def
+
+echo Creating backward compatibility forwarder dlls:
+echo  crypto.dll
+gcc -Zomf -Zdll -Zcrtdll -o crypto.dll backward_crypto.def 2>&1 | grep -v L4085
+echo  ssl.dll
+gcc -Zomf -Zdll -Zcrtdll -o ssl.dll backward_ssl.def 2>&1 | grep -v L4085
+
+echo Creating smaller backward compatibility forwarder dlls:
+echo These DLLs are not good for runtime resolution of symbols.
+echo  noname\crypto.dll
+gcc -Zomf -Zdll -Zcrtdll -o noname/crypto.dll noname/backward_crypto.def 2>&1 | grep -v L4085
+echo  noname\ssl.dll
+gcc -Zomf -Zdll -Zcrtdll -o noname/ssl.dll noname/backward_ssl.def 2>&1 | grep -v L4085
+
+echo Compressing forwarders (it is ok if lxlite is not found):
+lxlite *.dll noname/*.dll
+
+cd ..
+
+echo Now run:
+echo For static build:
+echo  make -f OS2-EMX.mak
+echo For dynamic build:
+echo  make -f OS2-EMX-DLL.mak
+echo then rename crypto.dll to cryptssl.dll, ssl.dll to open_ssl.dll
diff --git a/os2/backwardify.pl b/os2/backwardify.pl
new file mode 100644 (file)
index 0000000..272423c
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/perl -w
+use strict;
+
+# Use as $0
+# Use as $0 -noname
+
+my $did_library;
+my $did_description;
+my $do_exports;
+my @imports;
+my $noname = (@ARGV and $ARGV[0] eq '-noname' and shift);
+while (<>) {
+  unless ($did_library) {
+    s/\b(cryptssl)\b/crypto/ and $did_library = $1 if /^LIBRARY\s+cryptssl\b/;
+    s/\b(open_ssl)\b/ssl/    and $did_library = $1 if /^LIBRARY\s+open_ssl\b/;
+  }
+  unless ($did_description) {
+    s&^(DESCRIPTION\s+(['"])).*&${1}\@#www.openssl.org/:#\@forwarder DLL for pre-0.9.7c+ OpenSSL to the new dll naming scheme$2& and $did_description++;
+  }
+  if ($do_exports) {{
+    last unless /\S/;
+    warn, last unless /^ \s* ( \w+ ) \s+ \@(\d+)\s*$/x;
+    push @imports, [$1, $2];
+    s/$/ NONAME/ if $noname;
+  }}
+  $do_exports++ if not $do_exports and /^EXPORTS/;
+  print $_;
+}
+print "IMPORTS\n";
+for my $imp (@imports) {
+  print "\t$imp->[0]=$did_library.$imp->[1]\n";
+}
index 4d370720aa1687bd3ef077b05a229605ee8b8b9e..15813461f0767898a1cdbd06b783e4107705f796 100755 (executable)
@@ -290,6 +290,8 @@ $defs= <<"EOF";
 
 EOF
 
 
 EOF
 
+$defs .= $preamble if defined $preamble;
+
 if ($platform eq "VC-CE")
        {
        $defs.= <<"EOF";
 if ($platform eq "VC-CE")
        {
        $defs.= <<"EOF";
index 64e0430a19c15c5594a809e602314fc09ea69554..ddc33c152b35e6e510f428f5ace96e2627945b73 100755 (executable)
@@ -1135,27 +1135,55 @@ sub print_test_file
        }
 }
 
        }
 }
 
+sub get_version {
+   local *MF;
+   my $v = '?';
+   open MF, 'Makefile.ssl' or return $v;
+   while (<MF>) {
+     $v = $1, last if /^VERSION=(.*?)\s*$/;
+   }
+   close MF;
+   return $v;
+}
+
 sub print_def_file
 {
        (*OUT,my $name,*nums,my @symbols)=@_;
        my $n = 1; my @e; my @r; my @v; my $prev="";
        my $liboptions="";
 sub print_def_file
 {
        (*OUT,my $name,*nums,my @symbols)=@_;
        my $n = 1; my @e; my @r; my @v; my $prev="";
        my $liboptions="";
+       my $libname = $name;
+       my $http_vendor = 'www.openssl.org/';
+       my $version = get_version();
+       my $what = "OpenSSL: implementation of Secure Socket Layer";
+       my $description = "$what $version, $name - http://$http_vendor";
 
        if ($W32)
 
        if ($W32)
-               { $name.="32"; }
+               { $libname.="32"; }
        elsif ($W16)
        elsif ($W16)
-               { $name.="16"; }
+               { $libname.="16"; }
        elsif ($OS2)
        elsif ($OS2)
-               { $liboptions = "INITINSTANCE\nDATA NONSHARED"; }
+               { # DLL names should not clash on the whole system.
+                 # However, they should not have any particular relationship
+                 # to the name of the static library.  Chose descriptive names
+                 # (must be at most 8 chars).
+                 my %translate = (ssl => 'open_ssl', crypto => 'cryptssl');
+                 $libname = $translate{$name} || $name;
+                 $liboptions = <<EOO;
+INITINSTANCE
+DATA MULTIPLE NONSHARED
+EOO
+                 # Vendor field can't contain colon, drat; so we omit http://
+                 $description = "\@#$http_vendor:$version#\@$what; DLL for library $name.  Build for EMX -Zmtd";
+               }
 
        print OUT <<"EOF";
 ;
 ; Definition file for the DLL version of the $name library from OpenSSL
 ;
 
 
        print OUT <<"EOF";
 ;
 ; Definition file for the DLL version of the $name library from OpenSSL
 ;
 
-LIBRARY         $name  $liboptions
+LIBRARY         $libname       $liboptions
 
 
-DESCRIPTION     'OpenSSL $name - http://www.openssl.org/'
+DESCRIPTION     '$description'
 
 EOF
 
 
 EOF
 
index d695dda623dcc2c61c3e9389fe70745ab1e77e5d..ddb35242108c59872c9fac3348f2fba71657f448 100644 (file)
@@ -3,10 +3,12 @@
 # OS2-EMX.pl - for EMX GCC on OS/2
 #
 
 # OS2-EMX.pl - for EMX GCC on OS/2
 #
 
-$o='\\';
-$cp='copy';
+$o='/';
+$cp='cp';
 $rm='rm -f';
 
 $rm='rm -f';
 
+$preamble = "SHELL=sh\n";
+
 # C compiler stuff
 
 $cc='gcc';
 # C compiler stuff
 
 $cc='gcc';
@@ -48,24 +50,24 @@ $bf_enc_src="";
 
 if (!$no_asm)
        {
 
 if (!$no_asm)
        {
-       $bn_asm_obj="crypto\\bn\\asm\\bn-os2$obj crypto\\bn\\asm\\co-os2$obj";
-       $bn_asm_src="crypto\\bn\\asm\\bn-os2.asm crypto\\bn\\asm\\co-os2.asm";
-       $des_enc_obj="crypto\\des\\asm\\d-os2$obj crypto\\des\\asm\\y-os2$obj";
-       $des_enc_src="crypto\\des\\asm\\d-os2.asm crypto\\des\\asm\\y-os2.asm";
-       $bf_enc_obj="crypto\\bf\\asm\\b-os2$obj";
-       $bf_enc_src="crypto\\bf\\asm\\b-os2.asm";
-       $cast_enc_obj="crypto\\cast\\asm\\c-os2$obj";
-       $cast_enc_src="crypto\\cast\\asm\\c-os2.asm";
-       $rc4_enc_obj="crypto\\rc4\\asm\\r4-os2$obj";
-       $rc4_enc_src="crypto\\rc4\\asm\\r4-os2.asm";
-       $rc5_enc_obj="crypto\\rc5\\asm\\r5-os2$obj";
-       $rc5_enc_src="crypto\\rc5\\asm\\r5-os2.asm";
-       $md5_asm_obj="crypto\\md5\\asm\\m5-os2$obj";
-       $md5_asm_src="crypto\\md5\\asm\\m5-os2.asm";
-       $sha1_asm_obj="crypto\\sha\\asm\\s1-os2$obj";
-       $sha1_asm_src="crypto\\sha\\asm\\s1-os2.asm";
-       $rmd160_asm_obj="crypto\\ripemd\\asm\\rm-os2$obj";
-       $rmd160_asm_src="crypto\\ripemd\\asm\\rm-os2.asm";
+       $bn_asm_obj="crypto/bn/asm/bn-os2$obj crypto/bn/asm/co-os2$obj";
+       $bn_asm_src="crypto/bn/asm/bn-os2.asm crypto/bn/asm/co-os2.asm";
+       $des_enc_obj="crypto/des/asm/d-os2$obj crypto/des/asm/y-os2$obj";
+       $des_enc_src="crypto/des/asm/d-os2.asm crypto/des/asm/y-os2.asm";
+       $bf_enc_obj="crypto/bf/asm/b-os2$obj";
+       $bf_enc_src="crypto/bf/asm/b-os2.asm";
+       $cast_enc_obj="crypto/cast/asm/c-os2$obj";
+       $cast_enc_src="crypto/cast/asm/c-os2.asm";
+       $rc4_enc_obj="crypto/rc4/asm/r4-os2$obj";
+       $rc4_enc_src="crypto/rc4/asm/r4-os2.asm";
+       $rc5_enc_obj="crypto/rc5/asm/r5-os2$obj";
+       $rc5_enc_src="crypto/rc5/asm/r5-os2.asm";
+       $md5_asm_obj="crypto/md5/asm/m5-os2$obj";
+       $md5_asm_src="crypto/md5/asm/m5-os2.asm";
+       $sha1_asm_obj="crypto/sha/asm/s1-os2$obj";
+       $sha1_asm_src="crypto/sha/asm/s1-os2.asm";
+       $rmd160_asm_obj="crypto/ripemd/asm/rm-os2$obj";
+       $rmd160_asm_src="crypto/ripemd/asm/rm-os2.asm";
        }
 
 if ($shlib)
        }
 
 if ($shlib)