Fixed LDAP library file name bug (KNOWN_BUGS #1). configure now auto-detects
authorDan Fandrich <dan@coneharvesters.com>
Fri, 11 Mar 2005 05:28:07 +0000 (05:28 +0000)
committerDan Fandrich <dan@coneharvesters.com>
Fri, 11 Mar 2005 05:28:07 +0000 (05:28 +0000)
the correct dynamic library names by default, and provides override switches
--with-ldap-lib, --with-lber-lib and --without-lber-lib.  Added
CURL_DISABLE_LDAP to platform-specific config files to disable LDAP
support on those platforms that probably don't have dynamic OpenLDAP
libraries available to avoid compile errors.

acinclude.m4
configure.ac
docs/KNOWN_BUGS
lib/Makefile.netware
lib/config-amigaos.h
lib/config-mac.h
lib/config-riscos.h
lib/config-win32.h
lib/config.dj
lib/ldap.c
packages/vms/config-vms.h

index 552e6c81026e567bf650e9fb640bc4d4c30ec7bf..6e62f988d3d8d7bc0d669176d7ff5b519ee72a90 100644 (file)
@@ -766,3 +766,58 @@ AC_DEFUN([CURL_CC_DEBUG_OPTS],
 
 ]) dnl end of AC_DEFUN()
 
+
+dnl Determine the name of the library to pass to dlopen() based on the name
+dnl that would normally be given to AC_CHECK_LIB.  The preprocessor symbol
+dnl given is set to the quoted library file name. 
+dnl The standard dynamic library file name is first generated, based on the
+dnl current system type, then a search is performed for that file on the
+dnl standard dynamic library path.  If it is a symbolic link, the destination
+dnl of the link is used as the file name, after stripping off any minor
+dnl version numbers. If a library file can't be found, a guess is made.
+dnl This macro assumes AC_PROG_LIBTOOL has been called and requires perl
+dnl to be available.
+dnl
+dnl CURL_DLLIB_NAME(VARIABLE, library_name)
+dnl e.g. CURL_DLLIB_NAME(LDAP_NAME, ldap) on a Linux system might result
+dnl in LDAP_NAME holding the string "libldap.so.2".
+
+AC_DEFUN([CURL_DLLIB_NAME],
+[
+AC_MSG_CHECKING([name of dynamic library $2])
+
+dnl Create the dynamic library name of the correct form for this platform
+DLGUESSLIB=`name=$2 eval echo "$libname_spec"`
+DLGUESSFILE=`libname=$DLGUESSLIB release="" major="" eval echo "$soname_spec"`
+
+if test "$cross_compiling" = yes; then
+  dnl Can't look at filesystem when cross-compiling
+  AC_DEFINE_UNQUOTED($1, "$DLGUESSFILE", [$2 dynamic library file])
+  AC_MSG_RESULT([$DLGUESSFILE (guess while cross-compiling)])
+else
+
+  DLFOUNDFILE=""
+  if test "$sys_lib_dlsearch_path_spec" ; then
+    for direc in $sys_lib_dlsearch_path_spec ; do
+      DLTRYFILE="$direc/$DLGUESSFILE"
+      dnl Find where the symbolic link for this name points
+      changequote(<<, >>)dnl
+      <<
+      DLFOUNDFILE=`perl -e 'use File::Basename; (basename(readlink($ARGV[0])) =~ /^(.*[^\d]\.\d+)[\d\.]*$/ && print ${1}) || exit 1;' "$DLTRYFILE" 2>&5`
+      >>
+      changequote([, ])dnl
+      if test "$?" -eq "0"; then
+        dnl Found the file link
+        break
+      fi
+    done
+  fi
+
+  if test -z "$DLFOUNDFILE" ; then
+    DLFOUNDFILE="$DLGUESSFILE"
+  fi
+
+  AC_DEFINE_UNQUOTED($1, "$DLFOUNDFILE", [$2 dynamic library file])
+  AC_MSG_RESULT($DLFOUNDFILE)
+fi
+])
index e04088b01c0c482eabc34dc12d482fb56003f2d4..7fbb3c4f8438bd73173cb861c469adb900837d69 100644 (file)
@@ -371,6 +371,55 @@ AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
        AC_MSG_RESULT(no)
 )
 
