From 4db954f802d4806977bbb5f1169b022c7e7a79cc Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 14 Oct 2007 21:25:10 +0000 Subject: Add custom check for LDAP libraries --- acinclude.m4 | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 20 +++++++--------- 2 files changed, 85 insertions(+), 11 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 6a19cd805..66dfca0b8 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -467,6 +467,82 @@ AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [ ]) +dnl CURL_CHECK_LIBS_LDAP +dnl ------------------------------------------------- +dnl Check for libraries needed for LDAP support, +dnl and prepended to LIBS any needed libraries. + +AC_DEFUN([CURL_CHECK_LIBS_LDAP], [ + AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl + # + AC_MSG_CHECKING([libraries for LDAP support]) + # + curl_cv_save_LIBS=$LIBS + curl_cv_ldap_LIBS="unknown" + # + for x_nlibs in '' '-ldap' '-lber -ldap' '-ldap -lber'; do + if test -z "$x_nlibs"; then + LIBS="$curl_cv_save_LIBS" + else + LIBS="$x_nlibs $curl_cv_save_LIBS" + fi + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ +#undef inline +#ifdef HAVE_WINDOWS_H +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#endif +#ifndef LDAP_DEPRECATED +#define LDAP_DEPRECATED 1 +#endif +#ifdef NEED_LBER_H +#include +#endif +#ifdef HAVE_LDAP_H +#include +#endif" + ],[ + BerValue *bvp = NULL; + BerElement *bep = ber_init(bvp); + LDAP *ldp = ldap_init("dummy", LDAP_PORT); + int res = ldap_unbind(ldp); + ber_free(bep, 1); + ]) + ],[ + curl_cv_ldap_LIBS="$x_nlibs" + break + ]) + done + # + LIBS=$curl_cv_save_LIBS + # + case X-"$curl_cv_ldap_LIBS" in + X-unknown) + AC_MSG_RESULT([cannot find libraries for LDAP support]) + ;; + X-) + AC_MSG_RESULT([no additional lib required]) + ;; + *) + if test -z "$curl_cv_save_LIBS"; then + LIBS="$curl_cv_ldap_LIBS" + else + LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS" + fi + AC_MSG_RESULT([$curl_cv_ldap_LIBS]) + ;; + esac + # +]) + + dnl CURL_CHECK_HEADER_MALLOC dnl ------------------------------------------------- dnl Check for compilable and valid malloc.h header, diff --git a/configure.ac b/configure.ac index c4d626097..cc50eac11 100644 --- a/configure.ac +++ b/configure.ac @@ -567,11 +567,15 @@ if test x$CURL_DISABLE_LDAP != x1 ; then AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP]) AC_SUBST(CURL_DISABLE_LDAP, [1])]) else - dnl Try to find the right ldap library name for this system - AC_SEARCH_LIBS(ldap_init, [ldap],, [ - AC_MSG_WARN([Cannot find LDAP library: LDAP disabled]) - AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP]) - AC_SUBST(CURL_DISABLE_LDAP, [1])]) + dnl Try to find the right ldap libraries for this system + CURL_CHECK_LIBS_LDAP + case X-"$curl_cv_ldap_LIBS" in + X-unknown) + AC_MSG_WARN([Cannot find libraries for LDAP support: LDAP disabled]) + AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP]) + AC_SUBST(CURL_DISABLE_LDAP, [1]) + ;; + esac fi fi @@ -586,12 +590,6 @@ if test x$CURL_DISABLE_LDAP != x1 ; then AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP]) AC_SUBST(CURL_DISABLE_LDAP, [1])]) fi - else - dnl Try to find the right lber library name for this system - AC_SEARCH_LIBS(ber_free, [lber],, [ - AC_MSG_WARN([Cannot find a library defining ber_free(): LDAP disabled]) - AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP]) - AC_SUBST(CURL_DISABLE_LDAP, [1])]) fi fi -- cgit v1.2.3