1AC_DEFUN([DOVECOT_WANT_PAM], [
2  if test $want_pam != no; then
3          AC_CHECK_LIB(pam, pam_start, [
4                  have_pam=no
5                  AC_CHECK_HEADER(security/pam_appl.h, [
6                          AC_DEFINE(HAVE_SECURITY_PAM_APPL_H,,
7                                    [Define if you have security/pam_appl.h])
8                          have_pam=yes
9                  ])
10
11                  AC_CHECK_HEADER(pam/pam_appl.h, [
12                          AC_DEFINE(HAVE_PAM_PAM_APPL_H,,
13                                    [Define if you have pam/pam_appl.h])
14                          have_pam=yes
15                  ])
16          ], [
17            if test $want_pam = yes; then
18              AC_ERROR([Can't build with PAM support: libpam not found])
19            fi
20          ])
21  fi
22
23  if test "$have_pam" = "yes"; then
24    AUTH_LIBS="$AUTH_LIBS -lpam"
25    AC_DEFINE(PASSDB_PAM,, [Build with PAM support])
26    passdb="$passdb pam"
27
28    AC_CHECK_LIB(pam, pam_setcred, [
29      AC_DEFINE(HAVE_PAM_SETCRED,, [Define if you have pam_setcred()])
30    ])
31  elif test $want_pam = yes; then
32    AC_ERROR([Can't build with PAM support: pam_appl.h not found])
33  else
34    not_passdb="$not_passdb pam"
35  fi
36])
37