Hi,

The attached patch allows OpenSSL to build with Borland Builder and nasm
on Win32.  Although I've only tested with Builder 5, I see no reason why
Builders 3, 4 or 6 shouldn't also work.

A comment regarding each changed file:

x86nasm.pl : Make nasm use 32-bit sections.  The 2-year-old commit comment
from steve indicates he didn't get nasm support to work previously.  Since 
nasm apparently defaults to outputting 16-bit section types, this may be 
the reason.

rand.h : Various files in the tree (crypto/des/rand_key.c, for example)  
include rand.h without including anything that would drag in windows.h and
hence windef.h under Win32.  This causes a problem with the prototype of 
RAND_event, which uses the windows-specific types WPARAM, LPARAM and UINT.  
The patch therefore adds an addition #if defined() protection, checking 
for BASENAMES, a macro which is defined by windef.h, the same file that 
defines these three types.  I don't really follow how other Windows 
environments have been compiling rand_key.c and others without this 
change.

x509.h : This is the change I'm genuinely unsure about.  x509.h includes
asn1.h, but both x509/x_all.c and x509v3/v3_bitst.c reference (via macros)  
struct ASN1_ITEM_st, which is defined not in asn1.h but in asn1t.h.  
Since both files include x509.h, which includes asn1.h, and since asn1t.h
includes asn1.h, I've changed x509.h to include asn1t.h instead of asn1.h.  
Someone who knows the code better may be able to come up with a better
solution.

do_nasm.bat : Change all xx-win32.asm files to xx_win32.asm.  If the
filenames have hyphens in them, this gets interpreted by the dumb borland
linker as an option later on in the build.  Since according to the commit
on x86nasm.pl, nasm never worked anyway under Windows, this change
shouldn't bother anyone.  Also, generate a bcb.mak using mk1mf.pl and
'nasm'.

BC-32.pl : One ugly hack to get around the fact that _stricmp is called 
stricmp by Borland.  Change the assembler to nasm (from nothing), change 
the assembler flags.  Perform the same hyphen->underscore conversion as 
above.

...and that's it.  Apologies if the explanation's on the long side, but 
since it's the first involvement I've had with the project and I'd quite 
like the patch to be applied, I figured I'd better explain myself.  If the 
patch would more appropriately be sent elsewhere, please let me know.  
After this patch, the following instructions will build OpenSSL on a 
machine with perl, builder (including Builder's 'make') and nasm in the 
path:

perl Configure BC-32
ms\do_nasm.bat
make -f ms\bcb.mak

I've only just subscribed to this list, so I don't know if patches are 
preferred as attachments or included directly.  I've therefore attached 
it.

-- 
Jon Bright
Lead Programmer, Silicon Circus Ltd.
http://www.siliconcircus.com

diff -ur origopenssl/crypto/perlasm/x86nasm.pl openssl/crypto/perlasm/x86nasm.pl

--- origopenssl/crypto/perlasm/x86nasm.pl       Mon Jul 12 18:12:39 1999

+++ openssl/crypto/perlasm/x86nasm.pl   Tue Jun 25 11:23:45 2002

@@ -209,7 +209,7 @@

 

 sub main'file

        {

-       push(@out, "segment .text\n");

+       push(@out, "segment .text use32\n");

        }

 

 sub main'function_begin

diff -ur origopenssl/crypto/rand/rand.h openssl/crypto/rand/rand.h

--- origopenssl/crypto/rand/rand.h      Thu Oct 04 07:32:44 2001

+++ openssl/crypto/rand/rand.h  Tue Jun 25 11:25:08 2002

@@ -98,7 +98,7 @@

 int RAND_egd_bytes(const char *path,int bytes);

 int RAND_poll(void);

 

-#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)

+#if ((defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)) && 
+defined(BASETYPES))

 

 void RAND_screen(void);

 int RAND_event(UINT, WPARAM, LPARAM);

diff -ur origopenssl/crypto/x509/x509.h openssl/crypto/x509/x509.h

