fix-kerberos-autoconf-20060623
[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_CFLAGS="$CFLAGS"
58         CFLAGS="$CFLAGS KRB5CFLAGS"
59         save_LIBS="$LIBS"
60         LIBS="$LIBS $KRB5LIBS"
61         AC_CHECK_FUNCS([add_to_error_table])
62         CFLAGS="$save_CFLAGS"
63         LIBS="$save_LIBS"
64 fi
65 AC_SUBST(BUILD_KRB5)
66 AC_SUBST(KRB5CFLAGS)
67 AC_SUBST(KRB5LIBS)
68 ])dnl