unified build scheme: add the tweaks to build on Cygwin & Mingw
authorRichard Levitte <levitte@openssl.org>
Sat, 30 Jan 2016 04:45:29 +0000 (05:45 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 10 Feb 2016 13:36:04 +0000 (14:36 +0100)
Cygwin and Mingw name their libraries a bit differently from the rest
of the POSIXly universe, we need to adapt to that.

In Makefile.tmpl, it means that some hunks will only be output
conditionally.

This also means that shared_extension for the Cygwin and Mingw
configurations in Configurations/10-main.conf are changing from .dll.a
to .dll.  Makefile.shared does a fine job without having them
specified, and it's much easier to work with tucking an extra .a at
the end of files in the installation recipes than any amount of name
rewrites, especially with the support of the SHARED_NAME in the top
build.info.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Configurations/10-main.conf
Configurations/unix-Makefile.tmpl
Makefile.in
Makefile.shared
build.info

index c5c1424bdc21d5199c7ec7750266fa5bf2fdb1a6..db64b9ef0708fa3b6aa33379cc2d66fc76029498 100644 (file)
         shared_target    => "cygwin-shared",
         shared_cflag     => "-D_WINDLL -DOPENSSL_USE_APPLINK",
         shared_ldflag    => "-mno-cygwin",
-        shared_extension => ".dll.a",
+        shared_extension => ".dll",
     },
     "mingw64" => {
         # As for OPENSSL_USE_APPLINK. Applink makes it possible to use
         shared_target    => "cygwin-shared",
         shared_cflag     => "-D_WINDLL",
         shared_ldflag    => "-mno-cygwin",
-        shared_extension => ".dll.a",
+        shared_extension => ".dll",
     },
 
 #### UEFI
         shared_target    => "cygwin-shared",
         shared_cflag     => "-D_WINDLL",
         shared_ldflag    => "-shared",
-        shared_extension => ".dll.a",
+        shared_extension => ".dll",
     },
     "Cygwin-x86_64" => {
         inherit_from     => [ asm("x86_64_asm") ],
         shared_target    => "cygwin-shared",
         shared_cflag     => "-D_WINDLL",
         shared_ldflag    => "-shared",
-        shared_extension => ".dll.a",
+        shared_extension => ".dll",
     },
     # Backward compatibility for those using this target
     "Cygwin" => {
index 5e9e10bcad6c0574f1ceb03494efea22b2076129..4888dd0240603890a06cfc8cfb4ed0d43e5db449 100644 (file)
@@ -228,6 +228,13 @@ install_dev:
                        fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
                        ln -sf $$fn $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
                fi; \
+               : {- output_off() unless windowsdll(); "" -}; \
+               echo "install $$s.a -> $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
+               cp $$s.a $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
+               chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
+               mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \
+                     $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
+               : {- output_on() -}; \
        done
        @ : {- output_on() -}
        @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
@@ -263,6 +270,10 @@ uninstall_dev:
                fi; \
                echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
                $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
+               : {- output_off() unless windowsdll(); "" -}; \
+               echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
+               $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
+               : {- output_on() -}; \
        done
        @echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
        @$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
@@ -297,6 +308,16 @@ install_runtime:
        @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin
        @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(OPENSSLDIR)/misc
        @echo "*** Installing runtime files"
+       : {- output_off() unless windowsdll(); "" -};
+       @set -e; for s in $(SHLIBS); do \
+               fn=`basename $$i`; \
+               echo "install $$s -> $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
+               cp $$s $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new; \
+               chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new; \
+               mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new \
+                     $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn; \
+       done
+       : {- output_on() -};
        @set -e; for x in $(PROGRAMS); do \
                fn=`basename $$x`; \
                echo "install $$x -> $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
@@ -346,6 +367,13 @@ uninstall_runtime:
                echo "$(RM) $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn"; \
                $(RM) $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn; \
        done
+       : {- output_off() unless windowsdll(); "" -};
+       @set -e; for s in $(SHLIBS); do \
+               fn=`basename $$i`; \
+               echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
+               $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn; \
+       done
+       : {- output_on() -};
        $(RM) $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf
 
 # A method to extract all names from a .pod file
@@ -667,6 +695,12 @@ $targets : $lib\$(LIB_EXT) $deps $ordinalsfile
                 CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
                 SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
                 link_a.$shlib_target
+EOF
+         . (windowsdll() ? <<"EOF" : "");
+       rm -f apps/$shlib\$(SHLIB_EXT)
+       rm -f test/$shlib\$(SHLIB_EXT)
+       cp -p $shlib\$(SHLIB_EXT) apps/
+       cp -p $shlib\$(SHLIB_EXT) test/
 EOF
   }
   sub obj2dynlib {
index 44362d0a96066d81c35e9a8590a75db1f5adde7f..8083a54f7dfc6e1030b79140fcfacaad5893288f 100644 (file)
@@ -372,6 +372,23 @@ do_$(SHLIB_TARGET):
                        LIBDEPS="$$libs $(EX_LIBS)" \
                        link_a.$(SHLIB_TARGET); \
                libs="-l$$i $$libs"; \
+               case "$(PLATFORM)" in \
+               Cygwin*) \
+                       rm -f apps/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
+                       rm -f test/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
+                       cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll apps/; \
+                       cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll test/; \
+                       ;; \
+               mingw*) \
+                       case $$i in \
+                               crypto) i=libeay32;; \
+                               ssl) i=ssleay32;; \
+                       esac; \
+                       rm -f apps/$$i.dll; \
+                       rm -f test/$$i.dll; \
+                       cp $$i.dll apps/; \
+                       cp $$i.dll test/; \
+               esac; \
        done
 
 libcrypto.pc: Makefile
index af2dc8ce858ea4e47d8d9e0d1fae7e040b43dd1d..a474f16916150c2e52e2b508e2d24acb32ce1024 100644 (file)
@@ -310,12 +310,8 @@ link_a.cygwin:
        ALLSYMSFLAGS='-Wl,--whole-archive'; \
        NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
        SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \
-       [ -f apps/$$dll_name ] && rm apps/$$dll_name; \
-       [ -f test/$$dll_name ] && rm test/$$dll_name; \
        $(LINK_SO_A) || exit 1; \
-       rm $$extras; \
-       cp -p $$dll_name apps/; \
-       cp -p $$dll_name test/
+       rm $$extras
 link_app.cygwin:
        @if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
                LIBDEPS="$(SRCDIR)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
index a518efeae6b7e8b2177dd6c43c05d514b5584453..019fb86ad7f787865c89e86e51dfeb464ba76030 100644 (file)
@@ -5,3 +5,11 @@ ORDINALS[libssl]=ssl
 INCLUDE[libcrypto]={- rel2abs(catdir($builddir,"include")) -} . crypto/include include
 INCLUDE[libssl]={- rel2abs(catdir($builddir,"include")) -} . include
 DEPEND[libssl]=libcrypto
+
+IF[{- $config{target} =~ /^Cygwin/ -}]
+ SHARED_NAME[libcrypto]=cygcrypto-{- $config{shlib_major}.".".$config{shlib_minor} -}
+ SHARED_NAME[libssl]=cygssl-{- $config{shlib_major}.".".$config{shlib_minor} -}
+ELSIF[{- $config{target} =~ /^mingw/ -}]
+ SHARED_NAME[libcrypto]=libeay32
+ SHARED_NAME[libssl]=ssleay32
+ENDIF