Demo of use of errors in applications.
[openssl.git] / Makefile.shared
index 66b620f..e753f44 100644 (file)
@@ -93,7 +93,7 @@ LINK_APP=     \
   ( $(SET_X);   \
     LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
     LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS)}"; \
-    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=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
     $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
@@ -103,15 +103,13 @@ LINK_SO=  \
     LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
     SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \
     SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \
-    $(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=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | 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); \
-  ( $(SET_X); rm -f lib$(LIBNAME).exp )
+  ) && $(SYMLINK_SO)
 
 SYMLINK_SO=    \
        if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \
@@ -137,7 +135,7 @@ LINK_SO_A_VIA_O=    \
   ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
   ( $(SET_X); \
     ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
-  $(LINK_SO) && rm -f $(LIBNAME).o
+  $(LINK_SO) && rm -f lib$(LIBNAME).o
 
 LINK_SO_A_UNPACKED=    \
   UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
@@ -146,7 +144,7 @@ LINK_SO_A_UNPACKED= \
   SHOBJECTS=$$UNPACKDIR/*.o; \
   $(LINK_SO) && rm -rf $$UNPACKDIR
 
-DETECT_GNU_LD=(${CC} -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
+DETECT_GNU_LD=($(CC) -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
 
 DO_GNU_SO=$(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so; \
@@ -184,7 +182,7 @@ link_a.beos:
        @ $(DO_BEOS_SO); $(LINK_SO_A)
 
 link_o.bsd:
-       @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
+       @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
        $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
@@ -194,7 +192,7 @@ link_o.bsd:
        SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
        fi; $(LINK_SO_O)
 link_a.bsd:
-       @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
+       @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
        $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
@@ -204,22 +202,34 @@ link_a.bsd:
        SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
        fi; $(LINK_SO_A)
 link_app.bsd:
-       @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
+       @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
        LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBPATH)"; \
        fi; $(LINK_APP)
 
 # For Darwin AKA Mac OS/X (dyld)
-# link_o.darwin produces .so, because we let it use dso_dlfcn module,
-# which has .so extension hard-coded. One can argue that one should
-# develop special dso module for MacOS X. At least manual encourages
-# to use native NSModule(3) API and refers to dlfcn as termporary hack.
+# Originally link_o.darwin produced .so, because it was hard-coded
+# in dso_dlfcn module. At later point dso_dlfcn switched to .dylib
+# extension in order to allow for run-time linking with vendor-
+# supplied shared libraries such as libz, so that link_o.darwin had
+# to be harmonized with it. This caused minor controversy, because
+# it was believed that dlopen can't be used to dynamically load
+# .dylib-s, only so called bundle modules (ones linked with -bundle
+# flag). The belief seems to be originating from pre-10.4 release,
+# where dlfcn functionality was emulated by dlcompat add-on. In
+# 10.4 dlopen was rewritten as native part of dyld and is documented
+# to be capable of loading both dynamic libraries and bundles. In
+# order to provide compatibility with pre-10.4 dlopen, modules are
+# linked with -bundle flag, which makes .dylib extension misleading.
+# It works, because dlopen is [and always was] extension-agnostic.
+# Alternative to this heuristic approach is to develop specific
+# MacOS X dso module relying on whichever "native" dyld interface.
 link_o.darwin:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME); \
-       SHLIB_SUFFIX=.so; \
+       SHLIB_SUFFIX=.dylib; \
        ALLSYMSFLAGS='-all_load'; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
+       SHAREDFLAGS="$(CFLAGS) `echo $(SHARED_LDFLAGS) | sed s/dynamiclib/bundle/`"; \
        if [ -n "$(LIBVERSION)" ]; then \
                SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
        fi; \
@@ -240,7 +250,7 @@ link_a.darwin:
        if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
                SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
        fi; \
-       SHAREDFLAGS="$$SHAREDFLAGS -install_name ${INSTALLTOP}/lib/$$SHLIB${SHLIB_EXT}"; \
+       SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$(SHLIB_EXT)"; \
        $(LINK_SO_A)
 link_app.darwin:       # is there run-path on darwin?
        $(LINK_APP)
@@ -249,39 +259,60 @@ link_o.cygwin:
        @ $(CALC_VERSIONS); \
        INHIBIT_SYMLINKS=yes; \
        SHLIB=cyg$(LIBNAME); \
-       expr $(PLATFORM) : 'mingw' > /dev/null && SHLIB=$(LIBNAME); \
+       base=-Wl,--enable-auto-image-base; \
+       deffile=; \
+       if expr $(PLATFORM) : 'mingw' > /dev/null; then \
+               SHLIB=$(LIBNAME)eay32; base=; \
+               if test -f $(LIBNAME)eay32.def; then \
+                       deffile=$(LIBNAME)eay32.def; \
+               fi; \
+       fi; \
        SHLIB_SUFFIX=.dll; \
        LIBVERSION="$(LIBVERSION)"; \
        SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \
        ALLSYMSFLAGS='-Wl,--whole-archive'; \
        NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
-       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
+       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base $$deffile -Wl,-s,-Bsymbolic"; \
        $(LINK_SO_O)
+#for mingw target if def-file is in use dll-name should match library-name
 link_a.cygwin:
        @ $(CALC_VERSIONS); \
        INHIBIT_SYMLINKS=yes; \
-       SHLIB=cyg$(LIBNAME); def=; \
+       SHLIB=cyg$(LIBNAME); SHLIB_SOVER=-$(LIBVERSION); SHLIB_SUFFIX=.dll; \
+       dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; extras=; \
+       base=-Wl,--enable-auto-image-base; \
        if expr $(PLATFORM) : 'mingw' > /dev/null; then \
-               SHLIB=$(LIBNAME); \
-               def="$(LIBNAME).def"; \
-               $(PERL) util/mkdef.pl 32 $(LIBNAME) > $$def; \
+               case $(LIBNAME) in \
+                       crypto) SHLIB=libeay;; \
+                       ssl) SHLIB=ssleay;; \
+               esac; \
+               SHLIB_SOVER=32; \
+               extras="$(LIBNAME).def"; \
+               $(PERL) util/mkdef.pl 32 $$SHLIB > $$extras; \
+               base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
        fi; \
-       SHLIB_SUFFIX=.dll; \
-       SHLIB_SOVER=-$(LIBVERSION); \
+       dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
+       $(PERL) util/mkrc.pl $$dll_name | \
+               $(CROSS_COMPILE)windres -o rc.o; \
+       extras="$$extras rc.o"; \
        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"; \
-       [ -f apps/$$SHLIB$$SHLIB_SUFFIX ] && rm apps/$$SHLIB$$SHLIB_SUFFIX; \
-       [ -f test/$$SHLIB$$SHLIB_SUFFIX ] && rm test/$$SHLIB$$SHLIB_SUFFIX; \
+       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-s,-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; \
-       cp -p $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX apps/; \
-       cp -p $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX test/
+       rm $$extras; \
+       cp -p $$dll_name apps/; \
+       cp -p $$dll_name test/
 link_app.cygwin:
+       @if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
+               LIBDEPS="$(TOP)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
+               export LIBDEPS; \
+       fi; \
        $(LINK_APP)
 
 link_o.alpha-osf1:
-       @ if ${DETECT_GNU_LD}; then \
+       @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_SO); \
        else \
                SHLIB=lib$(LIBNAME).so; \
@@ -295,14 +326,14 @@ link_o.alpha-osf1:
                SHLIB_SOVER=; \
                ALLSYMSFLAGS='-all'; \
                NOALLSYMSFLAGS='-none'; \
-               SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared"; \
+               SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
                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 \
+       @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_SO); \
        else \
                SHLIB=lib$(LIBNAME).so; \
@@ -316,14 +347,14 @@ link_a.alpha-osf1:
                SHLIB_SOVER=; \
                ALLSYMSFLAGS='-all'; \
                NOALLSYMSFLAGS='-none'; \
-               SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared"; \
+               SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
                if [ -n "$$SHLIB_HIST" ]; then \
                        SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
                fi; \
        fi; \
        $(LINK_SO_A)
 link_app.alpha-osf1:
-       @if ${DETECT_GNU_LD}; then \
+       @if $(DETECT_GNU_LD); then \
                $(DO_GNU_APP); \
        else \
                LDFLAGS="$(CFLAGS) -rpath $(LIBRPATH)"; \
@@ -331,7 +362,7 @@ link_app.alpha-osf1:
        $(LINK_APP)
 
 link_o.solaris:
-       @ if ${DETECT_GNU_LD}; then \
+       @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_SO); \
        else \
                $(CALC_VERSIONS); \
@@ -345,12 +376,12 @@ link_o.solaris:
        fi; \
        $(LINK_SO_O)
 link_a.solaris:
-       @ if ${DETECT_GNU_LD}; then \
+       @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_SO); \
        else \
                $(CALC_VERSIONS); \
                MINUSZ='-z '; \
-               (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
+               ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=;\
                ALLSYMSFLAGS="$${MINUSZ}allextract"; \
@@ -359,7 +390,7 @@ link_a.solaris:
        fi; \
        $(LINK_SO_A)
 link_app.solaris:
-       @ if ${DETECT_GNU_LD}; then \
+       @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_APP); \
        else \
                LDFLAGS="$(CFLAGS) -R $(LIBRPATH)"; \
@@ -368,7 +399,7 @@ link_app.solaris:
 
 # OpenServer 5 native compilers used
 link_o.svr3:
-       @ if ${DETECT_GNU_LD}; then \
+       @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_SO); \
        else \
                $(CALC_VERSIONS); \
@@ -380,7 +411,7 @@ link_o.svr3:
        fi; \
        $(LINK_SO_O)
 link_a.svr3:
-       @ if ${DETECT_GNU_LD}; then \
+       @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_SO); \
        else \
                $(CALC_VERSIONS); \
@@ -392,12 +423,12 @@ link_a.svr3:
        fi; \
        $(LINK_SO_A_UNPACKED)
 link_app.svr3:
-       @${DETECT_GNU_LD} && $(DO_GNU_APP); \
+       @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
        $(LINK_APP)
 
 # UnixWare 7 and OpenUNIX 8 native compilers used
 link_o.svr5:
-       @ if ${DETECT_GNU_LD}; then \
+       @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_SO); \
        else \
                $(CALC_VERSIONS); \
@@ -411,12 +442,12 @@ link_o.svr5:
        fi; \
        $(LINK_SO_O)
 link_a.svr5:
-       @ if ${DETECT_GNU_LD}; then \
+       @ 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'; \
+               ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
                SHLIB=lib$(LIBNAME).so; \
                SHLIB_SUFFIX=; \
                ALLSYMSFLAGS=''; \
@@ -425,11 +456,11 @@ link_a.svr5:
        fi; \
        $(LINK_SO_A_UNPACKED)
 link_app.svr5:
-       @${DETECT_GNU_LD} && $(DO_GNU_APP); \
+       @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
        $(LINK_APP)
 
 link_o.irix:
-       @ if ${DETECT_GNU_LD}; then \
+       @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_SO); \
        else \
                $(CALC_VERSIONS); \
@@ -439,11 +470,11 @@ link_o.irix:
                ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
                ALLSYMSFLAGS="$${MINUSWL}-all"; \
                NOALLSYMSFLAGS="$${MINUSWL}-none"; \
-               SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
+               SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
        fi; \
        $(LINK_SO_O)
 link_a.irix:
-       @ if ${DETECT_GNU_LD}; then \
+       @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_SO); \
        else \
                $(CALC_VERSIONS); \
@@ -453,7 +484,7 @@ link_a.irix:
                ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
                ALLSYMSFLAGS="$${MINUSWL}-all"; \
                NOALLSYMSFLAGS="$${MINUSWL}-none"; \
-               SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
+               SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
        fi; \
        $(LINK_SO_A)
 link_app.irix:
@@ -469,7 +500,7 @@ link_app.irix:
 # ELFs by the way].
 #
 link_o.hpux:
-       @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
+       @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
        $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).sl; \
        expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
@@ -477,12 +508,12 @@ link_o.hpux:
        ALLSYMSFLAGS='-Wl,-Fl'; \
        NOALLSYMSFLAGS=''; \
        expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
-       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
+       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
        fi; \
        rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
        $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 link_a.hpux:
-       @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
+       @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
        $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).sl; \
        expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
@@ -490,38 +521,38 @@ link_a.hpux:
        ALLSYMSFLAGS='-Wl,-Fl'; \
        NOALLSYMSFLAGS=''; \
        expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
-       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
+       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
        fi; \
        rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
        $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 link_app.hpux:
-       @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
+       @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
        LDFLAGS="$(CFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
        fi; \
        $(LINK_APP)
 
 link_o.aix:
        @ $(CALC_VERSIONS); \
-       OBJECT_MODE=`expr x$(SHARED_LDFLAGS) : 'x\-[a-z]\([0-9]*\)'`; \
+       OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || :; \
        OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
        SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
-       ALLSYMSFLAGS='-bnogc'; \
+       ALLSYMSFLAGS=''; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -G -bE:lib$(LIBNAME).exp -bM:SRE'; \
-       $(LINK_SO_O); rm -rf lib$(LIBNAME).exp
+       SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
+       $(LINK_SO_O);
 link_a.aix:
        @ $(CALC_VERSIONS); \
-       OBJECT_MODE=`expr x$(SHARED_LDFLAGS) : 'x\-[a-z]\([0-9]*\)'`; \
+       OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || : ; \
        OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
        SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
        ALLSYMSFLAGS='-bnogc'; \
        NOALLSYMSFLAGS=''; \
-       SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -G -bE:lib$(LIBNAME).exp -bM:SRE'; \
+       SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
        $(LINK_SO_A_VIA_O)
 link_app.aix:
-       LDFLAGS="$(CFLAGS) -blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
+       LDFLAGS="$(CFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
        $(LINK_APP)
 
 link_o.reliantunix: