Browse Source

Add support for shared libraries with OS/2.
PR: 124

Richard Levitte 22 years ago
parent
commit
cd4c36adb8
7 changed files with 106 additions and 47 deletions
  1. 9 0
      INSTALL.OS2
  2. 2 0
      crypto/bio/bio.h
  3. 1 1
      crypto/symhacks.h
  4. 5 0
      os2/OS2-EMX.cmd
  5. 5 5
      util/libeay.num
  6. 34 12
      util/mkdef.pl
  7. 50 29
      util/pl/OS2-EMX.pl

+ 9 - 0
INSTALL.OS2

@@ -20,3 +20,12 @@
 
  If that finishes successfully you will find the libraries and programs in the
  "out" directory.
+
+ Alternatively, you can make a dynamic build that puts the library code into
+ crypto.dll and ssl.dll by running
+
+ > make -f os2-emx-dll.mak
+
+ This will build the above mentioned dlls and a matching pair of import
+ libraries in the "out_dll" directory along with the set of test programs
+ and the openssl application.

+ 2 - 0
crypto/bio/bio.h

@@ -554,7 +554,9 @@ BIO_METHOD *BIO_s_socket(void);
 BIO_METHOD *BIO_s_connect(void);
 BIO_METHOD *BIO_s_accept(void);
 BIO_METHOD *BIO_s_fd(void);
+#ifndef OPENSSL_SYS_OS2
 BIO_METHOD *BIO_s_log(void);
+#endif
 BIO_METHOD *BIO_s_bio(void);
 BIO_METHOD *BIO_s_null(void);
 BIO_METHOD *BIO_f_null(void);

+ 1 - 1
crypto/symhacks.h

@@ -249,7 +249,7 @@
 
 
 /* Case insensiteve linking causes problems.... */
-#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS)
+#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)
 #undef ERR_load_CRYPTO_strings
 #define ERR_load_CRYPTO_strings			ERR_load_CRYPTOlib_strings
 #undef OCSP_crlID_new

+ 5 - 0
os2/OS2-EMX.cmd

@@ -5,6 +5,11 @@ perl util\mkfiles.pl > MINFO
 
 @rem create make file
 perl util\mk1mf.pl OS2-EMX > OS2-EMX.mak
+perl util\mk1mf.pl dll OS2-EMX > OS2-EMX-DLL.mak
+
+echo Generating export definition files
+perl util\mkdef.pl crypto OS2 > os2\crypto.def
+perl util\mkdef.pl ssl OS2 > os2\ssl.def
 
 echo Generating x86 for GNU assember
 

+ 5 - 5
util/libeay.num

@@ -984,8 +984,8 @@ BIO_ghbn_ctrl                           1003	EXIST::FUNCTION:
 CRYPTO_free_ex_data                     1004	EXIST::FUNCTION:
 CRYPTO_get_ex_data                      1005	EXIST::FUNCTION:
 CRYPTO_set_ex_data                      1007	EXIST::FUNCTION:
-ERR_load_CRYPTO_strings                 1009	EXIST:!VMS,!WIN16:FUNCTION:
-ERR_load_CRYPTOlib_strings              1009	EXIST:VMS,WIN16:FUNCTION:
+ERR_load_CRYPTO_strings                 1009	EXIST:!OS2,!VMS,!WIN16:FUNCTION:
+ERR_load_CRYPTOlib_strings              1009	EXIST:OS2,VMS,WIN16:FUNCTION:
 EVP_PKEY_bits                           1010	EXIST::FUNCTION:
 MD5_Transform                           1011	EXIST::FUNCTION:MD5
 SHA1_Transform                          1012	EXIST::FUNCTION:SHA,SHA1
@@ -1216,7 +1216,7 @@ name_cmp                                1239	EXIST::FUNCTION:
 str_dup                                 1240	NOEXIST::FUNCTION:
 i2s_ASN1_ENUMERATED                     1241	EXIST::FUNCTION:
 i2s_ASN1_ENUMERATED_TABLE               1242	EXIST::FUNCTION:
-BIO_s_log                               1243	EXIST:!WIN16,!WIN32,!macintosh:FUNCTION:
+BIO_s_log                               1243	EXIST:!OS2,!WIN16,!WIN32,!macintosh:FUNCTION:
 BIO_f_reliable                          1244	EXIST::FUNCTION:BIO
 PKCS7_dataFinal                         1245	EXIST::FUNCTION:
 PKCS7_dataDecode                        1246	EXIST::FUNCTION:
@@ -2732,8 +2732,8 @@ EC_POINT_point2oct                      3178	EXIST::FUNCTION:EC
 KRB5_APREQ_free                         3179	EXIST::FUNCTION:
 ASN1_OBJECT_it                          3180	EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
 ASN1_OBJECT_it                          3180	EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
