1 # Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 ## Squid software is distributed under GPLv2+ license and includes
4 ## contributions from numerous individuals and organizations.
5 ## Please see the COPYING and CONTRIBUTORS files for details.
8 dnl checks for LDAP functionality
9 AC_DEFUN([SQUID_LDAP_TEST],[
10 AC_CACHE_CHECK([for $1],[squid_cv_$1],[
11 SQUID_STATE_SAVE(squid_ldap_test_state)
12 LIBS="$LIBLDAP_PATH $LIBLDAP_LIBS $LIBPTHREADS"
13 CPPFLAGS="-DLDAP_DEPRECATED=1 -DLDAP_REFERRALS $CPPFLAGS"
14 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
17 # elif HAVE_MOZLDAP_LDAP_H
18 # include <mozldap/ldap.h>
28 SQUID_STATE_ROLLBACK(squid_ldap_test_state)
30 AC_DEFINE_UNQUOTED([HAVE_$1],${squid_cv_$1},[Define to 1 if you have $1])
33 dnl similar to SQUID_LDAP_TEST but runs the test program
34 AC_DEFUN([SQUID_LDAP_TEST_RUN],[
35 AC_CACHE_CHECK([for $1],[m4_translit([squid_cv_$1],[-+. ],[____])],[
36 SQUID_STATE_SAVE(squid_ldap_test_state)
37 LIBS="$LIBLDAP_PATH $LIBLDAP_LIBS $LIBPTHREADS"
38 CPPFLAGS="-DLDAP_DEPRECATED=1 -DLDAP_REFERRALS $CPPFLAGS"
39 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
42 # elif HAVE_MOZLDAP_LDAP_H
43 # include <mozldap/ldap.h>
48 m4_translit([squid_cv_$1],[-+. ],[____])=1
50 m4_translit([squid_cv_$1],[-+. ],[____])=0
52 m4_translit([squid_cv_$1],[-+. ],[____])=0
54 SQUID_STATE_ROLLBACK(squid_ldap_test_state)
56 AC_DEFINE_UNQUOTED([m4_translit([m4_translit([HAVE_$1],[-+. abcdefghijklmnopqrstuvwxyz],[____ABCDEFGHIJKLMNOPQRSTUVWXYZ])],[-+. ],[____])],
57 ${m4_translit([squid_cv_$1],[-+. ],[____])},[Define to 1 if you have $1])
60 dnl find the LDAP library vendor and define relevant HAVE_(vendor name) macro
61 AC_DEFUN([SQUID_LDAP_CHECK_VENDOR],[
62 SQUID_LDAP_TEST_RUN([OpenLDAP],[return strcmp(LDAP_VENDOR_NAME,"OpenLDAP")])
63 SQUID_LDAP_TEST_RUN([Sun LDAP SDK],[return strcmp(LDAP_VENDOR_NAME,"Sun Microsystems Inc.")])
64 SQUID_LDAP_TEST_RUN([Mozilla LDAP SDK],[return strcmp(LDAP_VENDOR_NAME,"mozilla.org")])
67 dnl check whether the LDAP library(s) provide the needed API and types
68 dnl define HAVE_DAP_* macros for each checked item
69 AC_DEFUN([SQUID_CHECK_LDAP_API],[
70 SQUID_LDAP_TEST([LDAP],[
73 ldap_init((const char *)&host, port);
75 SQUID_LDAP_CHECK_VENDOR
76 SQUID_LDAP_TEST([LDAP_OPT_DEBUG_LEVEL],[auto i=LDAP_OPT_DEBUG_LEVEL])
77 SQUID_LDAP_TEST([LDAP_SCOPE_DEFAULT],[auto i=LDAP_SCOPE_DEFAULT])
78 SQUID_LDAP_TEST([LDAP_REBIND_PROC],[LDAP_REBIND_PROC ldap_rebind])
79 SQUID_LDAP_TEST([LDAP_REBINDPROC_CALLBACK],[LDAP_REBINDPROC_CALLBACK ldap_rebind])
80 SQUID_LDAP_TEST([LDAP_REBIND_FUNCTION],[LDAP_REBIND_FUNCTION ldap_rebind])
82 dnl TODO check this test's code actually works, it looks broken
83 SQUID_LDAP_TEST([LDAP_URL_LUD_SCHEME],[struct ldap_url_desc.lud_scheme])
85 AC_CHECK_LIB(ldap,[ldapssl_client_init],[
86 AC_DEFINE(HAVE_LDAPSSL_CLIENT_INIT,1,[Define to 1 if you have ldapssl_client_init])
88 dnl Extract library names for AC_SEARCH_LIBS() to iterate.
89 LIBLDAP_NAMES="`echo "$LIBLDAP_LIBS" | sed -e 's/-l//g'`"
90 dnl If a AC_SEARCH_LIBS() finds a required library X then subsequent calls
91 dnl may produce a misleading "none required" result for the same library X
92 dnl because the first successful search adds -lX to LIBS.
93 AC_SEARCH_LIBS([ldap_url_desc2str],[$LIBLDAP_NAMES],[
94 AC_DEFINE(HAVE_LDAP_URL_DESC2STR,1,[Define to 1 if you have ldap_url_desc2str])
96 AC_SEARCH_LIBS([ldap_url_parse],[$LIBLDAP_NAMES],[
97 AC_DEFINE(HAVE_LDAP_URL_PARSE,1,[Define to 1 if you have ldap_url_parse])
99 AC_SEARCH_LIBS([ldap_start_tls_s],[$LIBLDAP_NAMES],[
100 AC_DEFINE(HAVE_LDAP_START_TLS_S,1,[Define to 1 if you have ldap_start_tls_s])