Makefile.ssl doesn't exist anymore
[openssl.git] / Makefile.shared
index 9178b82..8593ead 100644 (file)
@@ -66,8 +66,8 @@ LIBDEPS=
 #------------------------------------------------------------------------------
 # The rest is private to this makefile.
 
-#DEBUG=:
-DEBUG=set -x
+#SET_X=:
+SET_X=set -x
 
 top:
        echo "Trying to use this makefile interactively?  Don't."
@@ -87,27 +87,33 @@ CALC_VERSIONS=      \
        fi
 
 LINK_APP=      \
-  ( $(DEBUG);   \
-    $$LDCMD $(LDFLAGS) $$LDFLAGS -o $$APPNAME $(OBJECTS) $$LIBDEPS )
+  ( $(SET_X);   \
+    LIBPATH=`for x in $$LIBDEPS; do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \
+    LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
+    LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
+    $$LDCMD $$LDFLAGS -o $$APPNAME $(OBJECTS) $$LIBDEPS )
 
 LINK_SO=       \
-  ( $(DEBUG);   \
+  ( $(SET_X);   \
     nm -Pg $$SHOBJECTS | grep ' [BDT] ' | cut -f1 -d' ' > lib$(LIBNAME).exp; \
-    $$SHAREDCMD $(SHARED_LDFLAGS) $$SHAREDFLAGS -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
+    LIBPATH=`for x in $$LIBDEPS; do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \
+    LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
+    LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
+    $$SHAREDCMD $$SHAREDFLAGS -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
        $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS ) && \
-  $(SYMLINK_SO); ( $(DEBUG); rm -f lib$(LIBNAME).exp )
+  $(SYMLINK_SO); ( $(SET_X); rm -f lib$(LIBNAME).exp )
 SYMLINK_SO=    \
        if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \
                prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
                if [ -n "$$SHLIB_COMPAT" ]; then \
                        for x in $$SHLIB_COMPAT; do \
