dnl Check for LDAP dnl Copyright (C) 2005, 2007 Free Software Foundation, Inc. dnl dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. dnl dnl Defines @GPGKEYS_LDAP@ to a executable name if a working ldap dnl setup is found, and sets @LDAPLIBS@ to the necessary libraries. AC_DEFUN([GNUPG_CHECK_LDAP], [ # Try and link a LDAP test program to weed out unusable LDAP # libraries. -lldap [-llber [-lresolv]] is for older OpenLDAPs. # OpenLDAP, circa 1999, was terrible with creating weird dependencies. # If all else fails, the user can play guess-the-dependency by using # something like ./configure LDAPLIBS="-Lfoo -lbar" AC_ARG_WITH(ldap, AC_HELP_STRING([--with-ldap=DIR],[look for the LDAP library in DIR]), [_ldap_with=$withval]) if test x$_ldap_with != xno ; then if test -d "$withval" ; then LDAP_CPPFLAGS="-I$withval/include" LDAP_LDFLAGS="-L$withval/lib" fi _ldap_save_cppflags=$CPPFLAGS CPPFLAGS="${LDAP_CPPFLAGS} ${CPPFLAGS}" _ldap_save_ldflags=$LDFLAGS LDFLAGS="${LDAP_LDFLAGS} ${LDFLAGS}" _ldap_save_libs=$LIBS for MY_LDAPLIBS in ${LDAPLIBS+"$LDAPLIBS"} "-lldap" "-lldap -llber" "-lldap -llber -lresolv" "-lwldap32"; do LIBS="$MY_LDAPLIBS $1 $_ldap_save_libs" AC_MSG_CHECKING([whether LDAP via \"$MY_LDAPLIBS\" is present and sane]) AC_TRY_LINK([ #ifdef _WIN32 #include #include #else #include #endif ],[ldap_open("foobar",1234);], [gnupg_cv_func_ldap_init=yes],[gnupg_cv_func_ldap_init=no]) AC_MSG_RESULT([$gnupg_cv_func_ldap_init]) if test $gnupg_cv_func_ldap_init = no; then AC_MSG_CHECKING([whether I can make LDAP be sane with lber.h]) AC_TRY_LINK([#include #include ],[ldap_open("foobar",1234);], [gnupg_cv_func_ldaplber_init=yes],[gnupg_cv_func_ldaplber_init=no]) AC_MSG_RESULT([$gnupg_cv_func_ldaplber_init]) fi if test "$gnupg_cv_func_ldaplber_init" = yes ; then AC_DEFINE(NEED_LBER_H,1, [Define if the LDAP library requires including lber.h before ldap.h]) fi if test "$gnupg_cv_func_ldap_init" = yes || \ test "$gnupg_cv_func_ldaplber_init" = yes ; then LDAPLIBS="$LDAP_LDFLAGS $MY_LDAPLIBS" GPGKEYS_LDAP="gpgkeys_ldap$EXEEXT" break fi done if test "$GPGKEYS_LDAP" = "" ; then # It didn't work, so try for mozldap. We only do this via # pkg-config due to a really impressive dependency list. AC_PATH_PROG([_pkg_config],[pkg-config]) if test x$_pkg_config != x ; then AC_MSG_CHECKING([for mozldap]) LDAPLIBS=`$_pkg_config --libs mozldap 2>/dev/null` LDAP_CPPFLAGS=`$_pkg_config --cflags mozldap 2>/dev/null` if test x"$LDAPLIBS" = x && test x"$LDAP_CPPFLAGS" = x; then AC_MSG_RESULT([no]) else AC_MSG_RESULT([yes]) LIBS="$LDAPLIBS" GPGKEYS_LDAP="gpgkeys_ldap$EXEEXT" CPPFLAGS="${LDAP_CPPFLAGS} ${CPPFLAGS}" AC_CHECK_HEADERS([ldap_ssl.h],,,[#include ]) fi fi fi if test "$GPGKEYS_LDAP" != "" ; then # Whichever library we ended up with, check for some features... AC_CHECK_FUNCS(ldap_get_option ldap_set_option ldap_start_tls_s) if test "$ac_cv_func_ldap_get_option" != yes ; then AC_MSG_CHECKING([whether LDAP supports ld_errno]) AC_TRY_LINK([#include ],[LDAP *ldap; ldap->ld_errno;], [gnupg_cv_func_ldap_ld_errno=yes], [gnupg_cv_func_ldap_ld_errno=no]) AC_MSG_RESULT([$gnupg_cv_func_ldap_ld_errno]) if test "$gnupg_cv_func_ldap_ld_errno" = yes ; then AC_DEFINE(HAVE_LDAP_LD_ERRNO,1, [Define if the LDAP library supports ld_errno]) fi fi fi LIBS=$_ldap_save_libs CPPFLAGS=$_ldap_save_cppflags LDFLAGS=$_ldap_save_ldflags AC_SUBST(GPGKEYS_LDAP) AC_SUBST(LDAPLIBS) AC_SUBST(LDAP_CPPFLAGS) fi ])dnl