summaryrefslogtreecommitdiffstats
path: root/m4/want_ldap.m4
blob: 91d9e0f00e6df748b829dfa220cc8b2a2e3009c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
AC_DEFUN([DOVECOT_WANT_LDAP], [
  have_ldap=no
  if test $want_ldap != no; then
          AC_CHECK_LIB(ldap, ldap_init, [
                  AC_CHECK_HEADER(ldap.h, [
                          AC_CHECK_LIB(ldap, ldap_initialize, [
                                  AC_DEFINE(LDAP_HAVE_INITIALIZE,, [Define if you have ldap_initialize])
                          ])
                          AC_CHECK_LIB(ldap, ldap_start_tls_s, [
                                  AC_DEFINE(LDAP_HAVE_START_TLS_S,, [Define if you have ldap_start_tls_s])
                          ])
                          LDAP_LIBS="-lldap"
                          AC_CHECK_LIB(ldap, ber_free, [
                            # do nothing, default is to add -lldap to LIBS
                            :
                          ], [
                            AC_CHECK_LIB(lber, ber_free, [
                              LDAP_LIBS="$LDAP_LIBS -llber"
                            ])
                          ])
                          AC_SUBST(LDAP_LIBS)
                          if test $want_ldap != plugin; then
                                  AUTH_LIBS="$AUTH_LIBS $LDAP_LIBS"
                                  DICT_LIBS="$DICT_LIBS $LDAP_LIBS"
                                  AC_DEFINE(BUILTIN_LDAP,, [LDAP support is built in])
                          fi
  
                          AC_DEFINE(USERDB_LDAP,, [Build with LDAP support])
                          AC_DEFINE(PASSDB_LDAP,, [Build with LDAP support])
                          AC_CHECK_HEADERS(sasl.h sasl/sasl.h)
                          have_ldap=yes
                  ], [
                    if test $want_ldap != auto; then
                      AC_ERROR([Can't build with LDAP support: ldap.h not found])
                    fi
                  ])
          ], [
            if test $want_ldap != auto; then
              AC_ERROR([Can't build with LDAP support: libldap not found])
            fi
          ])
  fi
  
  if test $have_ldap = no; then
    not_passdb="$not_passdb ldap"
    not_userdb="$not_userdb ldap"
  else
    userdb="$userdb ldap"
    passdb="$passdb ldap"
    if test $want_ldap = plugin; then
      have_ldap_plugin=yes
      userdb="$userdb (plugin)"
      passdb="$passdb (plugin)"
    fi
  fi
  AM_CONDITIONAL(LDAP_PLUGIN, test "$have_ldap_plugin" = "yes")
  AM_CONDITIONAL(HAVE_LDAP, test "$want_ldap" != "no")
])