--- origopenssl/crypto/x509/x509.h      Mon Dec 17 18:22:16 2001

+++ openssl/crypto/x509/x509.h  Tue Jun 25 11:51:46 2002

@@ -70,7 +70,7 @@

 #include <openssl/bio.h>

 #endif

 #include <openssl/stack.h>

-#include <openssl/asn1.h>

+#include <openssl/asn1t.h>

 #include <openssl/safestack.h>

 

 #ifndef OPENSSL_NO_RSA

diff -ur origopenssl/ms/do_nasm.bat openssl/ms/do_nasm.bat

--- origopenssl/ms/do_nasm.bat  Mon Jul 12 23:35:10 1999

+++ openssl/ms/do_nasm.bat      Tue Jun 25 11:31:21 2002

@@ -4,54 +4,54 @@

 

 echo Bignum

 cd crypto\bn\asm

-perl x86.pl win32n > bn-win32.asm

+perl x86.pl win32n > bn_win32.asm

 cd ..\..\..

 

 echo DES

 cd crypto\des\asm

-perl des-586.pl win32n > d-win32.asm

+perl des-586.pl win32n > d_win32.asm

 cd ..\..\..

 

 echo "crypt(3)"

 

 cd crypto\des\asm

-perl crypt586.pl win32n > y-win32.asm

+perl crypt586.pl win32n > y_win32.asm

 cd ..\..\..

 

 echo Blowfish

 

 cd crypto\bf\asm

-perl bf-586.pl win32n > b-win32.asm

+perl bf-586.pl win32n > b_win32.asm

 cd ..\..\..

 

 echo CAST5

 cd crypto\cast\asm

-perl cast-586.pl win32n > c-win32.asm

+perl cast-586.pl win32n > c_win32.asm

 cd ..\..\..

 

 echo RC4

 cd crypto\rc4\asm

-perl rc4-586.pl win32n > r4-win32.asm

+perl rc4-586.pl win32n > r4_win32.asm

 cd ..\..\..

 

 echo MD5

 cd crypto\md5\asm

-perl md5-586.pl win32n > m5-win32.asm

+perl md5-586.pl win32n > m5_win32.asm

 cd ..\..\..

 

 echo SHA1

 cd crypto\sha\asm

-perl sha1-586.pl win32n > s1-win32.asm

+perl sha1-586.pl win32n > s1_win32.asm

 cd ..\..\..

 

 echo RIPEMD160

 cd crypto\ripemd\asm

-perl rmd-586.pl win32n > rm-win32.asm

+perl rmd-586.pl win32n > rm_win32.asm

 cd ..\..\..

 

 echo RC5\32

 cd crypto\rc5\asm

-perl rc5-586.pl win32n > r5-win32.asm

+perl rc5-586.pl win32n > r5_win32.asm

 cd ..\..\..

 

 echo on

@@ -62,6 +62,7 @@

 perl util\mk1mf.pl dll VC-W31-32 >ms\w31dll.mak

 perl util\mk1mf.pl nasm VC-WIN32 >ms\nt.mak

 perl util\mk1mf.pl dll nasm VC-WIN32 >ms\ntdll.mak

+perl util\mk1mf.pl nasm BC-NT >ms\bcb.mak

 

 perl util\mkdef.pl 16 libeay > ms\libeay16.def

 perl util\mkdef.pl 32 libeay > ms\libeay32.def

diff -ur origopenssl/util/pl/BC-32.pl openssl/util/pl/BC-32.pl

--- origopenssl/util/pl/BC-32.pl        Mon Feb 19 15:01:52 2001

+++ openssl/util/pl/BC-32.pl    Sun Jun 23 15:36:06 2002

@@ -18,7 +18,7 @@

 $tmp_def="tmp32";

 $inc_def="inc32";

 #enable max error messages, disable most common warnings

