Eh, -Wl,--whole-archive disappeared from the GNU targets. I've no
[openssl.git] / Makefile.shared
index 033c8b7..e91804f 100644 (file)
@@ -61,12 +61,13 @@ top:
 
 CALC_VERSIONS= \
        SHLIB_COMPAT=; SHLIB_SOVER=; \
-       if [ -n "$(LIBVERSION) $(LIBCOMPATVERSIONS)" ]; then \
+       if [ -n "$(LIBVERSION)$(LIBCOMPATVERSIONS)" ]; then \
                prev=""; \
                for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \
+                       SHLIB_SOVER_NODOT=$$v \
                        SHLIB_SOVER=.$$v; \
                        if [ -n "$$prev" ]; then \
-                               SHLIB_COMPAT=$$SHLIB_COMPAT .$$prev; \
+                               SHLIB_COMPAT="$$SHLIB_COMPAT .$$prev"; \
                        fi; \
                        prev=$$v; \
                done; \
@@ -75,18 +76,23 @@ CALC_VERSIONS=      \
 LINK_SO=       \
   ( $(DEBUG); \
     nm -Pg $$SHOBJECTS | grep ' [BDT] ' | cut -f1 -d' ' > lib$(LIBNAME).exp; \
-    $$SHAREDCMD $(SHARED_LDFLAGS) $$SHAREDFLAGS -o $$SHLIB$$SHLIB_SOVER \
+    $$SHAREDCMD $(SHARED_LDFLAGS) $$SHAREDFLAGS -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
        $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS ) && \
   $(SYMLINK_SO); ( $(DEBUG); rm -f lib$(LIBNAME).exp )
 SYMLINK_SO=    \
-       if [ -n "$$SHLIB_COMPAT"]; then \
-               prev=$$SHLIB$$SHLIB_SOVER; \
+       prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
+       if [ -n "$$SHLIB_COMPAT" ]; then \
                for x in $$SHLIB_COMPAT; do \
