GSS_S_PROMPTING_NEEDED is a bit
[cyrus-sasl.git] / config / kerberos_v4.m4
1 dnl checking for kerberos 4 libraries (and DES)
2
3 AC_DEFUN([SASL_DES_CHK], [
4 AC_ARG_WITH(des, [  --with-des=DIR          with DES (look in DIR) [yes] ],
5         with_des=$withval,
6         with_des=yes)
7
8 LIB_DES=""
9 if test "$with_des" != no; then
10   if test -d $with_des; then
11     CPPFLAGS="$CPPFLAGS -I${with_des}/include"
12     LDFLAGS="$LDFLAGS -L${with_des}/lib"
13   fi
14
15   if test "$with_openssl" != no; then
16     dnl check for openssl installing -lcrypto, then make vanilla check
17     AC_CHECK_LIB(crypto, des_cbc_encrypt, [
18         AC_CHECK_HEADER(openssl/des.h, [AC_DEFINE(WITH_SSL_DES,[],[Use OpenSSL DES Implementation])
19                                        LIB_DES="-lcrypto";
20                                        with_des=yes],
21                        with_des=no)],
22         with_des=no, $LIB_RSAREF)
23
24     dnl same test again, different symbol name
25     if test "$with_des" = no; then
26       AC_CHECK_LIB(crypto, DES_cbc_encrypt, [
27         AC_CHECK_HEADER(openssl/des.h, [AC_DEFINE(WITH_SSL_DES,[],[Use OpenSSL DES Implementation])
28                                        LIB_DES="-lcrypto";
29                                        with_des=yes],
30                        with_des=no)],
31         with_des=no, $LIB_RSAREF)
32     fi
33   fi
34
35   if test "$with_des" = no; then
36     AC_CHECK_LIB(des, des_cbc_encrypt, [LIB_DES="-ldes";
37                                         with_des=yes], with_des=no)
38   fi
39
40   if test "$with_des" = no; then
41      AC_CHECK_LIB(des425, des_cbc_encrypt, [LIB_DES="-ldes425";
42                                        with_des=yes], with_des=no)
43   fi
44
45   if test "$with_des" = no; then
46      AC_CHECK_LIB(des524, des_cbc_encrypt, [LIB_DES="-ldes524";
47                                        with_des=yes], with_des=no)
48   fi
49
50   if test "$with_des" = no; then
51     dnl if openssl is around, we might be able to use that for des
52
53     dnl if openssl has been compiled with the rsaref2 libraries,
54     dnl we need to include the rsaref libraries in the crypto check
55     LIB_RSAREF=""
56     AC_CHECK_LIB(rsaref, RSAPublicEncrypt,
57                  LIB_RSAREF="-lRSAglue -lrsaref"; cmu_have_rsaref=yes,
58                  cmu_have_rsaref=no)
59
60     AC_CHECK_LIB(crypto, des_cbc_encrypt, [
61         AC_CHECK_HEADER(openssl/des.h, [AC_DEFINE(WITH_SSL_DES,[],[Use OpenSSL DES Implementation])
62                                         LIB_DES="-lcrypto";
63                                         with_des=yes],
64                         with_des=no)], 
65         with_des=no, $LIB_RSAREF)
66   fi
67 fi
68
69 if test "$with_des" != no; then
70   AC_DEFINE(WITH_DES,[],[Use DES])
71 fi
72
73 AC_SUBST(LIB_DES)
74 ])
75
76 AC_DEFUN([SASL_KERBEROS_V4_CHK], [
77   AC_REQUIRE([SASL_DES_CHK])
78
79   AC_ARG_ENABLE(krb4, [  --enable-krb4           enable KERBEROS_V4 authentication [[no]] ],
80     krb4=$enableval,
81     krb4=no)
82
83   if test "$krb4" != no; then
84     dnl In order to compile kerberos4, we need libkrb and libdes.
85     dnl (We've already gotten libdes from SASL_DES_CHK)
86     dnl we might need -lresolv for kerberos
87     AC_CHECK_LIB(resolv,res_search)
88
89     dnl if we were ambitious, we would look more aggressively for the
90     dnl krb4 install
91     if test -d ${krb4}; then
92        AC_CACHE_CHECK(for Kerberos includes, cyrus_krbinclude, [
93          for krbhloc in include/kerberosIV include/kerberos include
94          do
95            if test -f ${krb4}/${krbhloc}/krb.h ; then
96              cyrus_krbinclude=${krb4}/${krbhloc}
97              break
98            fi
99          done
100          ])
101
102        if test -n "${cyrus_krbinclude}"; then
103          CPPFLAGS="$CPPFLAGS -I${cyrus_krbinclude}"
104        fi
105        LDFLAGS="$LDFLAGS -L$krb4/lib"
106     fi
107
108     if test "$with_des" != no; then
109       AC_CHECK_HEADER(krb.h, [
110         AC_CHECK_LIB(com_err, com_err, [
111           AC_CHECK_LIB(krb, krb_mk_priv,
112                      [COM_ERR="-lcom_err"; SASL_KRB_LIB="-lkrb"; krb4lib="yes"],
113                      krb4lib=no, $LIB_DES -lcom_err)], [
114           AC_CHECK_LIB(krb, krb_mk_priv,
115                      [COM_ERR=""; SASL_KRB_LIB="-lkrb"; krb4lib="yes"],
116                      krb4lib=no, $LIB_DES)])], krb4="no")
117
118       if test "$krb4" != "no" -a "$krb4lib" = "no"; then
119         AC_CHECK_LIB(krb4, krb_mk_priv,
120                      [COM_ERR=""; SASL_KRB_LIB="-lkrb4"; krb4=yes],
121                      krb4=no, $LIB_DES)
122       fi
123       if test "$krb4" = no; then
124           AC_WARN(No Kerberos V4 found)
125       fi
126     else
127       AC_WARN(No DES library found for Kerberos V4 support)
128       krb4=no
129     fi
130   fi
131
132   if test "$krb4" != no; then
133     cmu_save_LIBS="$LIBS"
134     LIBS="$LIBS $SASL_KRB_LIB"
135     AC_CHECK_FUNCS(krb_get_err_text)
136     LIBS="$cmu_save_LIBS"
137   fi
138
139   AC_MSG_CHECKING(KERBEROS_V4)
140   if test "$krb4" != no; then
141     AC_MSG_RESULT(enabled)
142     SASL_MECHS="$SASL_MECHS libkerberos4.la"
143     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/kerberos4.c"
144     SASL_STATIC_OBJS="$SASL_STATIC_OBJS kerberos4.o"
145     AC_DEFINE(STATIC_KERBEROS4,[],[User KERBEROS_V4 Staticly])
146     AC_DEFINE(HAVE_KRB,[],[Do we have Kerberos 4 Support?])
147     SASL_KRB_LIB="$SASL_KRB_LIB $LIB_DES $COM_ERR"
148   else
149     AC_MSG_RESULT(disabled)
150   fi
151   AC_SUBST(SASL_KRB_LIB)
152 ])
153