root/trunk/m4/kerberos.m4

Revision 1147 (checked in by pvanhoof, 2 years ago)

Build environment improvements

Line 
1 AC_DEFUN([AC_TNY_KERBEROS_CHECK],
2 [
3
4 AC_ARG_WITH(krb5, [  --with-krb5=DIR      Location of Kerberos 5 install dir], with_krb5="$withval", with_krb5="no")
5 AC_ARG_WITH(krb5-libs, [  --with-krb5-libs=DIR Location of Kerberos 5 libraries], with_krb5_libs="$withval", with_krb5_libs="$with_krb5/lib")
6 AC_ARG_WITH(krb5-includes, [  --with-krb5-includes=DIR Location of Kerberos 5 headers], with_krb5_includes="$withval", with_krb5_includes="")
7 AC_ARG_WITH(krb4, [  --with-krb4=DIR      Location of Kerberos 4 install dir], with_krb4="$withval", with_krb4="no")
8 AC_ARG_WITH(krb4-libs, [  --with-krb4-libs=DIR Location of Kerberos 4 libraries], with_krb4_libs="$withval", with_krb4_libs="$with_krb4/lib")
9 AC_ARG_WITH(krb4-includes, [  --with-krb4-includes=DIR Location of Kerberos 4 headers], with_krb4_includes="$withval", with_krb4_includes="")
10
11 msg_krb5="no"
12 if test "x${with_krb5}" != "xno"; then
13         LDFLAGS_save="$LDFLAGS"
14         
15         mitlibs="-lkrb5 -lk5crypto -lcom_err -lgssapi_krb5"
16         heimlibs="-lkrb5 -lcrypto -lasn1 -lcom_err -lroken -lgssapi"
17         AC_CACHE_CHECK([for Kerberos 5], ac_cv_lib_kerberos5,
18         [
19                 LDFLAGS="$LDFLAGS -L$with_krb5_libs $mitlibs"
20                 AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$mitlibs",
21                 [
22                         LDFLAGS="$LDFLAGS_save -L$with_krb5_libs $heimlibs"
23                         AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$heimlibs", ac_cv_lib_kerberos5="no")
24                 ])
25                 LDFLAGS="$LDFLAGS_save"
26         ])
27         if test "$ac_cv_lib_kerberos5" != "no"; then
28                 AC_DEFINE(HAVE_KRB5,1,[Define if you have Krb5])
29                 if test "$ac_cv_lib_kerberos5" = "$mitlibs"; then
30                         AC_DEFINE(HAVE_MIT_KRB5,1,[Define if you have MIT Krb5])
31                         if test -z "$with_krb5_includes"; then
32                                 KRB5_CFLAGS="-I$with_krb5/include"
33                         else
34                                 KRB5_CFLAGS="-I$with_krb5_includes"
35                         fi
36                         msg_krb5="yes (MIT)"
37                 else
38                         AC_DEFINE(HAVE_HEIMDAL_KRB5,1,[Define if you have Heimdal])
39                         if test -z "$with_krb5_includes"; then
40                                 KRB5_CFLAGS="-I$with_krb5/include/heimdal"
41                         else
42                                 KRB5_CFLAGS="-I$with_krb5_includes"
43                         fi
44                         msg_krb5="yes (Heimdal)"
45                 fi
46                 KRB5_LDFLAGS="-L$with_krb5_libs $ac_cv_lib_kerberos5"
47         fi
48 else
49         AC_MSG_CHECKING(for Kerberos 5)
50         AC_MSG_RESULT($with_krb5)
51 fi
52 AM_CONDITIONAL(ENABLE_KRB5, test x$with_krb5 != xno)
53
54 AC_CHECK_HEADER([et/com_err.h],[AC_DEFINE([HAVE_ET_COM_ERR_H], 1, [Have et/comm_err.h])])
55 AC_CHECK_HEADER([com_err.h],[AC_DEFINE([HAVE_COM_ERR_H], 1, [Have comm_err.h])])
56
57 msg_krb4="no"
58 if test "x${with_krb4}" != "xno"; then
59         LDFLAGS_save="$LDFLAGS"
60         AC_CACHE_CHECK(for Kerberos 4, ac_cv_lib_kerberos4,
61         [
62                 ac_cv_lib_kerberos4="no"
63
64                 mitcompatlibs="-lkrb4 -ldes425 -lkrb5 -lk5crypto -lcom_err"
65                 # Look for MIT krb5 compat krb4
66                 LDFLAGS="$LDFLAGS -L$with_krb4_libs $mitcompatlibs"
67                 AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="$mitcompatlibs")
68                 
69                 if test "$ac_cv_lib_kerberos4" = "no"; then
70                         # Look for KTH krb4
71                         LDFLAGS="$LDFLAGS_save -L$with_krb4_libs -lkrb -lcrypto -lcom_err -lroken"
72                         AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb -lcrypto -lcom_err -lroken")
73                 fi
74                 if test "$ac_cv_lib_kerberos4" = "no"; then
75                         # Look for old MIT krb4
76                         LDFLAGS="$LDFLAGS_save -L$with_krb4_libs -lkrb"
77                         AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb",
78                         [
79                                 LDFLAGS="$LDFLAGS -ldes"
80                                 AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb -ldes")
81                         ])
82                 fi
83         ])
84         LDFLAGS="$LDFLAGS_save"
85         if test "$ac_cv_lib_kerberos4" != "no"; then
86                 AC_DEFINE(HAVE_KRB4,1,[Define if you have Krb4])
87                 msg_krb4="yes"
88
89                 if test -z "$with_krb4_includes"; then
90                         if test -f "$with_krb4/include/krb.h" -o -f "$with_krb4/include/port-sockets.h"; then
91                                 KRB4_CFLAGS="-I$with_krb4/include"
92                         fi
93                         if test -d "$with_krb4/include/kerberosIV"; then
94                                 KRB4_CFLAGS="$KRB4_CFLAGS -I$with_krb4/include/kerberosIV"
95                         fi
96                 else
97                         KRB4_CFLAGS="-I$with_krb4_includes"
98                 fi
99                 KRB4_LDFLAGS="-L$with_krb4_libs $ac_cv_lib_kerberos4"
100                 
101                 CFLAGS_save="$CFLAGS"
102                 CFLAGS="$CFLAGS $KRB4_CFLAGS"
103                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "krb.h"
104                 int krb_sendauth;
105                 ]], [[return 0]])],[AC_DEFINE(NEED_KRB_SENDAUTH_PROTO,1,[Need krb_sendauth proto])],[])
106                 CFLAGS="$CFLAGS_save"
107         fi
108 else
109         AC_MSG_CHECKING(for Kerberos 4)
110         AC_MSG_RESULT(${with_krb4})
111 fi
112
113 AC_SUBST(KRB5_CFLAGS)
114 AC_SUBST(KRB5_LDFLAGS)
115 AC_SUBST(KRB4_CFLAGS)
116 AC_SUBST(KRB4_LDFLAGS)
117
118 ])
119
Note: See TracBrowser for help on using the browser.