continue the configure simplifications.
[apps/madmutt.git] / m4 / gssapi.m4
1 # gssapi.m4: Find GSSAPI libraries in either Heimdal or MIT implementations
2 # Brendan Cully <brendan@kublai.com> 20010529
3
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],
10 [
11   GSSAPI_PREFIX=[$]$1
12   GSSAPI_IMPL="none"
13   saved_CPPFLAGS="$CPPFLAGS"
14   saved_LDFLAGS="$LDFLAGS"
15   saved_LIBS="$LIBS"
16   dnl First try krb5-config
17   if test "$GSSAPI_PREFIX" != "yes"
18   then
19     krb5_path="$GSSAPI_PREFIX/bin"
20   else
21     krb5_path="$PATH"
22   fi
23   AC_PATH_PROG(KRB5CFGPATH, krb5-config, none, $krb5_path)
24   if test "$KRB5CFGPATH" != "none"
25   then
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";;
32    esac
33   else
34     dnl No krb5-config, run the old code
35     if test "$GSSAPI_PREFIX" != "yes"
36     then
37       GSSAPI_CFLAGS="-I$GSSAPI_PREFIX/include"
38       GSSAPI_LDFLAGS="-L$GSSAPI_PREFIX/lib"
39       CPPFLAGS="$CPPFLAGS $GSSAPI_CFLAGS"
40       LDFLAGS="$LDFLAGS $GSSAPI_LDFLAGS"
41     fi
42
43     dnl New MIT kerberos V support
44     AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context, [
45       GSSAPI_IMPL="MIT",
46       GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err"
47       ],, -lkrb5 -lk5crypto -lcom_err)
48
49     dnl Heimdal kerberos V support
50     if test "$GSSAPI_IMPL" = "none"
51     then
52       AC_CHECK_LIB(gssapi, gss_init_sec_context, [
53           GSSAPI_IMPL="Heimdal"
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)
57     fi
58
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"
66     then
67       AC_CHECK_LIB(gssapi_krb5, g_order_init, [
68         GSSAPI_IMPL="OldMIT",
69         GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi_krb5 -lkrb5 -lcrypto -lcom_err"
70         ],, -lkrb5 -lcrypto -lcom_err)
71     fi
72   fi
73
74   CPPFLAGS="$saved_CPPFLAGS"
75   LDFLAGS="$saved_LDFLAGS"
76   LIBS="$saved_LIBS"
77 ])