1 # gssapi.m4: Find GSSAPI libraries in either Heimdal or MIT implementations
2 # Brendan Cully <brendan@kublai.com> 20010529
4 dnl MUTT_AM_PATH_GSSAPI(PREFIX)
5 dnl Search for a GSSAPI implementation in the standard locations plus PREFIX,
6 dnl if it is set and not "yes".
7 dnl Defines GSSAPI_CFLAGS and GSSAPI_LIBS if found.
8 dnl Defines GSSAPI_IMPL to "Heimdal", "MIT", or "OldMIT", or "none" if not found
9 AC_DEFUN([MUTT_AM_PATH_GSSAPI],
13 saved_CPPFLAGS="$CPPFLAGS"
14 saved_LDFLAGS="$LDFLAGS"
16 dnl First try krb5-config
17 if test "$GSSAPI_PREFIX" != "yes"
19 krb5_path="$GSSAPI_PREFIX/bin"
23 AC_PATH_PROG(KRB5CFGPATH, krb5-config, none, $krb5_path)
24 if test "$KRB5CFGPATH" != "none"
26 GSSAPI_CFLAGS="$CPPFLAGS `$KRB5CFGPATH --cflags gssapi`"
27 GSSAPI_LIBS="$MUTTLIBS `$KRB5CFGPATH --libs gssapi`"
28 case "`$KRB5CFGPATH --version`" in
29 "Kerberos 5 "*) GSSAPI_IMPL="MIT";;
30 ?eimdal*) GSSAPI_IMPL="Heimdal";;
31 *) GSSAPI_IMPL="Unknown";;
34 dnl No krb5-config, run the old code
35 if test "$GSSAPI_PREFIX" != "yes"
37 GSSAPI_CFLAGS="-I$GSSAPI_PREFIX/include"
38 GSSAPI_LDFLAGS="-L$GSSAPI_PREFIX/lib"
39 CPPFLAGS="$CPPFLAGS $GSSAPI_CFLAGS"
40 LDFLAGS="$LDFLAGS $GSSAPI_LDFLAGS"
43 dnl New MIT kerberos V support
44 AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context, [
46 GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err"
47 ],, -lkrb5 -lk5crypto -lcom_err)
49 dnl Heimdal kerberos V support
50 if test "$GSSAPI_IMPL" = "none"
52 AC_CHECK_LIB(gssapi, gss_init_sec_context, [
54 GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi -lkrb5 -ldes -lasn1 -lroken"
55 GSSAPI_LIBS="$GSSAPI_LIBS -lcrypt -lcom_err"
56 ],, -lkrb5 -ldes -lasn1 -lroken -lcrypt -lcom_err)
59 dnl Old MIT Kerberos V
60 dnl Note: older krb5 distributions use -lcrypto instead of
61 dnl -lk5crypto, which collides with OpenSSL. One way of dealing
62 dnl with that is to extract all objects from krb5's libcrypto
63 dnl and from openssl's libcrypto into the same directory, then
64 dnl to create a new libcrypto from these.
65 if test "$GSSAPI_IMPL" = "none"
67 AC_CHECK_LIB(gssapi_krb5, g_order_init, [
69 GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi_krb5 -lkrb5 -lcrypto -lcom_err"
70 ],, -lkrb5 -lcrypto -lcom_err)
74 CPPFLAGS="$saved_CPPFLAGS"
75 LDFLAGS="$saved_LDFLAGS"