+dnl **********************************************************************
+dnl Check for the name of dynamic OpenLDAP libraries
+dnl **********************************************************************
+
+LDAPLIBNAME=""
+AC_ARG_WITH(ldap-lib,
+AC_HELP_STRING([--with-ldap-lib=libname],[Specify name of dynamic ldap lib file]),
+ [LDAPLIBNAME="$withval"])
+
+LBERLIBNAME=""
+AC_ARG_WITH(lber-lib,
+AC_HELP_STRING([--with-lber-lib=libname],[Specify name of dynamic lber lib file]),
+ [LBERLIBNAME="$withval"])
+
+if test x$CURL_DISABLE_LDAP != x1 ; then
+
+  if test -z "$LDAPLIBNAME" ; then
+    case $host in
+      *-*-cygwin | *-*-mingw* | *-*-pw32*)
+        dnl Windows uses a single and unique OpenLDAP DLL name
+        LDAPLIBNAME="wldap32.dll"
+        LBERLIBNAME="no"
+        ;;
+    esac
+  fi
+
+  if test "$LDAPLIBNAME" ; then
+    AC_DEFINE_UNQUOTED(DL_LDAP_FILE, "$LDAPLIBNAME")
+    AC_MSG_CHECKING([name of dynamic library ldap])
+    AC_MSG_RESULT($LDAPLIBNAME)
+  else
+    dnl Try to find the right ldap library name for this system
+    CURL_DLLIB_NAME(DL_LDAP_FILE, ldap)
+  fi
+
+  if test "$LBERLIBNAME" ; then
+    dnl If name is "no" then don't define this variable at all
+    dnl (it's only needed if libldap.so's dependencies are broken).
+    if test "$LBERLIBNAME" != "no" ; then 
+      AC_DEFINE_UNQUOTED(DL_LBER_FILE, "$LBERLIBNAME")
+    fi
+    AC_MSG_CHECKING([name of dynamic library lber])
+    AC_MSG_RESULT($LBERLIBNAME)
+  else
+    dnl Try to find the right lber library name for this system
+    CURL_DLLIB_NAME(DL_LBER_FILE, lber)
+  fi
+fi
+
 dnl **********************************************************************
 dnl Check for the presence of the winmm library.
 dnl **********************************************************************
index 7cbb6280fa11d2e326f31177e0840e6c3227b00e..3634154d2e30fab6f18c37e9776cf76c6506dea9 100644 (file)
@@ -91,7 +91,3 @@ may have been fixed since this was written!
   and havoc is what happens.
   More details on this is found in this libcurl mailing list thread:
   http://curl.haxx.se/mail/lib-2002-08/0000.html
-
-1. LDAP support requires that not only the OpenLDAP shared libraries be
-   present at run time, but the development libraries (liblber.so and
-   libldap.so) as well (not applicable to Windows).
index 35c7932ceb889f624590adb64122fec5734b8e1c..a41656fbce5f1b2b35ffd1a2a9e519a6f9d73c45 100644 (file)
@@ -336,6 +336,7 @@ config.h: Makefile.netware
        @echo $(DL)#define SIZEOF_CURL_OFF_T 4$(DL) >> $@
        @echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
        @echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
+       @echo $(DL)#define CURL_DISABLE_LDAP 1$(DL) >> $@
 ifdef NW_WINSOCK
        @echo $(DL)#define HAVE_CLOSESOCKET 1$(DL) >> $@
 else
index 387adebf72dbf14fc06fc19e3f219f15c4f01f9d..88779753dcb12cbe5a36a63a6f706dac5ed96183 100644 (file)
@@ -57,6 +57,8 @@
 
 #define USE_OPENSSL 1
 #define USE_SSLEAY 1
+#define CURL_DISABLE_LDAP 1
+
 
 #define OS "AmigaOS"
 
index 8b0b0337c065d7afb6e36c8df561b05a7ca5cdad..d742452b196ca08059982cb815f0b7026097e6c6 100644 (file)
@@ -36,6 +36,8 @@
 #       define USE_OPENSSL      1
 #endif
 
