autoconf-help-text-20080713
[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 = Xyes; 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 if test X$conf_krb5 = XYES; then
60         AC_MSG_RESULT([Configuring support for Kerberos 5 utilities])
61         BUILD_KRB5=yes
62         save_CPPFLAGS="$CPPFLAGS"
63         CPPFLAGS="$CPPFLAGS $KRB5CFLAGS"
64         save_LIBS="$LIBS"
65         LIBS="$LIBS $KRB5LIBS"
66         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 krb5_cc_register krb5_decode_ticket krb5_get_prompt_types])
67         AC_CHECK_FUNCS([krb5_524_convert_creds], ,
68             [AC_CHECK_FUNCS([krb524_convert_creds_kdc], ,
69                 [AC_CHECK_LIB([krb524], [krb524_convert_creds_kdc],
70                     [LIBS="-lkrb524 $LIBS"
71                      KRB5LIBS="-lkrb524 $LIBS"
72                      AC_DEFINE([HAVE_KRB524_CONVERT_CREDS_KDC], 1,
73                          [Define to 1 if you have the `krb524_convert_creds_kdc' function.])])])])
74         AC_CHECK_HEADERS([kerberosIV/krb.h])
75         AC_CHECK_HEADERS([kerberosV/heim_err.h])
76
77 AC_MSG_CHECKING(for krb5_creds.keyblock existence)
78 AC_CACHE_VAL(ac_cv_krb5_creds_keyblock_exists,
79 [
80 AC_TRY_COMPILE(
81 [#include <krb5.h>],
82 [krb5_creds _c;
83 printf("%x\n", _c.keyblock);], 
84 ac_cv_krb5_creds_keyblock_exists=yes,
85 ac_cv_krb5_creds_keyblock_exists=no)])
86 AC_MSG_RESULT($ac_cv_krb5_creds_keyblock_exists)
87         
88 AC_MSG_CHECKING(for krb5_creds.session existence)
89 AC_CACHE_VAL(ac_cv_krb5_creds_session_exists,
90 [
91 AC_TRY_COMPILE(
92 [#include <krb5.h>],
93 [krb5_creds _c;
94 printf("%x\n", _c.session);], 
95 ac_cv_krb5_creds_session_exists=yes,
96 ac_cv_krb5_creds_session_exists=no)])
97 AC_MSG_RESULT($ac_cv_krb5_creds_session_exists)
98
99 AC_MSG_CHECKING(for krb5_prompt.type existence)
100 AC_CACHE_VAL(ac_cv_krb5_prompt_type_exists,
101 [
102 AC_TRY_COMPILE(
103 [#include <krb5.h>],
104 [krb5_prompt _p;
105 printf("%x\n", _p.type);], 
106 ac_cv_krb5_prompt_type_exists=yes,
107 ac_cv_krb5_prompt_type_exists=no)])
108 AC_MSG_RESULT($ac_cv_krb5_prompt_type_exists)
109         
110 if test "x$ac_cv_krb5_creds_keyblock_exists" = "xyes"; then
111         AC_DEFINE(HAVE_KRB5_CREDS_KEYBLOCK, 1, [define if krb5_creds has keyblock])
112 fi
113 if test "x$ac_cv_krb5_creds_session_exists" = "xyes"; then
114         AC_DEFINE(HAVE_KRB5_CREDS_SESSION, 1, [define if krb5_creds has session])
115 fi
116 if test "x$ac_cv_krb5_prompt_type_exists" = "xyes"; then
117         AC_DEFINE(HAVE_KRB5_PROMPT_TYPE, 1, [define if krb5_prompt has type])
118 fi
119         
120 dnl     AC_CHECK_MEMBERS([krb5_creds.keyblock, krb5_creds.session],,, [#include <krb5.h>])
121         CPPFLAGS="$save_CPPFLAGS"
122         LIBS="$save_LIBS"
123 fi
124
125 if test "x$ac_cv_krb5_cc_register_exists" = "xyes"; then
126         AC_DEFINE(HAVE_KRB5_CC_REGISTER, 1, [define if krb5_cc_register exists])
127 fi
128
129 AC_SUBST(BUILD_KRB5)
130 AC_SUBST(KRB5CFLAGS)
131 AC_SUBST(KRB5LIBS)
132
133 ])dnl