Imported Upstream version 3.3.0
[debian/amanda] / config / amanda / krb5-security.m4
1 # SYNOPSIS
2 #
3 #   AMANDA_KRB5_SECURITY
4 #
5 # OVERVIEW
6 #
7 #   Handle configuration for KRB5 security, implementing the --with-krb5-security
8 #   option.  If libraries are found, they are added to the relevant compiler flags.
9 #
10 #   Defines and substitutes KRB5_SECURITY, and sets AM_CONDITIONAL 
11 #   WANT_KRB5_SECURITY, if the user has selected this mechanism.  Also, the
12 #   following parameters are taken from options, defined, and substituted:
13 #
14 AC_DEFUN([AMANDA_KRB5_SECURITY],
15 [
16     # Specify --with-krb5-security if Kerberos software is in somewhere
17     # other than the listed KRB5_SPOTS.  We only compile kerberos support in
18     # if the right files are there.
19
20     KRB5_SECURITY="no"
21     : ${KRB5_SPOTS="/usr/kerberos /usr/cygnus /usr /opt/kerberos"}
22
23     AC_ARG_WITH(krb5-security,
24         AS_HELP_STRING([--with-krb5-security=DIR],
25             [Location of Kerberos V software @<:@/usr/kerberos /usr/cygnus /usr /opt/kerberos@:>@]),
26         [
27             case "$withval" in
28                 n | no) KRB5_SECURITY=no ;;
29                 y | ye | yes) KRB5_SECURITY=yes ;;
30                 *) KRB5_SPOTS="$KRB5_SECURITY"
31                    KRB5_SECURITY=yes
32                    ;;
33             esac
34         ]
35     )
36
37     if test "x$KRB5_SECURITY" = "xyes"; then
38         # if found, force the static versions of these libs (.a) by linking directly
39         # with the .a files.  I don't know how to get -R dependancies checked
40         # in autoconf at this time. -kashmir
41         AC_MSG_CHECKING(for Kerberos V libraries)
42         KRB5_DIR_FOUND=""
43         for dir in $KRB5_SPOTS; do
44           for lib in lib lib64; do
45             k5libdir=${dir}/${lib}
46             if test \( -f ${k5libdir}/libkrb5.a -o -f ${k5libdir}/libkrb5.so \) -a \( -f ${k5libdir}/libgssapi_krb5.so -o -f ${k5libdir}/libgssapi_krb5.a \) -a \( -f ${k5libdir}/libcom_err.a -o -f ${k5libdir}/libcom_err.so \); then
47                 if test -f ${k5libdir}/libk5crypto.a -o -f ${k5libdir}/libk5crypto.so; then
48                     K5CRYPTO=-lk5crypto
49                 elif test -f ${k5libdir}/libcrypto.a -o -f ${k5libdir}/libcrypto.so; then
50                     K5CRYPTO=-lcrypto
51                 else
52                     K5CRYPTO=""
53                 fi
54                 if test -f ${k5libdir}/libkrb5support.a -o -f ${k5libdir}/libkrb5support.so; then
55                     K5SUPPORT=-lkrb5support
56                 else
57                     K5SUPPORT=""
58                 fi
59                 KRB5_DIR_FOUND=$dir
60                 KRB5_LIBDIR_FOUND=$k5libdir
61                 AMANDA_ADD_LIBS([-lgssapi_krb5 -lkrb5 $K5CRYPTO $K5SUPPORT -lcom_err])
62                 break
63             elif test \( -f ${k5libdir}/libkrb5.a -o -f ${k5libdir}/libkrb5.so \) -a \( -f ${k5libdir}/libasn1.a -o -f ${k5libdir}/libasn1.so \) -a \( -f ${k5libdir}/libgssapi.a -o -f ${k5libdir}/libgssapi.so \); then
64                 AMANDA_ADD_LIBS([-lgssapi -lkrb5 -lasn1])
65                 AMANDA_ADD_CPPFLAGS([-DKRB5_HEIMDAL_INCLUDES])
66                 break
67             fi
68           done
69         done
70
71         if test "$KRB5_DIR_FOUND"; then
72             AC_MSG_RESULT(found in $KRB5_DIR_FOUND)
73             #
74             # some OS's, such as NetBSD, stick krb5 includes out of the way...
75             # should probably just use autoconf to look for various include
76             # options and set them, but don't quite want to do that until I've
77             # dug into it a bit more.
78             #
79             if test -d "$KRB5_DIR_FOUND/krb5" ; then
80                 AMANDA_ADD_CPPFLAGS([-I$KRB5_DIR_FOUND/include/krb5])
81             else
82                 AMANDA_ADD_CPPFLAGS([-I$KRB5_DIR_FOUND/include])
83             fi
84                 AC_CHECK_LIB(krb5support,main)
85
86             if test "$KRB5_LIBDIR_FOUND" != "$libdir" ; then
87                 AMANDA_ADD_LDFLAGS([-L$KRB5_LIBDIR_FOUND])
88             fi
89
90             AC_DEFINE(KRB5_SECURITY,1,
91                 [Define if Kerberos 5 security is to be enabled. ])
92         else
93             AC_MSG_RESULT(no krb5 system libraries found)
94             AC_MSG_ERROR([No Kerberos V libraries were found on your system; krb5-security cannot be enabled])
95             KRB5_SECURITY="no"
96         fi
97     fi
98
99     AM_CONDITIONAL(WANT_KRB5_SECURITY, test x"$KRB5_SECURITY" = x"yes")
100     AC_SUBST(KRB5_SECURITY)
101 ])