Autoconf: Use AC_CHECK_MEMBERS
[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 krb5_svc_get_msg])
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_CHECK_MEMBERS([krb5_creds.keyblock,
80                           krb5_creds.session,
81                           krb5_prompt.type],
82                          [], [], [#include <krb5.h>])
83
84         CPPFLAGS="$save_CPPFLAGS"
85         LIBS="$save_LIBS"
86 fi
87
88 AC_SUBST(BUILD_KRB5)
89 AC_SUBST(MAKE_KRB5)
90 AC_SUBST(KRB5CFLAGS)
91 AC_SUBST(KRB5LIBS)
92
93 ])dnl