aklog-no-kimpersonate-in-more-cases-20071105
[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],[--with-krb5-conf[=krb5-config-location]    Use a krb5-config script to configure Kerberos])
14 if test X$with_krb5_conf != X; then
15                 conf_krb5=YES
16                 if test X$with_krb5_conf = Xyes; then
17                         AC_PATH_PROG(KRB5_CONFIG, krb5-config, not_found)
18                         if test X$KRB5_CONFIG = Xnot_found; then
19                                 AC_MSG_ERROR([cannot find krb5-config script, you must configure Kerberos manually])
20                         fi
21                 else
22                         KRB5_CONFIG=$withval
23                 fi
24                 KRB5CFLAGS=`$KRB5_CONFIG --cflags krb5`
25                 retval=$?
26                 if test $retval -ne 0; then
27                         AC_MSG_ERROR([$KRB5_CONFIG failed with an error code of $retval])
28                 fi
29                 KRB5LIBS=`$KRB5_CONFIG --libs krb5`
30                 retval=$?
31                 if test $retval -ne 0; then
32                         AC_MSG_ERROR([$KRB5_CONFIG failed with an error code of $retval])
33                 fi
34                 AC_MSG_RESULT([Adding $KRB5CFLAGS to KRB5CFLAGS])
35                 AC_MSG_RESULT([Adding $KRB5LIBS to KRB5LIBS])
36 fi
37
38 AC_ARG_WITH([krb5], [--with-krb5 Support for Kerberos 5 (manual configuration)])
39
40 if test X$with_krb5 = Xyes; then
41         if test X$conf_krb5 = XYES; then
42                 AC_MSG_ERROR([--with-krb5-config and --with-krb5 are mutually exclusive, choose only one])
43         fi
44         if test "X$KRB5CFLAGS" = X; then
45                 AC_MSG_WARN([KRB5CFLAGS is not set])
46         fi
47         if test "X$KRB5LIBS" = X; then
48                 AC_MSG_WARN([KRB5LIBS is not set])
49         fi
50         conf_krb5=YES
51 fi
52
53 BUILD_KRB5=no
54 if test X$conf_krb5 = XYES; then
55         AC_MSG_RESULT([Configuring support for Kerberos 5 utilities])
56         BUILD_KRB5=yes
57         save_CPPFLAGS="$CPPFLAGS"
58         CPPFLAGS="$CPPFLAGS $KRB5CFLAGS"
59         save_LIBS="$LIBS"
60         LIBS="$LIBS $KRB5LIBS"
61         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_c_encrypt_length])
62         AC_CHECK_FUNCS([krb5_524_convert_creds], ,
63             [AC_CHECK_FUNCS([krb524_convert_creds_kdc], ,
64                 [AC_CHECK_LIB([krb524], [krb524_convert_creds_kdc],
65                     [LIBS="-lkrb524 $LIBS"
66                      KRB5LIBS="-lkrb524 $LIBS"
67                      AC_DEFINE([HAVE_KRB524_CONVERT_CREDS_KDC], 1,
68                          [Define to 1 if you have the `krb524_convert_creds_kdc' function.])])])])
69         AC_CHECK_HEADERS([kerberosIV/krb.h])
70         AC_CHECK_HEADERS([kerberosV/heim_err.h])
71
72 AC_MSG_CHECKING(for krb5_creds.keyblock existence)
73 AC_CACHE_VAL(ac_cv_krb5_creds_keyblock_exists,
74 [
75 AC_TRY_COMPILE(
76 [#include <krb5.h>],
77 [krb5_creds _c;
78 printf("%x\n", _c.keyblock);], 
79 ac_cv_krb5_creds_keyblock_exists=yes,
80 ac_cv_krb5_creds_keyblock_exists=no)])
81 AC_MSG_RESULT($ac_cv_krb5_creds_keyblock_exists)
82         
83 AC_MSG_CHECKING(for krb5_creds.session existence)
84 AC_CACHE_VAL(ac_cv_krb5_creds_session_exists,
85 [
86 AC_TRY_COMPILE(
87 [#include <krb5.h>],
88 [krb5_creds _c;
89 printf("%x\n", _c.session);], 
90 ac_cv_krb5_creds_session_exists=yes,
91 ac_cv_krb5_creds_session_exists=no)])
92 AC_MSG_RESULT($ac_cv_krb5_creds_session_exists)
93
94 if test "x$ac_cv_krb5_creds_keyblock_exists" = "xyes"; then
95         AC_DEFINE(HAVE_KRB5_CREDS_KEYBLOCK, 1, [define if krb5_creds has keyblock])
96 fi
97 if test "x$ac_cv_krb5_creds_session_exists" = "xyes"; then
98         AC_DEFINE(HAVE_KRB5_CREDS_SESSION, 1, [define if krb5_creds has session])
99 fi
100         
101 dnl     AC_CHECK_MEMBERS([krb5_creds.keyblock, krb5_creds.session],,, [#include <krb5.h>])
102         CPPFLAGS="$save_CPPFLAGS"
103         LIBS="$save_LIBS"
104 fi
105
106 AC_SUBST(BUILD_KRB5)
107 AC_SUBST(KRB5CFLAGS)
108 AC_SUBST(KRB5LIBS)
109
110 ])dnl