-OCSP_crlID_new                          3181	EXIST:!VMS,!WIN16:FUNCTION:
-OCSP_crlID2_new                         3181	EXIST:VMS,WIN16:FUNCTION:
+OCSP_crlID_new                          3181	EXIST:!OS2,!VMS,!WIN16:FUNCTION:
+OCSP_crlID2_new                         3181	EXIST:OS2,VMS,WIN16:FUNCTION:
 CONF_modules_load_file                  3182	EXIST::FUNCTION:
 CONF_imodule_set_usr_data               3183	EXIST::FUNCTION:
 ENGINE_set_default_string               3184	EXIST::FUNCTION:

+ 34 - 12
util/mkdef.pl

@@ -58,6 +58,7 @@ my $debug=0;
 
 my $crypto_num= "util/libeay.num";
 my $ssl_num=    "util/ssleay.num";
+my $libname;
 
 my $do_update = 0;
 my $do_rewrite = 1;
@@ -73,12 +74,13 @@ my $VMS=0;
 my $W32=0;
 my $W16=0;
 my $NT=0;
+my $OS2=0;
 # Set this to make typesafe STACK definitions appear in DEF
 my $safe_stack_def = 0;
 
 my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT",
 			"EXPORT_VAR_AS_FUNCTION" );
-my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT" );
+my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" );
 my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
 			 "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
 			 "RIPEMD",
@@ -126,11 +128,18 @@ foreach (@ARGV, split(/ /, $options))
 		$VMSAlpha=1;
 	}
 	$VMS=1 if $_ eq "VMS";
+	$OS2=1 if $_ eq "OS2";
 
 	$do_ssl=1 if $_ eq "ssleay";
-	$do_ssl=1 if $_ eq "ssl";
+	if ($_ eq "ssl") {
+		$do_ssl=1; 
+		$libname=$_
+	}
 	$do_crypto=1 if $_ eq "libeay";
-	$do_crypto=1 if $_ eq "crypto";
+	if ($_ eq "crypto") {
+		$do_crypto=1;
+		$libname=$_;
+	}
 	$do_update=1 if $_ eq "update";
 	$do_rewrite=1 if $_ eq "rewrite";
 	$do_ctest=1 if $_ eq "ctest";
@@ -171,8 +180,17 @@ foreach (@ARGV, split(/ /, $options))
 	}
 
 
+if (!$libname) { 
+	if ($do_ssl) {
+		$libname="SSLEAY";
+	}
+	if ($do_crypto) {
+		$libname="LIBEAY";
+	}
+}
+
 # If no platform is given, assume WIN32
-if ($W32 + $W16 + $VMS == 0) {
+if ($W32 + $W16 + $VMS + $OS2 == 0) {
 	$W32 = 1;
 }
 
@@ -183,7 +201,7 @@ if ($W16) {
 
 if (!$do_ssl && !$do_crypto)
 	{
-	print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ]\n";
+	print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT | OS2 ]\n";
 	exit(1);
 	}
 
@@ -307,10 +325,10 @@ EOF
 
 } else {
 
-	&print_def_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_symbols)
+	&print_def_file(*STDOUT,$libname,*ssl_list,@ssl_symbols)
 		if $do_ssl == 1;
 
-	&print_def_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_symbols)
+	&print_def_file(*STDOUT,$libname,*crypto_list,@crypto_symbols)
 		if $do_crypto == 1;
 
 }
@@ -997,6 +1015,7 @@ sub is_valid
 			if ($keyword eq "WIN32" && $W32) { return 1; }
 			if ($keyword eq "WIN16" && $W16) { return 1; }
 			if ($keyword eq "WINNT" && $NT) { return 1; }
+			if ($keyword eq "OS2" && $OS2) { return 1; }
 			# Special platforms:
 			# EXPORT_VAR_AS_FUNCTION means that global variables
 			# will be represented as functions.  This currently