-                       ( $(DEBUG); rm -f $$SHLIB$$x; \
-                         ln -s $$prev $$SHLIB$$x ); \
-                       prev=$$SHLIB$$x; \
+                       ( $(DEBUG); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
+                         ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
+                       prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
                done; \
+       fi; \
+       if [ -n "$$SHLIB_SOVER" ]; then \
+               ( $(DEBUG); rm -f $$SHLIB$$SHLIB_SUFFIX; \
+                 ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
        fi
+
 LINK_SO_A=     SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
 LINK_SO_O=     SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
 LINK_SO_A_VIA_O=       \
@@ -104,48 +110,58 @@ DETECT_GNU_LD=${CC} -v 2>&1 | grep '^gcc' >/dev/null 2>&1 && \
        my_ld=`gcc -print-prog-name=ld 2>&1` && \
        [ -n "$$my_ld" ] && \
        $$my_ld -v 2>&1 | grep 'GNU ld' >/dev/null 2>&1
-
-link_o.gnu:
-       @ $(CALC_VERSIONS); \
-       SHLIB=lib$(LIBNAME).so \
-       LIBDEPS="$(LIBDEPS)" \
-       NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
-       SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER" \
-       SHAREDCMD='$(CC)'; \
-       $(LINK_SO_O)
-link_a.gnu:
-       @ $(CALC_VERSIONS); \
+DO_GNU=$(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so \
-       LIBDEPS="$(LIBDEPS)" \
+       SHLIB_SUFFIX= \
+       LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS='-Wl,--whole-archive' \
        NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
-       SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER" \
-       SHAREDCMD='$(CC)'; \
-       $(LINK_SO_A)
+       SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX" \
+       SHAREDCMD='$(CC)'
+
+link_o.gnu:
+       @ $(DO_GNU); $(LINK_SO_O)
+link_a.gnu:
+       @ $(DO_GNU); $(LINK_SO_A)
 
 # For Darwin AKA Mac OS/X (dyld)
 link_o.darwin:
        @ $(CALC_VERSIONS); \
-       SHLIB=lib$(LIBNAME).dylib \
-       LIBDEPS="$(LIBDEPS)" \
+       SHLIB=lib$(LIBNAME) \
+       SHLIB_SUFFIX=.dylib \
+       LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS='-all_load' \
        NOALLSYMSFLAGS='' \
-       SHAREDFLAGS="-current_version $(LIBVERSION) -compatibility_version $$SHLIB_SOVER" \
+       SHAREDFLAGS="-dynamiclib" \
        SHAREDCMD='$(CC)'; \
+       if [ -n "$(LIBVERSION)" ]; then \
+               SHAREDFLAGS="$SHAREDFLAGS -current_version $(LIBVERSION)"; \
+       fi; \
+       if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
+               SHAREDFLAGS="$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
+       fi; \
        $(LINK_SO_O)
 link_a.darwin:
        @ $(CALC_VERSIONS); \
-       SHLIB=lib$(LIBNAME)$$SHLIB_SOVER.dylib \
-       LIBDEPS="$(LIBDEPS)" \
+       SHLIB=lib$(LIBNAME) \
+       SHLIB_SUFFIX=.dylib \
+       LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS='-all_load' \
        NOALLSYMSFLAGS='' \
-       SHAREDFLAGS="-dynamiclib -current_version $(LIBVERSION) -compatibility_version $$SHLIB_SOVER" \
+       SHAREDFLAGS="-dynamiclib" \
        SHAREDCMD='$(CC)'; \
+       if [ -n "$(LIBVERSION)" ]; then \
+               SHAREDFLAGS="$SHAREDFLAGS -current_version $(LIBVERSION)"; \
+       fi; \
+       if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
+               SHAREDFLAGS="$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
+       fi; \
        $(LINK_SO_A)
 
 link_o.cygwin:
        @ SHLIB=cyg$(LIBNAME).dll \
-       LIBDEPS="$(LIBDEPS)" \
+       SHLIB_SUFFIX= \
+       LIBDEPS="$(LIBDEPS) -lc" \
        SHLIB_SOVER= \
        ALLSYMSFLAGS='-Wl,--whole-archive' \
        NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
@@ -154,7 +170,8 @@ link_o.cygwin:
        $(LINK_SO_O)
 link_a.cygwin:
        @ SHLIB=cyg$(LIBNAME).dll \
-       LIBDEPS="$(LIBDEPS)" \
+       SHLIB_SUFFIX= \
+       LIBDEPS="$(LIBDEPS) -lc" \
        SHLIB_SOVER= \
        ALLSYMSFLAGS='-Wl,--whole-archive' \
        NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
@@ -164,15 +181,11 @@ link_a.cygwin:
 
 link_o.alpha-osf1:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -182,21 +195,20 @@ link_o.alpha-osf1:
                SHLIB_SOVER= \
                ALLSYMSFLAGS='-all' \
                NOALLSYMSFLAGS='-none' \
-               SHAREDFLAGS="-shared -set_version \"$$SHLIB_HIST\"" \
+               SHAREDFLAGS="-shared" \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_O); \
-       fi
+               if [ -n "$$SHLIB_HIST" ]; then \
+                       SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
+               fi; \
+       fi; \
+       $(LINK_SO_O)
 link_a.alpha-osf1:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -206,24 +218,23 @@ link_a.alpha-osf1:
                SHLIB_SOVER= \
                ALLSYMSFLAGS='-all' \
                NOALLSYMSFLAGS='-none' \
-               SHAREDFLAGS="-shared -set_version \"$$SHLIB_HIST\"" \
+               SHAREDFLAGS="-shared" \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_A); \
-       fi
+               if [ -n "$$SHLIB_HIST" ]; then \
+                       SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
+               fi; \
+       fi; \
+       $(LINK_SO_A)
 
 # The difference between alpha-osf1-shared and tru64-shared is the `-msym'
 # option passed to the linker.
 link_o.tru64:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -233,21 +244,20 @@ link_o.tru64:
                SHLIB_SOVER= \
                ALLSYMSFLAGS='-all' \
                NOALLSYMSFLAGS='-none' \
-               SHAREDFLAGS="-shared -msym -set_version \"$$SHLIB_HIST\"" \
+               SHAREDFLAGS="-shared -msym" \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_O); \
-       fi
+               if [ -n "$$SHLIB_HIST" ]; then \
+                       SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
+               fi; \
+       fi; \
+       $(LINK_SO_O)
 link_a.tru64:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -257,24 +267,23 @@ link_a.tru64:
                SHLIB_SOVER= \
                ALLSYMSFLAGS='-all' \
                NOALLSYMSFLAGS='-none' \
