On 2006.10.23 at 11:21:26 +0200, Andy Polyakov wrote:

> >But there is another problem which Unix-style Configure doesn't solve
> >now: 
> >
> >dll can include VERSION_INFO resource. Now Configure creates .rc file
> >only if IsMK1MF is set. I think that if we want to have native Win32
> >dll, we should include this resource, even if build environment is
> >completely Unix-style.
> 
> Care to figure out and tell how to do it with windres and ld? I mean 
> I've never done this... This one probably doesn't have to be mingw 
> specific, cygwin people [Corinna?] might appreciate it just as much. A.

Here is preliminary patch to generate resource sections for DLLs.

I call it preliminary, because:

1. DLL name issue is not permanentely settled. MSVC build creates
        libeay32.dll and ssleay32.dll, and Mingw build  crypto32.dll and
        ssl32.dll. Patch includes code to support this difference, but I'm
        not absolutely sure it belongs there.

2. It is good idea to generate VERSION_INFO resource not only for DLLs,
   but also for executable files. At least for those which are considered
   part of production shipment (i.e. openssl.exe). Patch doesn't include
  this now

3. Resources for engine dlls are not generated.

Index: Makefile.org
===================================================================
RCS file: /cvs-openssl/openssl/Makefile.org,v
retrieving revision 1.278
diff -u -r1.278 Makefile.org
--- Makefile.org        21 Oct 2006 16:28:03 -0000      1.278
+++ Makefile.org        23 Oct 2006 12:17:00 -0000
@@ -67,6 +67,7 @@
 AR=ar $(ARFLAGS) r
 RANLIB= ranlib
 NM= nm
+WINDRES=windres
 PERL= perl
 TAR= tar
 TARFLAGS= --no-recursion
@@ -175,7 +176,7 @@
 BUILDENV=      PLATFORM='${PLATFORM}' PROCESSOR='${PROCESSOR}' \
                CC='${CC}' CFLAG='${CFLAG}'                     \
                AS='${CC}' ASFLAG='${CFLAG} -c'                 \
-               AR='${AR}' NM='${NM}' RANLIB='${RANLIB}'        \
+               AR='${AR}' NM='${NM}' RANLIB='${RANLIB}' WINDRES='${WINDRES}'   
\
                PERL='${PERL}'                                  \
                SDIRS='${SDIRS}' LIBRPATH='${INSTALLTOP}/lib'   \
                INSTALL_PREFIX='${INSTALL_PREFIX}'              \
Index: Makefile.shared
===================================================================
RCS file: /cvs-openssl/openssl/Makefile.shared,v
retrieving revision 1.59
diff -u -r1.59 Makefile.shared
--- Makefile.shared     23 Oct 2006 07:30:18 -0000      1.59
+++ Makefile.shared     23 Oct 2006 12:17:00 -0000
@@ -16,6 +16,8 @@
 
 NM=nm
 
+WINDRES=windres
+
 # LIBNAME contains just the name of the library, without prefix ("lib"
 # on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
 # .dll, ...).  This one MUST have a value when using this makefile to
@@ -260,18 +262,21 @@
 link_a.cygwin:
        @ $(CALC_VERSIONS); \
        INHIBIT_SYMLINKS=yes; \
+       SHLIB_SOVER=-$(LIBVERSION); \
        SHLIB=cyg$(LIBNAME); def=; \
        if expr $(PLATFORM) : 'mingw' > /dev/null; then \
                SHLIB=$(LIBNAME); \
                def="$(LIBNAME).def"; \
+               res=$${SHLIB}_rc.o\
+               SHLIB_SOVER=32; \
+               $(WINDRES) -D`echo ${LIBNAME}|tr a-z A-Z` -o $$res 
ms/version32.rc;\
                $(PERL) util/mkdef.pl 32 $(LIBNAME) > $$def; \
        fi; \
        SHLIB_SUFFIX=.dll; \
-       SHLIB_SOVER=-$(LIBVERSION); \
        ALLSYMSFLAGS='-Wl,--whole-archive'; \
        NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
        base=;  [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
-       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic 
-Wl,--out-implib,lib$(LIBNAME).dll.a $$def"; \
+       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic 
-Wl,--out-implib,lib$(LIBNAME).dll.a $$def $$res"; \
        [ -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; \
Index: Configure
===================================================================
RCS file: /cvs-openssl/openssl/Configure,v
retrieving revision 1.544
diff -u -r1.544 Configure
--- Configure   23 Oct 2006 07:38:27 -0000      1.544
+++ Configure   23 Oct 2006 12:17:00 -0000
@@ -1321,6 +1321,7 @@
                s/^AR=\s*/AR= \$\(CROSS_COMPILE_PREFIX\)/;
                s/^NM=\s*/NM= \$\(CROSS_COMPILE_PREFIX\)/;
                s/^RANLIB=\s*/RANLIB= \$\(CROSS_COMPILE_PREFIX\)/;
+               s/^WINDRES=\s*/WINDRES= \$\(CROSS_COMPILE_PREFIX\)/;
                }
        else    {
                s/^CC=.*$/CC= $cc/;
@@ -1616,7 +1617,7 @@
 }
 
 # create the ms/version32.rc file if needed
-if ($IsMK1MF) {
+if ($IsMK1MF || $target eq "mingw" ) {
        my ($v1, $v2, $v3, $v4);
        if ($version_num =~ 
/(^[0-9a-f]{1})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i) {
                $v1=hex $1;
@@ -1624,6 +1625,8 @@
                $v3=hex $3;
                $v4=hex $4;
        }
+       my $cryptolibname = $target eq "mingw"? "crypto32" : "libeay32";
+       my $ssllibname = $target eq "mingw" ? "ssl32" : "ssleay32";
        open (OUT,">ms/version32.rc") || die "Can't open ms/version32.rc";
        print OUT <<EOF;
 #include <winver.h>
@@ -1652,11 +1655,11 @@
            VALUE "FileDescription", "OpenSSL Shared Library\\0"
            VALUE "FileVersion", "$version\\0"
 #if defined(CRYPTO)
-           VALUE "InternalName", "libeay32\\0"
-           VALUE "OriginalFilename", "libeay32.dll\\0"
+           VALUE "InternalName", "$cryptolibname\\0"
+           VALUE "OriginalFilename", "$cryptolibname.dll\\0"
 #elif defined(SSL)
-           VALUE "InternalName", "ssleay32\\0"
-           VALUE "OriginalFilename", "ssleay32.dll\\0"
+           VALUE "InternalName", "$ssllibname\\0"
+           VALUE "OriginalFilename", "$ssllibname.dll\\0"
 #endif
            VALUE "ProductName", "The OpenSSL Toolkit\\0"
            VALUE "ProductVersion", "$version\\0"

Reply via email to