@@ -1095,24 +1114,27 @@ sub print_def_file
 {
 	(*OUT,my $name,*nums,my @symbols)=@_;
 	my $n = 1; my @e; my @r; my @v; my $prev="";
+	my $liboptions="";
 
 	if ($W32)
 		{ $name.="32"; }
-	else
+	elsif ($W16)
 		{ $name.="16"; }
+	elsif ($OS2)
+		{ $liboptions = "INITINSTANCE\nDATA NONSHARED"; }
 
 	print OUT <<"EOF";
 ;
 ; Definition file for the DLL version of the $name library from OpenSSL
 ;
 
-LIBRARY         $name
+LIBRARY         $name	$liboptions
 
 DESCRIPTION     'OpenSSL $name - http://www.openssl.org/'
 
 EOF
 
-	if (!$W32) {
+	if ($W16) {
 		print <<"EOF";
 CODE            PRELOAD MOVEABLE
 DATA            PRELOAD MOVEABLE SINGLE
@@ -1151,10 +1173,10 @@ EOF
 					print STDERR "Warning: Symbol '",$s2,"' redefined. old=",($nums{$prev} =~ /^(.*?)\\/,$1),", new=",($nums{$s2} =~ /^(.*?)\\/,$1),"\n";
 				}
 				$prev = $s2;	# To warn about duplicates...
-				if($v) {
+				if($v && !$OS2) {
 					printf OUT "    %s%-39s @%-8d DATA\n",($W32)?"":"_",$s2,$n;
 				} else {
-					printf OUT "    %s%-39s @%d\n",($W32)?"":"_",$s2,$n;
+					printf OUT "    %s%-39s @%d\n",($W32||$OS2)?"":"_",$s2,$n;
 				}
 			}
 		}

+ 50 - 29
util/pl/OS2-EMX.pl

@@ -10,18 +10,20 @@ $rm='rm -f';
 # C compiler stuff
 
 $cc='gcc';
-$cflags="-DL_ENDIAN -O3 -fomit-frame-pointer -m486 -Zmt -Wall ";
+$cflags="-DL_ENDIAN -O3 -fomit-frame-pointer -m486 -Zmtd -Wall ";
+$cflags.="-Zomf " if $shlib;
+$shl_cflag="-Zdll";
 
 if ($debug) { 
 	$cflags.="-g "; 
 }
 
-$obj='.o';
+$obj=$shlib ? '.obj' : '.o';
 $ofile='-o ';
 
 # EXE linking stuff
 $link='${CC}';
-$lflags='${CFLAGS} -Zbsd-signals';
+$lflags='${CFLAGS} -Zbsd-signals -s';
 $efile='-o ';
 $exep='.exe';
 $ex_libs="-lsocket";
@@ -30,12 +32,12 @@ $ex_libs="-lsocket";
 $mklib='ar r';
 $mlflags='';
 $ranlib="ar s";
-$plib='lib';
-$libp=".a";
-$shlibp=".a";
+$plib='';
+$libp=$shlib ? ".lib" : ".a";
+$shlibp=$shlib ? ".dll" : ".a";
 $lfile='';
 
-$asm='as';
+$asm=$shlib ? 'as -Zomf' : 'as';
 $afile='-o ';
 $bn_asm_obj="";
 $bn_asm_src="";
@@ -46,24 +48,32 @@ $bf_enc_src="";
 
 if (!$no_asm)
 	{
-	$bn_asm_obj='crypto\bn\asm\bn-os2.o crypto\bn\asm\co-os2.o';
-	$bn_asm_src='crypto\bn\asm\bn-os2.asm crypto\bn\asm\co-os2.asm';
-	$des_enc_obj='crypto\des\asm\d-os2.o crypto\des\asm\y-os2.o';
-	$des_enc_src='crypto\des\asm\d-os2.asm crypto\des\asm\y-os2.asm';
-	$bf_enc_obj='crypto\bf\asm\b-os2.o';
-	$bf_enc_src='crypto\bf\asm\b-os2.asm';
-	$cast_enc_obj='crypto\cast\asm\c-os2.o';
-	$cast_enc_src='crypto\cast\asm\c-os2.asm';
-	$rc4_enc_obj='crypto\rc4\asm\r4-os2.o';
-	$rc4_enc_src='crypto\rc4\asm\r4-os2.asm';
-	$rc5_enc_obj='crypto\rc5\asm\r5-os2.o';
-	$rc5_enc_src='crypto\rc5\asm\r5-os2.asm';
-	$md5_asm_obj='crypto\md5\asm\m5-os2.o';
-	$md5_asm_src='crypto\md5\asm\m5-os2.asm';
-	$sha1_asm_obj='crypto\sha\asm\s1-os2.o';
-	$sha1_asm_src='crypto\sha\asm\s1-os2.asm';
-	$rmd160_asm_obj='crypto\ripemd\asm\rm-os2.o';
-	$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)
+	{
+	$mlflags.=" $lflags -Zdll";
+	$lib_cflag=" -D_DLL";
+	$out_def="out_dll";
+	$tmp_def="tmp_dll";
 	}
 
 sub do_lib_rule
@@ -76,9 +86,20 @@ sub do_lib_rule
 	($Name=$name) =~ tr/a-z/A-Z/;
 
 	$ret.="$target: \$(${Name}OBJ)\n";
-	$ret.="\t\$(RM) $target\n";
-	$ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
-	$ret.="\t\$(RANLIB) $target\n\n";
+	if (!$shlib) 
+		{
+		$ret.="\t\$(RM) $target\n";
+		$ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
+		$ret.="\t\$(RANLIB) $target\n\n";
+		}
+	else
+		{
+		local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
+		$ex.=' -lsocket';
+		$ret.="\t\$(LINK) \$(SHLIB_CFLAGS) \$(MLFLAGS) $efile$target \$(SHLIB_EX_OBJ) \$(${Name}OBJ) $ex os2/${Name}.def\n";
+		$ret.="\temximp -o $out_def/$name.a os2/${Name}.def\n";
+		$ret.="\temximp -o $out_def/$name.lib os2/${Name}.def\n\n";
+		}
 	}
 
 sub do_link_rule
@@ -89,7 +110,7 @@ sub do_link_rule
 	$file =~ s/\//$o/g if $o ne '/';
 	$n=&bname($target);
 	$ret.="$target: $files $dep_libs\n";
-	$ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
+	$ret.="\t\$(LINK) ${efile}$target \$(CFLAG) \$(LFLAGS) $files $libs\n\n";
 	return($ret);
 	}