-               SHAREDFLAGS="-shared -msym -set_version \"$$SHLIB_HIST\"" \
+               SHAREDFLAGS="-shared -msym" \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_A); \
-       fi
+               if [ -n "$$SHLIB_HIST" ]; then \
+                       SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
+               fi; \
+       fi; \
+       $(LINK_SO_A)
 
 # The difference between tru64-shared and tru64-shared-rpath is the
 # -rpath ${LIBRPATH} passed to the linker.
 link_o.tru64-rpath:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -284,21 +293,20 @@ link_o.tru64-rpath:
                SHLIB_SOVER= \
                ALLSYMSFLAGS='-all' \
                NOALLSYMSFLAGS='-none' \
-               SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH) -set_version \"$$SHLIB_HIST\"" \
+               SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)" \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_O); \
-       fi
+               if [ -n "$$SHLIB_HIST" ]; then \
+                       SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
+               fi; \
+       fi; \
+       $(LINK_SO_O)
 link_a.tru64-rpath:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -308,123 +316,102 @@ link_a.tru64-rpath:
                SHLIB_SOVER= \
                ALLSYMSFLAGS='-all' \
                NOALLSYMSFLAGS='-none' \
-               SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH) -set_version \"$$SHLIB_HIST\"" \
+               SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)" \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_A); \
-       fi
+               if [ -n "$$SHLIB_HIST" ]; then \
+                       SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
+               fi; \
+       fi; \
+       $(LINK_SO_A)
 
 link_o.solaris:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                ALLSYMSFLAGS='-z allextract' \
                NOALLSYMSFLAGS='' \
-               SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER' \
+               SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_O); \
-       fi
+       fi; \
+       $(LINK_SO_O)
 link_a.solaris:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                ALLSYMSFLAGS='-z allextract' \
                NOALLSYMSFLAGS='' \
-               SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER' \
+               SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_A); \
-       fi
+       fi; \
+       $(LINK_SO_A)
 
 # OpenServer 5 native compilers used
 # UnixWare 7 and OpenUNIX 8 native compilers used
 link_o.svr3:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                ALLSYMSFLAGS='-z allextract' \
                NOALLSYMSFLAGS='' \
-               SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER' \
+               SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_O); \
-       fi
+       fi; \
+       $(LINK_SO_O)
 link_a.svr3:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                ALLSYMSFLAGS='-z allextract' \
                NOALLSYMSFLAGS='' \
-               SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER' \
+               SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_A_UNPACKED); \
-       fi
+       fi; \
+       $(LINK_SO_A_UNPACKED)
 
 link_o.irix:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                ALLSYMSFLAGS='-all' \
                NOALLSYMSFLAGS='' \
-               SHAREDFLAGS='-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER' \
+               SHAREDFLAGS='-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_O); \
-       fi
+       fi; \
+       $(LINK_SO_O)
 link_a.irix:
        @ if ${DETECT_GNU_LD}; then \
-               $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
-                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
-                       LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
-                       LIBVERSION="$(LIBVERSION)"
-                       LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
-                       LIBDEPS="$(LIBDEPS)" link_o.gnu; \
+               $(DO_GNU); \
        else \
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so \
-               LIBDEPS="$(LIBDEPS)" \
+               SHLIB_SUFFIX= \
+               LIBDEPS="$(LIBDEPS) -lc" \
                ALLSYMSFLAGS='-all' \
                NOALLSYMSFLAGS='' \
