]>
Commit | Line | Data |
---|---|---|
b8ae064d | 1 | # Copyright (C) 1996-2023 The Squid Software Foundation and contributors |
0d57ed2e AJ |
2 | ## |
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. | |
6 | ## | |
7 | ||
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([[ | |
15 | # if HAVE_LDAP_H | |
16 | # include <ldap.h> | |
17 | # elif HAVE_MOZLDAP_LDAP_H | |
18 | # include <mozldap/ldap.h> | |
19 | # endif | |
20 | ]],[[$2]]) | |
21 | ],[ | |
22 | squid_cv_$1=1 | |
23 | ],[ | |
24 | squid_cv_$1=0 | |
25 | ],[ | |
26 | squid_cv_$1=0 | |
27 | ]) | |
28 | SQUID_STATE_ROLLBACK(squid_ldap_test_state) | |
29 | ]) | |
30 | AC_DEFINE_UNQUOTED([HAVE_$1],${squid_cv_$1},[Define to 1 if you have $1]) | |
31 | ]) | |
32 | ||
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([[ | |
40 | # if HAVE_LDAP_H | |
41 | # include <ldap.h> | |
42 | # elif HAVE_MOZLDAP_LDAP_H | |
43 | # include <mozldap/ldap.h> | |
44 | # endif | |
45 | # include <string.h> | |
46 | ]],[[$2]]) | |
47 | ],[ | |
48 | m4_translit([squid_cv_$1],[-+. ],[____])=1 | |
49 | ],[ | |
50 | m4_translit([squid_cv_$1],[-+. ],[____])=0 | |
51 | ],[ | |
52 | m4_translit([squid_cv_$1],[-+. ],[____])=0 | |
53 | ]) | |
54 | SQUID_STATE_ROLLBACK(squid_ldap_test_state) | |
55 | ]) | |
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]) | |
58 | ]) | |
59 | ||
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")]) | |
65 | ]) | |
66 | ||
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],[ | |
71 | char host[]=""; | |
72 | int port; | |
73 | ldap_init((const char *)&host, port); | |
74 | ]) | |
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]) | |
81 | ||
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]) | |
84 | ||
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]) | |
87 | ]) | |
959f72e0 AR |
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],[ | |
0d57ed2e AJ |
94 | AC_DEFINE(HAVE_LDAP_URL_DESC2STR,1,[Define to 1 if you have ldap_url_desc2str]) |
95 | ]) | |
959f72e0 | 96 | AC_SEARCH_LIBS([ldap_url_parse],[$LIBLDAP_NAMES],[ |
0d57ed2e AJ |
97 | AC_DEFINE(HAVE_LDAP_URL_PARSE,1,[Define to 1 if you have ldap_url_parse]) |
98 | ]) | |
959f72e0 | 99 | AC_SEARCH_LIBS([ldap_start_tls_s],[$LIBLDAP_NAMES],[ |
0d57ed2e AJ |
100 | AC_DEFINE(HAVE_LDAP_START_TLS_S,1,[Define to 1 if you have ldap_start_tls_s]) |
101 | ]) | |
0d57ed2e | 102 | ]) |