Correct example.
[openssl.git] / Makefile.shared
index 6f0f5ce..e753f44 100644 (file)
@@ -14,6 +14,8 @@ CFLAGS=$(CFLAG)
 LDFLAGS=
 SHARED_LDFLAGS=
 
+NM=nm
+
 # LIBNAME contains just the name of the library, without prefix ("lib"
 # on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
 # .dll, ...).  This one MUST have a value when using this makefile to
@@ -89,25 +91,25 @@ CALC_VERSIONS=      \
 
 LINK_APP=      \
   ( $(SET_X);   \
-    LIBDEPS=$${LIBDEPS:-$(LIBDEPS)}; \
-    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`; \
+    LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
+    LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS)}"; \
+    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:=$(CC)} $${LDFLAGS:=$(CFLAGS)} \
-       -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $$LIBDEPS )
+    $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
 
 LINK_SO=       \
   ( $(SET_X);   \
-    LIBDEPS=$${LIBDEPS:-$(LIBDEPS)}; \
-    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`; \
+    LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
+    SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \
+    SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \
+    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:=$(CC)} $${SHAREDFLAGS:=$(CFLAGS) $(SHARED_LDFLAGS)} \
+    $${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 \
@@ -133,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; \
@@ -142,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; \
@@ -168,8 +170,19 @@ link_a.gnu:
 link_app.gnu:
        @ $(DO_GNU_APP); $(LINK_APP)
 
+DO_BEOS_SO=    SHLIB=lib$(LIBNAME).so; \
+       SHLIB_SUFFIX=; \
+       ALLSYMSFLAGS='-Wl,--whole-archive'; \
+       NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
+       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SUFFIX"
+
+link_o.beos:
+       @ $(DO_BEOS_SO); $(LINK_SO_O)
+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=; \
@@ -179,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=; \
@@ -189,17 +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)
+# 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=.dylib; \
        ALLSYMSFLAGS='-all_load'; \
        NOALLSYMSFLAGS=''; \
+       SHAREDFLAGS="$(CFLAGS) `echo $(SHARED_LDFLAGS) | sed s/dynamiclib/bundle/`"; \
        if [ -n "$(LIBVERSION)" ]; then \
                SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
        fi; \
@@ -213,12 +243,14 @@ link_a.darwin:
        SHLIB_SUFFIX=.dylib; \
        ALLSYMSFLAGS='-all_load'; \
        NOALLSYMSFLAGS=''; \
+       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
        if [ -n "$(LIBVERSION)" ]; then \
                SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
        fi; \
        if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
                SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
        fi; \
+       SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$(SHLIB_EXT)"; \
        $(LINK_SO_A)
 link_app.darwin:       # is there run-path on darwin?
        $(LINK_APP)
@@ -227,35 +259,60 @@ link_o.cygwin:
        @ $(CALC_VERSIONS); \
        INHIBIT_SYMLINKS=yes; \
        SHLIB=cyg$(LIBNAME); \
-       expr $(PLATFORM) : 'mingw' > /dev/null && SHLIB=$(LIBNAME)eay32; \
+       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); \
-       expr $(PLATFORM) : 'mingw' > /dev/null && SHLIB=$(LIBNAME)eay32; \
-       SHLIB_SUFFIX=.dll; \
-       SHLIB_SOVER=-$(LIBVERSION); \
+       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 \
+               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; \
+       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"; \
-       [ -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; \
@@ -269,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\""; \
+                       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; \
@@ -290,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\""; \
+                       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)"; \
@@ -305,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); \
@@ -319,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"; \
@@ -333,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)"; \
@@ -342,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); \
@@ -354,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); \
@@ -366,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); \
@@ -385,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=''; \
@@ -399,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); \
@@ -413,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); \
@@ -427,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:
@@ -443,19 +500,20 @@ 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 $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
+       expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
        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; \
@@ -463,37 +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)"; \
+       LDFLAGS="$(CFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
        $(LINK_APP)
 
 link_o.reliantunix:
@@ -532,7 +591,7 @@ symlink.hpux:
        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:
+symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath symlink.beos:
 
 # Compatibility targets
 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
@@ -590,3 +649,7 @@ link_o.reliantunix-shared: link_o.reliantunix
 link_a.reliantunix-shared: link_a.reliantunix
 link_app.reliantunix-shared: link_app.reliantunix
 symlink.reliantunix-shared: symlink.reliantunix
+link_o.beos-shared: link_o.beos
+link_a.beos-shared: link_a.beos
+link_app.beos-shared: link_app.gnu
+symlink.beos-shared: symlink.beos