-               SHAREDFLAGS='-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER' \
+               SHAREDFLAGS='-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
                SHAREDCMD='$(CC)'; \
-               $(LINK_SO_A); \
-       fi
+       fi; \
+       $(LINK_SO_A)
 
 # HP-UX includes the full pathname of libs we depend on, so we would get
 # ./libcrypto (with ./ as path information) compiled into libssl, hence
@@ -439,21 +426,23 @@ link_a.irix:
 link_o.hpux32:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).sl \
+       SHLIB_SUFFIX= \
        LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS='-Fl' \
        NOALLSYMSFLAGS='' \
-       SHAREDFLAGS='+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER' \
+       SHAREDFLAGS='+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
        SHAREDCMD='/usr/ccs/bin/ld'; \
-       $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER
+       $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 link_a.hpux32:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).sl \
+       SHLIB_SUFFIX= \
        LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS='-Fl' \
        NOALLSYMSFLAGS='' \
-       SHAREDFLAGS='+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER' \
+       SHAREDFLAGS='+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
        SHAREDCMD='/usr/ccs/bin/ld'; \
-       $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER
+       $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 
 # HP-UX includes the full pathname of libs we depend on, so we would get
 # ./libcrypto (with ./ as path information) compiled into libssl, hence
@@ -466,26 +455,29 @@ link_a.hpux32:
 link_o.hpux64:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).sl \
+       SHLIB_SUFFIX= \
        LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS='+forceload' \
        NOALLSYMSFLAGS='' \
-       SHAREDFLAGS='-b -z +h $$SHLIB$$SHLIB_SOVER' \
+       SHAREDFLAGS='-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
        SHAREDCMD='/usr/ccs/bin/ld'; \
-       $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER
+       $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 link_a.hpux64:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).sl \
+       SHLIB_SUFFIX= \
        LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS='+forceload' \
        NOALLSYMSFLAGS='' \
-       SHAREDFLAGS='-b -z +h $$SHLIB$$SHLIB_SOVER' \
+       SHAREDFLAGS='-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
        SHAREDCMD='/usr/ccs/bin/ld'; \
-       $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER
+       $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 
 link_o.aix:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so \
-       LIBDEPS="$(LIBDEPS)" \
+       SHLIB_SUFFIX= \
+       LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS='-bnogc' \
        NOALLSYMSFLAGS='' \
        SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE' \
@@ -494,7 +486,8 @@ link_o.aix:
 link_a.aix:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so \
-       LIBDEPS="$(LIBDEPS)" \
+       SHLIB_SUFFIX= \
+       LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS='-bnogc' \
        NOALLSYMSFLAGS='' \
        SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE' \
@@ -504,7 +497,8 @@ link_a.aix:
 link_o.reliantunix:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so \
-       LIBDEPS="$(LIBDEPS)" \
+       SHLIB_SUFFIX= \
+       LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS= \
        NOALLSYMSFLAGS='' \
        SHAREDFLAGS='-G' \
@@ -513,7 +507,8 @@ link_o.reliantunix:
 link_a.reliantunix:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so \
-       LIBDEPS="$(LIBDEPS)" \
+       SHLIB_SUFFIX= \
+       LIBDEPS="$(LIBDEPS) -lc" \
        ALLSYMSFLAGS= \
        NOALLSYMSFLAGS='' \
        SHAREDFLAGS='-G' \
@@ -521,11 +516,16 @@ link_a.reliantunix:
        $(LINK_SO_A_UNPACKED)
 
 # Targets to build symbolic links when needed
-symlink.gnu symlink.darwin symlink.solaris symlink.svr3 symlink.irix \
+symlink.gnu symlink.solaris symlink.svr3 symlink.irix \
 symlink.aix symlink.reliantunix:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so \
        $(SYMLINK_SO)
+symlink.darwin:
+       @ $(CALC_VERSIONS); \
+       SHLIB=lib$(LIBNAME) \
+       SHLIB_SUFFIX=.dylib \
+       $(SYMLINK_SO)
 symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
 symlink.hpux32 symlink.hpux64:
        @ $(CALC_VERSIONS); \