Extend Solaris x86 support to amd64.
[openssl.git] / Makefile.shared
index 81a72a4..6c6a96d 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,33 +87,33 @@ CALC_VERSIONS=      \
        fi
 
 LINK_APP=      \
-  ( $(DEBUG);   \
+  ( $(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) $$LDFLAGS -o $$APPNAME $(OBJECTS) $$LIBDEPS )
+    $$LDCMD $$LDFLAGS -o $$APPNAME $(OBJECTS) $$LIBDEPS )
 
 LINK_SO=       \
-  ( $(DEBUG);   \
+  ( $(SET_X);   \
     nm -Pg $$SHOBJECTS | grep ' [BDT] ' | cut -f1 -d' ' > lib$(LIBNAME).exp; \
     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 $(SHARED_LDFLAGS) $$SHAREDFLAGS -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
+    $$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
@@ -123,7 +123,7 @@ 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=    \
@@ -138,14 +138,14 @@ 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_LDFLAGS) -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
@@ -155,7 +155,7 @@ DO_GNU_APP=LDCMD=$(CC);\
 #else...
 link_app.:
        LDCMD=$(CC); \
-       LDFLAGS=""; \
+       LDFLAGS="$(CFLAGS)"; \
        LIBDEPS="$(LIBDEPS)"; \
        APPNAME="$(APPNAME)"; \
        $(LINK_APP)
@@ -167,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)"; \
@@ -188,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)"; \
@@ -202,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)
 
@@ -211,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:
@@ -244,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)"; \
@@ -254,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\""; \
@@ -267,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)"; \
@@ -277,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\""; \
@@ -289,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)
@@ -303,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)"; \
@@ -313,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\""; \
@@ -326,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)"; \
@@ -336,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\""; \
@@ -348,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)
@@ -362,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)"; \
@@ -372,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\""; \
@@ -385,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)"; \
@@ -395,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\""; \
@@ -407,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)
@@ -422,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) $(SHARED_LDFLAGS) -G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH) -Wl,-Bsymbolic"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_O)
@@ -438,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) $(SHARED_LDFLAGS) -G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH) -Wl,-Bsymbolic"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_A)
@@ -450,8 +482,8 @@ 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)
@@ -464,10 +496,10 @@ link_o.svr3:
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               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)
@@ -478,10 +510,10 @@ link_a.svr3:
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               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)
@@ -490,8 +522,8 @@ link_app.svr3:
                $(DO_GNU_APP); \
        else \
                LDCMD=$(CC);\
-               LDFLAGS=""; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LDFLAGS="$(CFLAGS)"; \
+               LIBDEPS="$(LIBDEPS)"; \
                APPNAME="$(APPNAME)"; \
        fi; \
        $(LINK_APP)
@@ -506,10 +538,10 @@ link_o.svr5:
                (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                ALLSYMSFLAGS=''; \
                NOALLSYMSFLAGS=''; \
-               SHAREDFLAGS="$${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
+               SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_O)
@@ -522,10 +554,10 @@ link_a.svr5:
                (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                ALLSYMSFLAGS=''; \
                NOALLSYMSFLAGS=''; \
-               SHAREDFLAGS="$${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
+               SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_A_UNPACKED)
@@ -534,8 +566,8 @@ link_app.svr5:
                $(DO_GNU_APP); \
        else \
                LDCMD=$(CC);\
-               LDFLAGS=""; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LDFLAGS="$(CFLAGS)"; \
+               LIBDEPS="$(LIBDEPS)"; \
                APPNAME="$(APPNAME)"; \
        fi; \
        $(LINK_APP)
@@ -547,12 +579,12 @@ link_o.irix:
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                MINUSWL=""; \
                ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
                ALLSYMSFLAGS="$${MINUSWL}-all"; \
-               NOALLSYMSFLAGS="$${MINUSWL}-notall"; \
-               SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
+               NOALLSYMSFLAGS="$${MINUSWL}-none"; \
+               SHAREDFLAGS="$(CFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_O)
@@ -563,12 +595,12 @@ link_a.irix:
                $(CALC_VERSIONS); \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LIBDEPS="$(LIBDEPS)"; \
                MINUSWL=""; \
                ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
                ALLSYMSFLAGS="$${MINUSWL}-all"; \
-               NOALLSYMSFLAGS="$${MINUSWL}-notall"; \
-               SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
+               NOALLSYMSFLAGS="$${MINUSWL}-none"; \
+               SHAREDFLAGS="$(CFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
                SHAREDCMD='$(CC)'; \
        fi; \
        $(LINK_SO_A)
@@ -577,8 +609,8 @@ link_app.irix:
                $(DO_GNU_APP); \
        else \
                LDCMD=$(CC);\
-               LDFLAGS="-Wl,-rpath,$(LIBRPATH)"; \
-               LIBDEPS="$(LIBDEPS) -lc"; \
+               LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
+               LIBDEPS="$(LIBDEPS)"; \
                APPNAME="$(APPNAME)"; \
        fi; \
        $(LINK_APP)
@@ -595,12 +627,13 @@ 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)"; \
        ALLSYMSFLAGS='-Wl,-Fl'; \
        NOALLSYMSFLAGS=''; \
        expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
-       SHAREDFLAGS="-Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+cdp,../:,+cdp,./:,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+b,$(LIBRPATH)"; \
+       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
@@ -608,19 +641,20 @@ 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)"; \
        ALLSYMSFLAGS='-Wl,-Fl'; \
        NOALLSYMSFLAGS=''; \
        expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
-       SHAREDFLAGS="-Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+cdp,../:,+cdp,./:,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+b,$(LIBRPATH)"; \
+       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.hpux:
        @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
        LDCMD=$(CC);\
-       LDFLAGS="-Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
+       LDFLAGS="$(CFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
        LIBDEPS="$(LIBDEPS)"; \
        APPNAME="$(APPNAME)"; \
        fi; \
@@ -628,28 +662,32 @@ link_app.hpux:
 
 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)
 
@@ -657,26 +695,26 @@ 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)
 
@@ -694,6 +732,7 @@ symlink.darwin:
 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:
@@ -702,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