-                               ( $(DEBUG); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
+                               ( $(SET_X); 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; \
+                       ( $(SET_X); rm -f $$SHLIB$$SHLIB_SUFFIX; \
                          ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
                fi; \
        fi
@@ -117,12 +123,13 @@ LINK_SO_O=        SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
 LINK_SO_A_VIA_O=       \
   SHOBJECTS=lib$(LIBNAME).o; \
   ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
-  ( $(DEBUG); \
+  ( $(SET_X); \
     ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
   $(LINK_SO) && rm -f $(LIBNAME).o
 LINK_SO_A_UNPACKED=    \
   UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
-  (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && cp $(LIBEXTRAS) $$UNPACKDIR && \
+  (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && \
+  ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
   SHOBJECTS=$$UNPACKDIR/*.o; \
   $(LINK_SO) && rm -rf $$UNPACKDIR
 
@@ -131,16 +138,28 @@ DETECT_GNU_LD=(${CC} -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
 DO_GNU_SO=$(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LIBDEPS="$(LIBDEPS)"; \
        ALLSYMSFLAGS='-Wl,--whole-archive'; \
        NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
-       SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
+       SHAREDFLAGS="$(CFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
        SHAREDCMD='$(CC)'
 DO_GNU_APP=LDCMD=$(CC);\
-       LDFLAGS="-Wl,-rpath,$(LIBRPATH)"; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
+       LIBDEPS="$(LIBDEPS)"; \
        APPNAME=$(APPNAME)
 
+#This is rather special.  It's a special target with which one can link
+#applications without bothering with any features that have anything to
+#do with shared libraries, for example when linking against static
+#libraries.  It's mostly here to avoid a lot of conditionals everywhere
+#else...
+link_app.:
+       LDCMD=$(CC); \
+       LDFLAGS="$(CFLAGS)"; \
+       LIBDEPS="$(LIBDEPS)"; \
+       APPNAME="$(APPNAME)"; \
+       $(LINK_APP)
+
 link_o.gnu:
        @ $(DO_GNU_SO); $(LINK_SO_O)
 link_a.gnu:
@@ -148,15 +167,45 @@ link_a.gnu:
 link_app.gnu:
        @ $(DO_GNU_APP); $(LINK_APP)
 
+link_o.bsd:
+       @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
+       $(CALC_VERSIONS); \
+       SHLIB=lib$(LIBNAME).so; \
+       SHLIB_SUFFIX=; \
+       LIBDEPS=; \
+       ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
+       NOALLSYMSFLAGS=; \
+       SHAREDFLAGS="$(CFLAGS) -shared -nostdlib"; \
+       SHAREDCMD=$(CC); \
+       fi; $(LINK_SO_O)
+link_a.bsd:
+       @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
+       $(CALC_VERSIONS); \
+       SHLIB=lib$(LIBNAME).so; \
+       SHLIB_SUFFIX=; \
+       LIBDEPS=; \
+       ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
+       NOALLSYMSFLAGS=; \
+       SHAREDFLAGS="$(CFLAGS) -shared -nostdlib"; \
+       SHAREDCMD=$(CC); \
+       fi; $(LINK_SO_A)
+link_app.bsd:
+       @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
+       LDCMD=$(CC); \
+       LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBPATH)"; \
+       LIBDEPS="$(LIBDEPS)"; \
+       APPNAME="$(APPNAME)"; \
+       fi; $(LINK_APP)
+
 # For Darwin AKA Mac OS/X (dyld)
 link_o.darwin:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME); \
        SHLIB_SUFFIX=.dylib; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LIBDEPS="$(LIBDEPS)"; \
        ALLSYMSFLAGS='-all_load'; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS="-dynamiclib"; \
+       SHAREDFLAGS="$(CFLAGS) -dynamiclib"; \
        SHAREDCMD='$(CC)'; \
        if [ -n "$(LIBVERSION)" ]; then \
                SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
@@ -169,10 +218,10 @@ link_a.darwin:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME); \
        SHLIB_SUFFIX=.dylib; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LIBDEPS="$(LIBDEPS)"; \
        ALLSYMSFLAGS='-all_load'; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS="-dynamiclib"; \
+       SHAREDFLAGS="$(CFLAGS) -dynamiclib"; \
        SHAREDCMD='$(CC)'; \
        if [ -n "$(LIBVERSION)" ]; then \
                SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
@@ -183,8 +232,8 @@ link_a.darwin:
        $(LINK_SO_A)
 link_app.darwin:
        LDCMD=$(CC);\
-       LDFLAGS=""; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LDFLAGS="$(CFLAGS)"; \
+       LIBDEPS="$(LIBDEPS)"; \
        APPNAME="$(APPNAME)"; \
        $(LINK_APP)
 
@@ -192,31 +241,33 @@ link_o.cygwin:
        @ $(CALC_VERSIONS); \
        INHIBIT_SYMLINKS=yes; \
        SHLIB=cyg$(LIBNAME); \
+       expr $(PLATFORM) : 'mingw' > /dev/null && SHLIB=$(LIBNAME)eay32; \
        SHLIB_SUFFIX=.dll; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LIBDEPS="$(LIBDEPS)"; \
        SHLIB_SOVER=-$(LIBVERSION); \
        ALLSYMSFLAGS='-Wl,--whole-archive'; \
        NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
-       SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
+       SHAREDFLAGS="$(CFLAGS) -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
        SHAREDCMD='${CC}'; \
        $(LINK_SO_O)
 link_a.cygwin:
        @ $(CALC_VERSIONS); \
        INHIBIT_SYMLINKS=yes; \
        SHLIB=cyg$(LIBNAME); \
+       expr $(PLATFORM) : 'mingw' > /dev/null && SHLIB=$(LIBNAME)eay32; \
        SHLIB_SUFFIX=.dll; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LIBDEPS="$(LIBDEPS)"; \
        SHLIB_SOVER=; \
        ALLSYMSFLAGS='-Wl,--whole-archive'; \
        NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
-       SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
+       SHAREDFLAGS="$(CFLAGS) -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
        SHAREDCMD='${CC}'; \
        $(LINK_SO_A)
 link_app.cygwin:
        LDCMD=$(CC);\
-       LDFLAGS=""; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
-       APPNAME="$(APPNAME).exe"
+       LDFLAGS="$(CFLAGS)"; \
+       LIBDEPS="$(LIBDEPS)"; \
+       APPNAME="$(APPNAME)"; \
        $(LINK_APP)
 
 link_o.alpha-osf1:
@@ -225,7 +276,7 @@ link_o.alpha-osf1:
        else \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -235,7 +286,7 @@ link_o.alpha-osf1:
                SHLIB_SOVER=; \
                ALLSYMSFLAGS='-all'; \
                NOALLSYMSFLAGS='-none'; \
-               SHAREDFLAGS="-shared"; \
+               SHAREDFLAGS="$(CFLAGS) -shared"; \
                SHAREDCMD='$(CC)'; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
@@ -248,7 +299,7 @@ link_a.alpha-osf1:
        else \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -258,7 +309,7 @@ link_a.alpha-osf1:
                SHLIB_SOVER=; \
                ALLSYMSFLAGS='-all'; \
                NOALLSYMSFLAGS='-none'; \
-               SHAREDFLAGS="-shared"; \
+               SHAREDFLAGS="$(CFLAGS) -shared"; \
                SHAREDCMD='$(CC)'; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
@@ -270,8 +321,8 @@ link_app.alpha-osf1:
                $(DO_GNU_APP); \
        else \
                LDCMD=$(CC);\
-               LDFLAGS=""; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LDFLAGS="$(CFLAGS)"; \
+               LIBDEPS="$(LIBDEPS)"; \
                APPNAME="$(APPNAME)"
        fi; \
        $(LINK_APP)
@@ -284,7 +335,7 @@ link_o.tru64:
        else \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -294,7 +345,7 @@ link_o.tru64:
                SHLIB_SOVER=; \
                ALLSYMSFLAGS='-all'; \
                NOALLSYMSFLAGS='-none'; \
-               SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
+               SHAREDFLAGS="$(CFLAGS) -shared -msym -rpath $(LIBRPATH)"; \
                SHAREDCMD='$(CC)'; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
@@ -307,7 +358,7 @@ link_a.tru64:
        else \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -317,7 +368,7 @@ link_a.tru64:
                SHLIB_SOVER=; \
                ALLSYMSFLAGS='-all'; \
                NOALLSYMSFLAGS='-none'; \
-               SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
+               SHAREDFLAGS="$(CFLAGS) -shared -msym -rpath $(LIBRPATH)"; \
                SHAREDCMD='$(CC)'; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
@@ -329,8 +380,8 @@ link_app.tru64:
                $(DO_GNU_APP); \
        else \
                LDCMD=$(CC);\
-               LDFLAGS="-rpath $(LIBRPATH)"; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LDFLAGS="$(CFLAGS) -rpath $(LIBRPATH)"; \
+               LIBDEPS="$(LIBDEPS)"; \
                APPNAME="$(APPNAME)"; \
        fi; \
        $(LINK_APP)
@@ -343,7 +394,7 @@ link_o.tru64-rpath:
        else \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -353,7 +404,7 @@ link_o.tru64-rpath:
                SHLIB_SOVER=; \
                ALLSYMSFLAGS='-all'; \
                NOALLSYMSFLAGS='-none'; \
-               SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
+               SHAREDFLAGS="$(CFLAGS) -shared -msym -rpath $(LIBRPATH)"; \
                SHAREDCMD='$(CC)'; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
@@ -366,7 +417,7 @@ link_a.tru64-rpath:
        else \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
@@ -376,7 +427,7 @@ link_a.tru64-rpath:
                SHLIB_SOVER=; \
                ALLSYMSFLAGS='-all'; \
                NOALLSYMSFLAGS='-none'; \
-               SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
+               SHAREDFLAGS="$(CFLAGS) -shared -msym -rpath $(LIBRPATH)"; \
                SHAREDCMD='$(CC)'; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
@@ -388,8 +439,8 @@ link_app.tru64-rpath:
                $(DO_GNU_APP); \
        else \
                LDCMD=$(CC);\
-               LDFLAGS="-rpath $(LIBRPATH)"; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LDFLAGS="$(CFLAGS) -rpath $(LIBRPATH)"; \
+               LIBDEPS="$(LIBDEPS)"; \
                APPNAME="$(APPNAME)"; \
        fi; \
        $(LINK_APP)
@@ -403,10 +454,10 @@ link_o.solaris:
                (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                ALLSYMSFLAGS="$${MINUSZ}allextract"; \
                NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
-               SHAREDFLAGS="-G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH)"; \
+               SHAREDFLAGS="$(CFLAGS) -G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH) -Wl,-Bsymbolic"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_O)
@@ -419,10 +470,10 @@ link_a.solaris:
                (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=;\
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                ALLSYMSFLAGS="$${MINUSZ}allextract"; \
                NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
-               SHAREDFLAGS="-G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH)"; \
+               SHAREDFLAGS="$(CFLAGS) -G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH) -Wl,-Bsymbolic"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_A)
@@ -431,14 +482,13 @@ link_app.solaris:
                $(DO_GNU_APP); \
        else \
                LDCMD=$(CC);\
-               LDFLAGS="-R $(LIBRPATH)"; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LDFLAGS="$(CFLAGS) -R $(LIBRPATH)"; \
+               LIBDEPS="$(LIBDEPS)"; \
                APPNAME="$(APPNAME)"; \
        fi; \
        $(LINK_APP)
 
 # OpenServer 5 native compilers used
-# UnixWare 7 and OpenUNIX 8 native compilers used
 link_o.svr3:
        @ if ${DETECT_GNU_LD}; then \
                $(DO_GNU_SO); \
@@ -446,10 +496,10 @@ link_o.svr3:
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
-               ALLSYMSFLAGS='-z allextract'; \
+               LIBDEPS="$(LIBDEPS)"; \
+               ALLSYMSFLAGS=''; \
                NOALLSYMSFLAGS=''; \
-               SHAREDFLAGS="-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
+               SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_O)
@@ -460,10 +510,10 @@ link_a.svr3:
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
-               ALLSYMSFLAGS='-z allextract'; \
+               LIBDEPS="$(LIBDEPS)"; \
+               ALLSYMSFLAGS=''; \
                NOALLSYMSFLAGS=''; \
-               SHAREDFLAGS="-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
+               SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_A_UNPACKED)
@@ -472,147 +522,172 @@ link_app.svr3:
                $(DO_GNU_APP); \
        else \
                LDCMD=$(CC);\
-               LDFLAGS=""; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LDFLAGS="$(CFLAGS)"; \
+               LIBDEPS="$(LIBDEPS)"; \
                APPNAME="$(APPNAME)"; \
        fi; \
        $(LINK_APP)
 
-link_o.irix:
+# UnixWare 7 and OpenUNIX 8 native compilers used
+link_o.svr5:
        @ if ${DETECT_GNU_LD}; then \
                $(DO_GNU_SO); \
        else \
                $(CALC_VERSIONS); \
+               SHARE_FLAG='-G'; \
+               (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
-               ALLSYMSFLAGS='-all'; \
+               LIBDEPS="$(LIBDEPS)"; \
+               ALLSYMSFLAGS=''; \
                NOALLSYMSFLAGS=''; \
-               SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
+               SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_O)
-link_a.irix:
+link_a.svr5:
        @ if ${DETECT_GNU_LD}; then \
                $(DO_GNU_SO); \
        else \
                $(CALC_VERSIONS); \
+               SHARE_FLAG='-G'; \
+               (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
-               ALLSYMSFLAGS='-all'; \
+               LIBDEPS="$(LIBDEPS)"; \
+               ALLSYMSFLAGS=''; \
                NOALLSYMSFLAGS=''; \
-               SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
+               SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
                SHAREDCMD='$(CC)'; \
        fi; \
-       $(LINK_SO_A)
-link_app.irix:
+       $(LINK_SO_A_UNPACKED)
+link_app.svr5:
        @ if ${DETECT_GNU_LD}; then \
                $(DO_GNU_APP); \
        else \
                LDCMD=$(CC);\
-               LDFLAGS="-Wl,-rpath,$(LIBRPATH)"; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LDFLAGS="$(CFLAGS)"; \
+               LIBDEPS="$(LIBDEPS)"; \
                APPNAME="$(APPNAME)"; \
        fi; \
        $(LINK_APP)
 
-# HP-UX includes the full pathname of libs we depend on, so we would get
-# ./libcrypto (with ./ as path information) compiled into libssl, hence
-# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
-# anyway.
-# The object modules are loaded from lib$i.a using the undocumented -Fl
-# option.
-#
-# WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
-#          by temporarily specifying "+s"!
-#
-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$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
-       SHAREDCMD='/usr/ccs/bin/ld'; \
-       $(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$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
-       SHAREDCMD='/usr/ccs/bin/ld'; \
-       $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
-link_app.hpux32:
-       LDCMD=$(CC);\
-       LDFLAGS="-Wl,+b,$(LIBRPATH)"; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
-       APPNAME="$(APPNAME)"
+link_o.irix:
+       @ if ${DETECT_GNU_LD}; then \
+               $(DO_GNU_SO); \
+       else \
+               $(CALC_VERSIONS); \
+               SHLIB=lib$(LIBNAME).so; \
+               SHLIB_SUFFIX=; \
+               LIBDEPS="$(LIBDEPS)"; \
+               MINUSWL=""; \
+               ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
+               ALLSYMSFLAGS="$${MINUSWL}-all"; \
+               NOALLSYMSFLAGS="$${MINUSWL}-none"; \
+               SHAREDFLAGS="$(CFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
+               SHAREDCMD='$(CC)'; \
+       fi; \
+       $(LINK_SO_O)
+link_a.irix:
+       @ if ${DETECT_GNU_LD}; then \
+               $(DO_GNU_SO); \
+       else \
+               $(CALC_VERSIONS); \
+               SHLIB=lib$(LIBNAME).so; \
+               SHLIB_SUFFIX=; \
+               LIBDEPS="$(LIBDEPS)"; \
+               MINUSWL=""; \
+               ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
+               ALLSYMSFLAGS="$${MINUSWL}-all"; \
+               NOALLSYMSFLAGS="$${MINUSWL}-none"; \
+               SHAREDFLAGS="$(CFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
+               SHAREDCMD='$(CC)'; \
+       fi; \
+       $(LINK_SO_A)
+link_app.irix:
+       @ if ${DETECT_GNU_LD}; then \
+               $(DO_GNU_APP); \
+       else \
+               LDCMD=$(CC);\
+               LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
+               LIBDEPS="$(LIBDEPS)"; \
+               APPNAME="$(APPNAME)"; \
+       fi; \
        $(LINK_APP)
 
-# HP-UX includes the full pathname of libs we depend on, so we would get
-# ./libcrypto (with ./ as path information) compiled into libssl, hence
-# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
-# anyway.
+# 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
+# we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
+# rules imply that we can only link one level down in catalog structure,
+# but that's what takes place for the moment of this writing. +cdp option
+# was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
+# editor context only [it's simply ignored in other cases, which are all
+# ELFs by the way].
 #
-# HP-UX in 64bit mode has "+s" enabled by default; it will search for
-# shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
-#
-link_o.hpux64:
-       @ $(CALC_VERSIONS); \
+link_o.hpux:
+       @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
+       $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).sl; \
+       expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
-       ALLSYMSFLAGS='+forceload'; \
+       LIBDEPS="$(LIBDEPS)"; \
+       ALLSYMSFLAGS='-Wl,-Fl'; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
-       SHAREDCMD='/usr/ccs/bin/ld'; \
+       expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
+       SHAREDFLAGS="$(CFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+cdp,../:,+cdp,./:,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+b,$(LIBRPATH)"; \
+       SHAREDCMD=$(CC); \
+       fi; \
        $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
-link_a.hpux64:
-       @ $(CALC_VERSIONS); \
+link_a.hpux:
+       @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
+       $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).sl; \
+       expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
-       ALLSYMSFLAGS='+forceload'; \
+       LIBDEPS="$(LIBDEPS)"; \
+       ALLSYMSFLAGS='-Wl,-Fl'; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
-       SHAREDCMD='/usr/ccs/bin/ld'; \
+       expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
+       SHAREDFLAGS="$(CFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+cdp,../:,+cdp,./:,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+b,$(LIBRPATH)"; \
+       SHAREDCMD='$(CC)'; \
+       fi; \
        $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
-link_app.hpux64:
+link_app.hpux:
+       @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
        LDCMD=$(CC);\
-       LDFLAGS="-Wl,+b,$(LIBRPATH)"; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
-       APPNAME="$(APPNAME)"
+       LDFLAGS="$(CFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
+       LIBDEPS="$(LIBDEPS)"; \
+       APPNAME="$(APPNAME)"; \
+       fi; \
        $(LINK_APP)
 
 link_o.aix:
        @ $(CALC_VERSIONS); \
+       OBJECT_MODE=`expr x$(SHARED_LDFLAGS) : 'x\-[a-z]\([0-9]*\)'`; \
+       OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
        SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LIBDEPS="$(LIBDEPS)"; \
        ALLSYMSFLAGS='-bnogc'; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
+       SHAREDFLAGS='$(CFLAGS) -G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
        SHAREDCMD='$(CC)'; \
-       $(LINK_SO_O)
+       $(LINK_SO_O); rm -rf lib$(LIBNAME).exp
 link_a.aix:
        @ $(CALC_VERSIONS); \
+       OBJECT_MODE=`expr x$(SHARED_LDFLAGS) : 'x\-[a-z]\([0-9]*\)'`; \
+       OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
        SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LIBDEPS="$(LIBDEPS)"; \
        ALLSYMSFLAGS='-bnogc'; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
+       SHAREDFLAGS='$(CFLAGS) -G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
        SHAREDCMD='$(CC)'; \
        $(LINK_SO_A_VIA_O)
 link_app.aix:
        LDCMD=$(CC);\
-       LDFLAGS="-blibpath:$(LIBRPATH)"; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LDFLAGS="$(CFLAGS) -blibpath:$(LIBRPATH)"; \
+       LIBDEPS="$(LIBDEPS)"; \
        APPNAME="$(APPNAME)"
        $(LINK_APP)
 
@@ -620,31 +695,31 @@ link_o.reliantunix:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LIBDEPS="$(LIBDEPS)"; \
        ALLSYMSFLAGS=; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS='-G'; \
+       SHAREDFLAGS='$(CFLAGS) -G'; \
        SHAREDCMD='$(CC)'; \
        $(LINK_SO_O)
 link_a.reliantunix:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LIBDEPS="$(LIBDEPS)"; \
        ALLSYMSFLAGS=; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS='-G'; \
+       SHAREDFLAGS='$(CFLAGS) -G'; \
        SHAREDCMD='$(CC)'; \
        $(LINK_SO_A_UNPACKED)
 link_app.reliantunix:
        LDCMD=$(CC);\
-       LDFLAGS=""; \
-       LIBDEPS="$(LIBDEPS) -lc"; \
+       LDFLAGS="$(CFLAGS)"; \
+       LIBDEPS="$(LIBDEPS)"; \
        APPNAME="$(APPNAME)"
        $(LINK_APP)
 
 # Targets to build symbolic links when needed
-symlink.gnu symlink.solaris symlink.svr3 symlink.irix \
+symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
 symlink.aix symlink.reliantunix:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so; \
@@ -654,9 +729,10 @@ symlink.darwin:
        SHLIB=lib$(LIBNAME); \
        SHLIB_SUFFIX=.dylib; \
        $(SYMLINK_SO)
-symlink.hpux32 symlink.hpux64:
+symlink.hpux:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).sl; \
+       expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
        $(SYMLINK_SO)
 # The following lines means those specific architectures do no symlinks
 symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
@@ -665,7 +741,10 @@ symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
 link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
 link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
-symlink.bsd-gcc-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
+symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
+link_o.bsd-shared: link_o.bsd
+link_a.bsd-shared: link_a.bsd
+link_app.bsd-shared: link_app.bsd
 link_o.darwin-shared: link_o.darwin
 link_a.darwin-shared: link_a.darwin
 link_app.darwin-shared: link_app.darwin
@@ -694,22 +773,18 @@ link_o.svr3-shared: link_o.svr3
 link_a.svr3-shared: link_a.svr3
 link_app.svr3-shared: link_app.svr3
 symlink.svr3-shared: symlink.svr3
-link_o.svr5-shared: link_o.svr3
-link_a.svr5-shared: link_a.svr3
-link_app.svr5-shared: link_app.svr3
-symlink.svr5-shared: symlink.svr3
+link_o.svr5-shared: link_o.svr5
+link_a.svr5-shared: link_a.svr5
+link_app.svr5-shared: link_app.svr5
+symlink.svr5-shared: symlink.svr5
 link_o.irix-shared: link_o.irix
 link_a.irix-shared: link_a.irix
 link_app.irix-shared: link_app.irix
 symlink.irix-shared: symlink.irix
-link_o.hpux-shared: link_o.hpux32
-link_a.hpux-shared: link_a.hpux32
-link_app.hpux-shared: link_app.hpux32
-symlink.hpux-shared: symlink.hpux32
-link_o.hpux64-shared: link_o.hpux64
-link_a.hpux64-shared: link_a.hpux64
-link_app.hpux64-shared: link_app.hpux64
-symlink.hpux64-shared: symlink.hpux64
+link_o.hpux-shared: link_o.hpux
+link_a.hpux-shared: link_a.hpux
+link_app.hpux-shared: link_app.hpux
+symlink.hpux-shared: symlink.hpux
 link_o.aix-shared: link_o.aix
 link_a.aix-shared: link_a.aix
 link_app.aix-shared: link_app.aix