+#define CURL_DISABLE_LDAP       1
+
 #define HAVE_RAND_STATUS        1
 #define HAVE_RAND_EGD           1
 
index 85dec3ea4fae54d2c2bc9288f045f78e5ffd3fe0..be18c8693160d833c5a6ef0992a3cf5174fac169 100644 (file)
 
 #define HAVE_FIONBIO
 
+/* to disable LDAP */
+#define CURL_DISABLE_LDAP
+
index a12394f2c8eb9628ce699c876cd4a033738164e6..e17ef98ae3ec9435e76756226566578b0526dc59 100644 (file)
 /* use ioctlsocket() for non-blocking sockets */
 #define HAVE_IOCTLSOCKET
 
+/* lber dynamic library file */
+/* #undef DL_LBER_FILE */
+
+/* ldap dynamic library file */
+#define DL_LDAP_FILE "wldap32.dll"
+
 /*************************************************
  * This section is for compiler specific defines.*
  *************************************************/
index f2d38d3da3ff31caa2c247cf701353593b184524..4b53bd9ae15f1edacc2b843ef62a100b3afb5b53 100644 (file)
@@ -93,6 +93,9 @@
   #define USE_OPENSSL            1
 #endif
 
+/* to disable LDAP */
+#define CURL_DISABLE_LDAP        1
+
 /* Because djgpp <= 2.03 doesn't have snprintf() etc.
  */
 #if (DJGPP_MINOR < 4)
index 15c19b377e02568c1ab54b675fb3a820ec78c305..bb8a8493321336384c30c7bafa11a68bfc73006f 100644 (file)
@@ -110,7 +110,7 @@ typedef void * (*dynafunc)(void *input);
  */
 #if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL) || defined(WIN32)
 static void *libldap = NULL;
-#ifndef WIN32
+#if defined(DL_LBER_FILE)
 static void *liblber = NULL;
 #endif
 #endif
@@ -120,24 +120,26 @@ static int DynaOpen(const char **mod_name)
 #if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL)
   if (libldap == NULL) {
     /*
-     * libldap.so should be able to resolve its dependency on
-     * liblber.so automatically, but since it does not we will
+     * libldap.so can normally resolve its dependency on liblber.so
+     * automatically, but in broken installation it does not so
      * handle it here by opening liblber.so as global.
      */
-    *mod_name = "liblber.so";
+#ifdef DL_LBER_FILE
+    *mod_name = DL_LBER_FILE;
     liblber = dlopen(*mod_name, DLOPEN_MODE);
+    if (!liblber)
+      return 0;
+#endif
 
     /* Assume loading libldap.so will fail if loading of liblber.so failed
      */
-    if (liblber)  {
-      *mod_name = "libldap.so";
-      libldap = dlopen(*mod_name, RTLD_LAZY);
-    }
+    *mod_name = DL_LDAP_FILE;
+    libldap = dlopen(*mod_name, RTLD_LAZY);
   }
-  return (libldap != NULL && liblber != NULL);
+  return (libldap != NULL);
 
 #elif defined(WIN32)
-  *mod_name = "wldap32.dll";
+  *mod_name = DL_LDAP_FILE;
   if (!libldap)
     libldap = (void*)LoadLibrary(*mod_name);
   return (libldap != NULL);
@@ -155,10 +157,12 @@ static void DynaClose(void)
     dlclose(libldap);
     libldap=NULL;
   }
+#ifdef DL_LBER_FILE
   if (liblber) {
     dlclose(liblber);
     liblber=NULL;
   }
+#endif
 #elif defined(WIN32)
   if (libldap) {
     FreeLibrary ((HMODULE)libldap);
index 275f0f12e071a3c760ffff9c09c4b51961bf538e..3152a8ae9a656d317cd64ba3757646432035c407 100644 (file)
 
 /* Somewhere around 7.12.0 HAVE_INET_NTOP was introduced. */
 #define HAVE_INET_NTOP 1
+
+/* to disable LDAP */
+#define CURL_DISABLE_LDAP 1