Skip to content

Commit 0b352c5

Browse files
committed
Make a number of changes to the OS/2 build. Submitter's comment below.
PR: 732 Submitted by: Ilya Zakharevich <[email protected]> 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.
1 parent 03ddbdd commit 0b352c5

File tree

5 files changed

+125
-25
lines changed

5 files changed

+125
-25
lines changed

os2/OS2-EMX.cmd

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,39 @@ echo RC5\32
6464
cd crypto\rc5\asm
6565
perl rc5-586.pl a.out > r5-os2.asm
6666
cd ..\..\..
67+
68+
cd os2
69+
70+
if exist noname\backward_ssl.def goto nomkdir
71+
mkdir noname
72+
:nomkdir
73+
74+
perl backwardify.pl crypto.def >backward_crypto.def
75+
perl backwardify.pl ssl.def >backward_ssl.def
76+
perl backwardify.pl -noname crypto.def >noname\backward_crypto.def
77+
perl backwardify.pl -noname ssl.def >noname\backward_ssl.def
78+
79+
echo Creating backward compatibility forwarder dlls:
80+
echo crypto.dll
81+
gcc -Zomf -Zdll -Zcrtdll -o crypto.dll backward_crypto.def 2>&1 | grep -v L4085
82+
echo ssl.dll
83+
gcc -Zomf -Zdll -Zcrtdll -o ssl.dll backward_ssl.def 2>&1 | grep -v L4085
84+
85+
echo Creating smaller backward compatibility forwarder dlls:
86+
echo These DLLs are not good for runtime resolution of symbols.
87+
echo noname\crypto.dll
88+
gcc -Zomf -Zdll -Zcrtdll -o noname/crypto.dll noname/backward_crypto.def 2>&1 | grep -v L4085
89+
echo noname\ssl.dll
90+
gcc -Zomf -Zdll -Zcrtdll -o noname/ssl.dll noname/backward_ssl.def 2>&1 | grep -v L4085
91+
92+
echo Compressing forwarders (it is ok if lxlite is not found):
93+
lxlite *.dll noname/*.dll
94+
95+
cd ..
96+
97+
echo Now run:
98+
echo For static build:
99+
echo make -f OS2-EMX.mak
100+
echo For dynamic build:
101+
echo make -f OS2-EMX-DLL.mak
102+
echo then rename crypto.dll to cryptssl.dll, ssl.dll to open_ssl.dll

os2/backwardify.pl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/perl -w
2+
use strict;
3+
4+
# Use as $0
5+
# Use as $0 -noname
6+
7+
my $did_library;
8+
my $did_description;
9+
my $do_exports;
10+
my @imports;
11+
my $noname = (@ARGV and $ARGV[0] eq '-noname' and shift);
12+
while (<>) {
13+
unless ($did_library) {
14+
s/\b(cryptssl)\b/crypto/ and $did_library = $1 if /^LIBRARY\s+cryptssl\b/;
15+
s/\b(open_ssl)\b/ssl/ and $did_library = $1 if /^LIBRARY\s+open_ssl\b/;
16+
}
17+
unless ($did_description) {
18+
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++;
19+
}
20+
if ($do_exports) {{
21+
last unless /\S/;
22+
warn, last unless /^ \s* ( \w+ ) \s+ \@(\d+)\s*$/x;
23+
push @imports, [$1, $2];
24+
s/$/ NONAME/ if $noname;
25+
}}
26+
$do_exports++ if not $do_exports and /^EXPORTS/;
27+
print $_;
28+
}
29+
print "IMPORTS\n";
30+
for my $imp (@imports) {
31+
print "\t$imp->[0]=$did_library.$imp->[1]\n";
32+
}

util/mk1mf.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@
290290
291291
EOF
292292

293+
$defs .= $preamble if defined $preamble;
294+
293295
if ($platform eq "VC-CE")
294296
{
295297
$defs.= <<"EOF";

util/mkdef.pl

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,27 +1135,55 @@ sub print_test_file
11351135
}
11361136
}
11371137

1138+
sub get_version {
1139+
local *MF;
1140+
my $v = '?';
1141+
open MF, 'Makefile.ssl' or return $v;
1142+
while (<MF>) {
1143+
$v = $1, last if /^VERSION=(.*?)\s*$/;
1144+
}
1145+
close MF;
1146+
return $v;
1147+
}
1148+
11381149
sub print_def_file
11391150
{
11401151
(*OUT,my $name,*nums,my @symbols)=@_;
11411152
my $n = 1; my @e; my @r; my @v; my $prev="";
11421153
my $liboptions="";
1154+
my $libname = $name;
1155+
my $http_vendor = 'www.openssl.org/';
1156+
my $version = get_version();
1157+
my $what = "OpenSSL: implementation of Secure Socket Layer";
1158+
my $description = "$what $version, $name - http://$http_vendor";
11431159

11441160
if ($W32)
1145-
{ $name.="32"; }
1161+
{ $libname.="32"; }
11461162
elsif ($W16)
1147-
{ $name.="16"; }
1163+
{ $libname.="16"; }
11481164
elsif ($OS2)
1149-
{ $liboptions = "INITINSTANCE\nDATA NONSHARED"; }
1165+
{ # DLL names should not clash on the whole system.
1166+
# However, they should not have any particular relationship
1167+
# to the name of the static library. Chose descriptive names
1168+
# (must be at most 8 chars).
1169+
my %translate = (ssl => 'open_ssl', crypto => 'cryptssl');
1170+
$libname = $translate{$name} || $name;
1171+
$liboptions = <<EOO;
1172+
INITINSTANCE
1173+
DATA MULTIPLE NONSHARED
1174+
EOO
1175+
# Vendor field can't contain colon, drat; so we omit http://
1176+
$description = "\@#$http_vendor:$version#\@$what; DLL for library $name. Build for EMX -Zmtd";
1177+
}
11501178

11511179
print OUT <<"EOF";
11521180
;
11531181
; Definition file for the DLL version of the $name library from OpenSSL
11541182
;
11551183
1156-
LIBRARY $name $liboptions
1184+
LIBRARY $libname $liboptions
11571185
1158-
DESCRIPTION 'OpenSSL $name - http://www.openssl.org/'
1186+
DESCRIPTION '$description'
11591187
11601188
EOF
11611189

util/pl/OS2-EMX.pl

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
# OS2-EMX.pl - for EMX GCC on OS/2
44
#
55

6-
$o='\\';
7-
$cp='copy';
6+
$o='/';
7+
$cp='cp';
88
$rm='rm -f';
99

10+
$preamble = "SHELL=sh\n";
11+
1012
# C compiler stuff
1113

1214
$cc='gcc';
@@ -48,24 +50,24 @@
4850

4951
if (!$no_asm)
5052
{
51-
$bn_asm_obj="crypto\\bn\\asm\\bn-os2$obj crypto\\bn\\asm\\co-os2$obj";
52-
$bn_asm_src="crypto\\bn\\asm\\bn-os2.asm crypto\\bn\\asm\\co-os2.asm";
53-
$des_enc_obj="crypto\\des\\asm\\d-os2$obj crypto\\des\\asm\\y-os2$obj";
54-
$des_enc_src="crypto\\des\\asm\\d-os2.asm crypto\\des\\asm\\y-os2.asm";
55-
$bf_enc_obj="crypto\\bf\\asm\\b-os2$obj";
56-
$bf_enc_src="crypto\\bf\\asm\\b-os2.asm";
57-
$cast_enc_obj="crypto\\cast\\asm\\c-os2$obj";
58-
$cast_enc_src="crypto\\cast\\asm\\c-os2.asm";
59-
$rc4_enc_obj="crypto\\rc4\\asm\\r4-os2$obj";
60-
$rc4_enc_src="crypto\\rc4\\asm\\r4-os2.asm";
61-
$rc5_enc_obj="crypto\\rc5\\asm\\r5-os2$obj";
62-
$rc5_enc_src="crypto\\rc5\\asm\\r5-os2.asm";
63-
$md5_asm_obj="crypto\\md5\\asm\\m5-os2$obj";
64-
$md5_asm_src="crypto\\md5\\asm\\m5-os2.asm";
65-
$sha1_asm_obj="crypto\\sha\\asm\\s1-os2$obj";
66-
$sha1_asm_src="crypto\\sha\\asm\\s1-os2.asm";
67-
$rmd160_asm_obj="crypto\\ripemd\\asm\\rm-os2$obj";
68-
$rmd160_asm_src="crypto\\ripemd\\asm\\rm-os2.asm";
53+
$bn_asm_obj="crypto/bn/asm/bn-os2$obj crypto/bn/asm/co-os2$obj";
54+
$bn_asm_src="crypto/bn/asm/bn-os2.asm crypto/bn/asm/co-os2.asm";
55+
$des_enc_obj="crypto/des/asm/d-os2$obj crypto/des/asm/y-os2$obj";
56+
$des_enc_src="crypto/des/asm/d-os2.asm crypto/des/asm/y-os2.asm";
57+
$bf_enc_obj="crypto/bf/asm/b-os2$obj";
58+
$bf_enc_src="crypto/bf/asm/b-os2.asm";
59+
$cast_enc_obj="crypto/cast/asm/c-os2$obj";
60+
$cast_enc_src="crypto/cast/asm/c-os2.asm";
61+
$rc4_enc_obj="crypto/rc4/asm/r4-os2$obj";
62+
$rc4_enc_src="crypto/rc4/asm/r4-os2.asm";
63+
$rc5_enc_obj="crypto/rc5/asm/r5-os2$obj";
64+
$rc5_enc_src="crypto/rc5/asm/r5-os2.asm";
65+
$md5_asm_obj="crypto/md5/asm/m5-os2$obj";
66+
$md5_asm_src="crypto/md5/asm/m5-os2.asm";
67+
$sha1_asm_obj="crypto/sha/asm/s1-os2$obj";
68+
$sha1_asm_src="crypto/sha/asm/s1-os2.asm";
69+
$rmd160_asm_obj="crypto/ripemd/asm/rm-os2$obj";
70+
$rmd160_asm_src="crypto/ripemd/asm/rm-os2.asm";
6971
}
7072

7173
if ($shlib)

0 commit comments

Comments
 (0)