-$cflags="-DWIN32_LEAN_AND_MEAN -q -w-aus -w-par -w-inl  -c -tWC -tWM 
-DOPENSSL_SYSNAME_WIN32 -DL_ENDIAN -DDSO_WIN32 ";

+$cflags="-DWIN32_LEAN_AND_MEAN -q -w-aus -w-par -w-inl  -c -tWC -tWM 
+-DOPENSSL_SYSNAME_WIN32 -DL_ENDIAN -DDSO_WIN32 -D_stricmp=stricmp ";

 if ($debug)

 {

     $cflags.="-Od -y -v -vi- -D_DEBUG";

@@ -51,9 +51,9 @@

 $shlib_ex_obj="";

 $app_ex_obj="c0x32.obj"; 

 

-$asm='n_o_T_a_s_m';

+$asm='nasmw';

 $asm.=" /Zi" if $debug;

-$afile='/Fo';

+$afile='-f obj -o ';

 

 $bn_mulw_obj='';

 $bn_mulw_src='';

@@ -64,24 +64,24 @@

 

 if (!$no_asm)

        {

-       $bn_mulw_obj='crypto\bn\asm\bn-win32.obj';

-       $bn_mulw_src='crypto\bn\asm\bn-win32.asm';

-       $des_enc_obj='crypto\des\asm\d-win32.obj crypto\des\asm\y-win32.obj';

-       $des_enc_src='crypto\des\asm\d-win32.asm crypto\des\asm\y-win32.asm';

-       $bf_enc_obj='crypto\bf\asm\b-win32.obj';

-       $bf_enc_src='crypto\bf\asm\b-win32.asm';

-       $cast_enc_obj='crypto\cast\asm\c-win32.obj';

-       $cast_enc_src='crypto\cast\asm\c-win32.asm';

-       $rc4_enc_obj='crypto\rc4\asm\r4-win32.obj';

-       $rc4_enc_src='crypto\rc4\asm\r4-win32.asm';

-       $rc5_enc_obj='crypto\rc5\asm\r5-win32.obj';

-       $rc5_enc_src='crypto\rc5\asm\r5-win32.asm';

-       $md5_asm_obj='crypto\md5\asm\m5-win32.obj';

-       $md5_asm_src='crypto\md5\asm\m5-win32.asm';

-       $sha1_asm_obj='crypto\sha\asm\s1-win32.obj';

-       $sha1_asm_src='crypto\sha\asm\s1-win32.asm';

-       $rmd160_asm_obj='crypto\ripemd\asm\rm-win32.obj';

-       $rmd160_asm_src='crypto\ripemd\asm\rm-win32.asm';

+       $bn_mulw_obj='crypto\bn\asm\bn_win32.obj';

+       $bn_mulw_src='crypto\bn\asm\bn_win32.asm';

+       $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj';

+       $des_enc_src='crypto\des\asm\d_win32.asm crypto\des\asm\y_win32.asm';

+       $bf_enc_obj='crypto\bf\asm\b_win32.obj';

+       $bf_enc_src='crypto\bf\asm\b_win32.asm';

+       $cast_enc_obj='crypto\cast\asm\c_win32.obj';

+       $cast_enc_src='crypto\cast\asm\c_win32.asm';

+       $rc4_enc_obj='crypto\rc4\asm\r4_win32.obj';

+       $rc4_enc_src='crypto\rc4\asm\r4_win32.asm';

+       $rc5_enc_obj='crypto\rc5\asm\r5_win32.obj';

+       $rc5_enc_src='crypto\rc5\asm\r5_win32.asm';

+       $md5_asm_obj='crypto\md5\asm\m5_win32.obj';

+       $md5_asm_src='crypto\md5\asm\m5_win32.asm';

+       $sha1_asm_obj='crypto\sha\asm\s1_win32.obj';

+       $sha1_asm_src='crypto\sha\asm\s1_win32.asm';

+       $rmd160_asm_obj='crypto\ripemd\asm\rm_win32.obj';

+       $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm';

        $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";

        }

 

Reply via email to