test-heimdal-20060217
[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 krb5_524_convert_creds krb524_convert_creds_kdc])
62         AC_CHECK_HEADERS([kerberosIV/krb.h])
63         AC_CHECK_HEADERS([kerberosV/heim_err.h])
64
65 AC_MSG_CHECKING(for krb5_creds.keyblock existence)
66 AC_CACHE_VAL(ac_cv_krb5_creds_keyblock_exists,
67 [
68 AC_TRY_COMPILE(
69 [#include <krb5.h>],
70 [krb5_creds _c;
71 printf("%x\n", _c.keyblock);], 
72 ac_cv_krb5_creds_keyblock_exists=yes,
73 ac_cv_krb5_creds_keyblock_exists=no)])
74 AC_MSG_RESULT($ac_cv_krb5_creds_keyblock_exists)
75         
76 AC_MSG_CHECKING(for krb5_creds.session existence)
77 AC_CACHE_VAL(ac_cv_krb5_creds_session_exists,
78 [
79 AC_TRY_COMPILE(
80 [#include <krb5.h>],
81 [krb5_creds _c;
82 printf("%x\n", _c.session);], 
83 ac_cv_krb5_creds_session_exists=yes,
84 ac_cv_krb5_creds_session_exists=no)])
85 AC_MSG_RESULT($ac_cv_krb5_creds_session_exists)
86
87 if test "x$ac_cv_krb5_creds_keyblock_exists" = "xyes"; then
88         AC_DEFINE(HAVE_KRB5_CREDS_KEYBLOCK, 1, [define if krb5_creds has keyblock])
89 fi
90 if test "x$ac_cv_krb5_creds_session_exists" = "xyes"; then
91         AC_DEFINE(HAVE_KRB5_CREDS_SESSION, 1, [define if krb5_creds has session])
92 fi
93         
94 dnl     AC_CHECK_MEMBERS([krb5_creds.keyblock, krb5_creds.session],,, [#include <krb5.h>])
95         CPPFLAGS="$save_CPPFLAGS"
96         LIBS="$save_LIBS"
97 fi
98
99 if test "$ac_cv_header_kerberosV_heim_err_h" = "yes"; then
100     ASETKEY=
101 else
102     ASETKEY=asetkey
103 fi
104
105 AC_SUBST(BUILD_KRB5)
106 AC_SUBST(KRB5CFLAGS)
107 AC_SUBST(KRB5LIBS)
108 AC_SUBST(ASETKEY)
109
110 ])dnl