Print

Print


Mac OS X makes a distinction between shared libraries and shared modules.  Shared libraries end in .dylib and are loaded when the executable starts up.  Shared modules end in .so and can be loaded during runtime using dlopen.

This patch makes XrdCrypto and friends shared modules, and uses an autoconf macro to auto-determine the shared library extension.

This patch also generates a few warnings when shared libraries (such as libXrdClient) are linked against the shared modules.  In testing, this seems to be harmless.
---
 configure.ac                      |    2 ++
 src/XrdCrypto/Makefile.am         |    3 +++
 src/XrdCrypto/XrdCryptoFactory.cc |    8 ++++++--
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 770fcaa..0232eea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1017,6 +1017,8 @@ fi
 
 AM_CONDITIONAL(ENABLE_SECSSL,test x"$activate_secssl" = xyes -o x"$activate_secssl" = xdefault_yes)
 
+# Record the extension of dynamic libraries on this platform
+LT_SYS_MODULE_EXT
 
 ###########################################
 # tkauthz checks
diff --git a/src/XrdCrypto/Makefile.am b/src/XrdCrypto/Makefile.am
index 9b2f3a9..edd19b7 100644
--- a/src/XrdCrypto/Makefile.am
+++ b/src/XrdCrypto/Makefile.am
@@ -70,11 +70,13 @@ libXrdCrypto_la_LIBADD = libXrdSSLutil.la \
                          ../XrdSys/libXrdSys.la \
                          ../XrdNet/libXrdNet.la \
                          ../XrdNet/libXrdNetUtil.la
+libXrdCrypto_la_LDFLAGS = -module
 
 libXrdCryptoLite_la_SOURCES = \
         XrdCryptoLite.hh \
         XrdCryptoLite.cc \
         XrdCryptoLite_bf32.cc
+libXrdCryptoLite_la_LDFLAGS = -module
 libXrdCrytoLite_la_CXXFLAGS = $(SSLCXXFLAGS)
 
 
@@ -91,6 +93,7 @@ libXrdCryptossl_la_SOURCES = \
         XrdCryptosslgsiX509Chain.cc
 libXrdCryptossl_la_LIBADD = ../XrdSut/libXrdSut.la \
                             $(OPENSSL_LIBDIR) -lssl -lcrypto
+libXrdCryptossl_la_LDFLAGS = -module
 libXrdCryptossl_la_CXXFLAGS = $(SSLCXXFLAGS)
 
 
diff --git a/src/XrdCrypto/XrdCryptoFactory.cc b/src/XrdCrypto/XrdCryptoFactory.cc
index 6f110b5..ec9ed1f 100644
--- a/src/XrdCrypto/XrdCryptoFactory.cc
+++ b/src/XrdCrypto/XrdCryptoFactory.cc
@@ -26,6 +26,10 @@ const char *XrdCryptoFactoryCVSID = "$Id$";
 #include <XrdCrypto/XrdCryptoFactory.hh>
 #include <XrdCrypto/XrdCryptolocalFactory.hh>
 
+#ifndef LT_MODULE_EXT
+#define LT_MODULE_EXT ".so"
+#endif
+
 // We have always an instance of the simple RSA implementation
 static XrdCryptolocalFactory localCryptoFactory;
 
@@ -374,7 +378,7 @@ XrdCryptoFactory *XrdCryptoFactory::GetCryptoFactory(const char *factoryid)
 
    //
    // Form library name
-   snprintf(libfn, sizeof(libfn)-1, "libXrdCrypto.so");
+   snprintf(libfn, sizeof(libfn)-1, "libXrdCrypto%s", LT_MODULE_EXT);
    libfn[sizeof(libfn)-1] = '\0';
 
    //
@@ -396,7 +400,7 @@ XrdCryptoFactory *XrdCryptoFactory::GetCryptoFactory(const char *factoryid)
 
       //
       // Try also specific library name
-      snprintf(libfn, sizeof(libfn)-1, "libXrdCrypto%s.so", factoryid);
+      snprintf(libfn, sizeof(libfn)-1, "libXrdCrypto%s%s", factoryid, LT_MODULE_EXT);
       libfn[sizeof(libfn)-1] = '\0';
       
       //
-- 
1.7.3.1