Enable weak enctypes for aklog if supported by Kerberos
[openafs.git] / src / cf / kerberos.m4
1 dnl
2 dnl $Id$
3 dnl
4 dnl Kerberos autoconf glue
5 dnl
6
7 AC_DEFUN([OPENAFS_KRB5CONF],[
8
9 dnl AC_ARG_VAR(KRB5CFLAGS, [C flags to compile Kerberos 5 programs])
10 dnl AC_ARG_VAR(KRB5LIBS, [Libraries and flags to compile Kerberos 5 programs])
11 dnl AC_ARG_VAR(KRB5_CONFIG, [Location of krb5-config script])
12
13 AC_ARG_WITH([krb5-conf],
14     [AS_HELP_STRING([--with-krb5-conf=@<:@krb5-config-location@:>@],
15         [use a krb5-config script to configure Kerberos])])
16
17 if test X$with_krb5_conf != X; then
18                 conf_krb5=YES
19                 if test X$with_krb5_conf = Xyes; then
20                         AC_PATH_PROG(KRB5_CONFIG, krb5-config, not_found)
21                         if test X$KRB5_CONFIG = Xnot_found; then
22                                 AC_MSG_ERROR([cannot find krb5-config script, you must configure Kerberos manually])
23                         fi
24                 else
25                         KRB5_CONFIG=$withval
26                 fi
27                 KRB5CFLAGS=`$KRB5_CONFIG --cflags krb5`
28                 retval=$?
29                 if test $retval -ne 0; then
30                         AC_MSG_ERROR([$KRB5_CONFIG failed with an error code of $retval])
31                 fi
32                 KRB5LIBS=`$KRB5_CONFIG --libs krb5`
33                 retval=$?
34                 if test $retval -ne 0; then
35                         AC_MSG_ERROR([$KRB5_CONFIG failed with an error code of $retval])
36                 fi
37                 AC_MSG_RESULT([Adding $KRB5CFLAGS to KRB5CFLAGS])
38                 AC_MSG_RESULT([Adding $KRB5LIBS to KRB5LIBS])
39 fi
40
41 AC_ARG_WITH([krb5], 
42     [AS_HELP_STRING([--with-krb5],
43         [support for Kerberos 5 (manual configuration)])])
44
45 if test X$with_krb5 != X; then
46         if test X$conf_krb5 = XYES; then
47                 AC_MSG_ERROR([--with-krb5-config and --with-krb5 are mutually exclusive, choose only one])
48         fi
49         if test "X$KRB5CFLAGS" = X; then
50                 AC_MSG_WARN([KRB5CFLAGS is not set])
51         fi
52         if test "X$KRB5LIBS" = X; then
53                 AC_MSG_WARN([KRB5LIBS is not set])
54         fi
55         conf_krb5=YES
56 fi
57
58 BUILD_KRB5=no
59 MAKE_KRB5=#
60 if test X$conf_krb5 = XYES; then
61         AC_MSG_RESULT([Configuring support for Kerberos 5 utilities])
62         BUILD_KRB5=yes
63         MAKE_KRB5=
64         save_CPPFLAGS="$CPPFLAGS"
65         CPPFLAGS="$CPPFLAGS $KRB5CFLAGS"
66         save_LIBS="$LIBS"
67         LIBS="$LIBS $KRB5LIBS"
68         AC_CHECK_FUNCS([add_to_error_table add_error_table krb5_princ_size krb5_principal_get_comp_string encode_krb5_enc_tkt_part encode_krb5_ticket krb5_c_encrypt krb5_decode_ticket krb5_get_prompt_types krb5_allow_weak_crypto krb5_enctype_enable])
69         AC_CHECK_FUNCS([krb5_524_convert_creds], ,
70             [AC_CHECK_FUNCS([krb524_convert_creds_kdc], ,
71                 [AC_CHECK_LIB([krb524], [krb524_convert_creds_kdc],
72                     [LIBS="-lkrb524 $LIBS"
73                      KRB5LIBS="-lkrb524 $LIBS"
74                      AC_DEFINE([HAVE_KRB524_CONVERT_CREDS_KDC], 1,
75                          [Define to 1 if you have the `krb524_convert_creds_kdc' function.])])])])
76         AC_CHECK_HEADERS([kerberosIV/krb.h])
77         AC_CHECK_HEADERS([kerberosV/heim_err.h])
78
79 AC_MSG_CHECKING(for krb5_creds.keyblock existence)
80 AC_CACHE_VAL(ac_cv_krb5_creds_keyblock_exists,
81 [
82 AC_TRY_COMPILE(
83 [#include <krb5.h>],
84 [krb5_creds _c;
85 printf("%x\n", _c.keyblock);], 
86 ac_cv_krb5_creds_keyblock_exists=yes,
87 ac_cv_krb5_creds_keyblock_exists=no)])
88 AC_MSG_RESULT($ac_cv_krb5_creds_keyblock_exists)
89         
90 AC_MSG_CHECKING(for krb5_creds.session existence)
91 AC_CACHE_VAL(ac_cv_krb5_creds_session_exists,
92 [
93 AC_TRY_COMPILE(
94 [#include <krb5.h>],
95 [krb5_creds _c;
96 printf("%x\n", _c.session);], 
97 ac_cv_krb5_creds_session_exists=yes,
98 ac_cv_krb5_creds_session_exists=no)])
99 AC_MSG_RESULT($ac_cv_krb5_creds_session_exists)
100
101 AC_MSG_CHECKING(for krb5_prompt.type existence)
102 AC_CACHE_VAL(ac_cv_krb5_prompt_type_exists,
103 [
104 AC_TRY_COMPILE(
105 [#include <krb5.h>],
106 [krb5_prompt _p;
107 printf("%x\n", _p.type);], 
108 ac_cv_krb5_prompt_type_exists=yes,
109 ac_cv_krb5_prompt_type_exists=no)])
110 AC_MSG_RESULT($ac_cv_krb5_prompt_type_exists)
111         
112 if test "x$ac_cv_krb5_creds_keyblock_exists" = "xyes"; then
113         AC_DEFINE(HAVE_KRB5_CREDS_KEYBLOCK, 1, [define if krb5_creds has keyblock])
114 fi
115 if test "x$ac_cv_krb5_creds_session_exists" = "xyes"; then
116         AC_DEFINE(HAVE_KRB5_CREDS_SESSION, 1, [define if krb5_creds has session])
117 fi
118 if test "x$ac_cv_krb5_prompt_type_exists" = "xyes"; then
119         AC_DEFINE(HAVE_KRB5_PROMPT_TYPE, 1, [define if krb5_prompt has type])
120 fi
121         
122 dnl     AC_CHECK_MEMBERS([krb5_creds.keyblock, krb5_creds.session],,, [#include <krb5.h>])
123         CPPFLAGS="$save_CPPFLAGS"
124         LIBS="$save_LIBS"
125 fi
126
127 AC_SUBST(BUILD_KRB5)
128 AC_SUBST(MAKE_KRB5)
129 AC_SUBST(KRB5CFLAGS)
130 AC_SUBST(KRB5LIBS)
131
132 ])dnl