--- openssl-0.9.8j/Makefile~	2011-07-08 18:27:54.000000000 +0400
+++ openssl-0.9.8j/Makefile	2011-07-09 04:04:36.000000000 +0400
@@ -134,7 +134,7 @@ FIPSCANLIB=
 
 BASEADDR=0xFB00000
 
-DIRS=   crypto fips ssl engines apps test tools
+DIRS=   crypto fips ssl engines
 SHLIBDIRS= crypto ssl
 
 # dirs in crypto to build
@@ -151,7 +151,7 @@ SDIRS=  \
 
 # tests to perform.  "alltests" is a special word indicating that all tests
 # should be performed.
-TESTS = alltests
+TESTS =
 
 MAKEFILE= Makefile
 
@@ -166,8 +166,8 @@ ONEDIRS=out tmp
 EDIRS=  times doc bugs util include certs ms shlib mt demos perl sf dep VMS
 WDIRS=  windows
 LIBS=   libcrypto.a libssl.a
-SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
-SHARED_SSL=libssl$(SHLIB_EXT)
+SHARED_CRYPTO=libeay32$(SHLIB_EXT)
+SHARED_SSL=ssleay32$(SHLIB_EXT)
 SHARED_FIPS=
 SHARED_LIBS=$(SHARED_FIPS) $(SHARED_CRYPTO) $(SHARED_SSL)
 SHARED_LIBS_LINK_EXTS=
@@ -352,7 +352,7 @@ build_testapps:
 	@dir=crypto; target=testapps; $(BUILD_ONE_CMD)
 
 build_shared:	$(SHARED_LIBS)
-libcrypto$(SHLIB_EXT): libcrypto.a $(SHARED_FIPS)
+libeay32$(SHLIB_EXT): libcrypto.a $(SHARED_FIPS)
 	@if [ "$(SHLIB_TARGET)" != "" ]; then \
 		if [ "$(FIPSCANLIB)" = "libfips" ]; then \
 			$(ARD) libcrypto.a fipscanister.o ; \
@@ -366,7 +366,7 @@ libcrypto$(SHLIB_EXT): libcrypto.a $(SHA
 		exit 1; \
 	fi
 
-libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
+ssleay32$(SHLIB_EXT): libeay32$(SHLIB_EXT) libssl.a
 	@if [ "$(SHLIB_TARGET)" != "" ]; then \
 		shlibdeps=-lcrypto; \
 		[ "$(FIPSCANLIB)" = "libfips" ] && shlibdeps="$$shlibdeps -lfips"; \
--- openssl-0.9.8j/Makefile.shared~	2011-07-08 18:27:53.000000000 +0400
+++ openssl-0.9.8j/Makefile.shared	2011-07-09 03:56:29.000000000 +0400
@@ -67,8 +67,8 @@ LIBDEPS=
 #------------------------------------------------------------------------------
 # The rest is private to this makefile.
 
-SET_X=:
-#SET_X=set -x
+#SET_X=:
+SET_X=set -x
 
 top:
 	echo "Trying to use this makefile interactively?  Don't."
@@ -254,16 +254,23 @@ link_a.cygwin:
 	base=-Wl,--enable-auto-image-base; \
 	if expr $(PLATFORM) : 'mingw' > /dev/null; then \
 		SHLIB=$(LIBNAME)eay32; \
-		base=;  [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
+		base=; \
+		[ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x10000000; \
+		[ $(LIBNAME) = "crypto" ] && SHLIB=libeay32; \
 	fi; \
 	SHLIB_SUFFIX=.dll; \
-	SHLIB_SOVER=-$(LIBVERSION); \
+	SHLIB_SOVER=; \
 	ALLSYMSFLAGS='-Wl,--whole-archive'; \
 	NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
-	SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
+	SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a -Wl,--kill-at,--output-def,lib$(LIBNAME).dll.def"; \
 	[ -f apps/$$SHLIB$$SHLIB_SUFFIX ] && rm apps/$$SHLIB$$SHLIB_SUFFIX; \
 	[ -f test/$$SHLIB$$SHLIB_SUFFIX ] && rm test/$$SHLIB$$SHLIB_SUFFIX; \
 	$(LINK_SO_A) || exit 1; \
+	[ -f lib$(LIBNAME).dll.def.reorder ] && ( \
+		SHAREDCMD=i686-pc-mingw32-dllwrap; \
+		SHAREDFLAGS="-def lib$(LIBNAME).dll.def.reorder --mno-cygwin"; \
+		$(LINK_SO_A) || exit 1; \
+	); \
 	cp -p $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX apps/; \
 	cp -p $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX test/
 link_app.cygwin:
--- openssl-0.9.8j/crypto/Makefile~	2011-07-08 18:27:54.000000000 +0400
+++ openssl-0.9.8j/crypto/Makefile	2011-07-08 18:54:06.000000000 +0400
@@ -32,7 +32,7 @@ LIBS=
 GENERAL=Makefile README crypto-lib.com install.com
 
 LIB= $(TOP)/libcrypto.a
-SHARED_LIB= libcrypto$(SHLIB_EXT)
+SHARED_LIB= libeay32$(SHLIB_EXT)
 LIBSRC=	cryptlib.c dyn_lck.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c o_init.c fips_err.c
 LIBOBJ= cryptlib.o dyn_lck.o mem.o mem_clr.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o o_time.o o_str.o o_dir.o o_init.o fips_err.o $(CPUID_OBJ)
 
--- openssl-0.9.8j/ssl/Makefile~	2011-07-08 18:27:56.000000000 +0400
+++ openssl-0.9.8j/ssl/Makefile	2011-07-08 18:57:34.000000000 +0400
@@ -19,7 +19,7 @@ TEST=ssltest.c
 APPS=
 
 LIB=$(TOP)/libssl.a
-SHARED_LIB= libssl$(SHLIB_EXT)
+SHARED_LIB= ssleay32$(SHLIB_EXT)
 LIBSRC=	\
 	s2_meth.c   s2_srvr.c s2_clnt.c  s2_lib.c  s2_enc.c s2_pkt.c \
 	s3_meth.c   s3_srvr.c s3_clnt.c  s3_lib.c  s3_enc.c s3_pkt.c s3_both.c \
