summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2006-01-02 05:08:30 +0000
committerRuss Allbery <rra@stanford.edu>2006-01-02 05:08:30 +0000
commitbc4901b4e5bb295f22ac425f7437421523cfa0bf (patch)
tree8537255e6e24ba5c3be6cbf070f42ffdebf7dec1 /m4
parentf4c06764a7bc8fb8b6a3a8bf942eccdde1a94413 (diff)
Update the krb5 macro to the latest version from kstart. None of the
changes should be particularly significant, but may as well synchronize between all my packages.
Diffstat (limited to 'm4')
-rw-r--r--m4/krb5.m4198
1 files changed, 152 insertions, 46 deletions
diff --git a/m4/krb5.m4 b/m4/krb5.m4
index 24f76e5..236155d 100644
--- a/m4/krb5.m4
+++ b/m4/krb5.m4
@@ -14,6 +14,113 @@ dnl be either "true" (if the program doesn't otherwise use the networking
dnl libraries) or "false" (if it is already probing for the networking
dnl libraries separately).
+dnl Does the appropriate library checks for reduced-dependency GSSAPI linkage.
+AC_DEFUN([_RRA_LIB_KRB5_GSSAPI_REDUCED],
+[AC_CHECK_LIB([gssapi], [gss_import_name],
+ [KRBLIBS="-lgssapi"],
+ [AC_CHECK_LIB([gssapi_krb5], [gss_import_name],
+ [KRBLIBS="-lgssapi_krb5"],
+ [AC_MSG_ERROR([cannot find usable GSSAPI library])])])])
+
+dnl Does the appropriate library checks for reduced-dependency krb5 linkage.
+AC_DEFUN([_RRA_LIB_KRB5_KRB5_REDUCED],
+[AC_CHECK_LIB([krb5], [krb5_init_context], [KRBLIBS="-lkrb5"],
+ [AC_MSG_ERROR([cannot find usable Kerberos v5 library])])
+AC_CHECK_LIB([com_err], [com_err], [KRBLIBS="$KRBLIBS -lcom_err"],
+ [AC_MSG_ERROR([cannot find usable com_err library])])])
+
+dnl Does the appropriate library checks for reduced-dependency krb4 linkage.
+AC_DEFUN([_RRA_LIB_KRB5_KRB4_REDUCED],
+[AC_CHECK_LIB([krb4], [krb_get_svc_in_tkt], [KRBLIBS="-lkrb4"],
+ [AC_CHECK_LIB([krb], [krb_get_svc_in_tkt], [KRBLIBS="-lkrb"],
+ [AC_MSG_ERROR([cannot find usable Kerberos v4 library])])])])
+
+dnl Does the appropriate library checks for GSSAPI linkage.
+AC_DEFUN([_RRA_LIB_KRB5_GSSAPI],
+[AC_CHECK_LIB([gssapi], [gss_import_name],
+ [KRBLIBS="-lgssapi -lkrb5 -lasn1 -lroken -lcrypto -lcom_err"],
+ [KRB5EXTRA="-lkrb5 -lk5crypto -lcom_err"
+ AC_CHECK_LIB([krb5support], [krb5int_getspecific],
+ [KRB5EXTRA="$KRB5EXTRA -lkrb5support"],
+ [AC_SEARCH_LIBS([pthread_setspecific], [pthreads pthread])
+ AC_CHECK_LIB([krb5support], [krb5int_setspecific],
+ [KRB5EXTRA="$KRB5EXTRA -lkrb5support"])])
+ AC_CHECK_LIB([gssapi_krb5], [gss_import_name],
+ [KRBLIBS="-lgssapi_krb5 $KRB5EXTRA"],
+ [AC_MSG_ERROR([cannot find usable GSSAPI library])],
+ [$KRB5EXTRA])],
+ [-lkrb5 -lasn1 -lroken -lcrypto -lcom_err])])
+
+dnl Does the appropriate library checks for krb5 linkage. Note that we have
+dnl to check for a different function the second time since the Heimdal and
+dnl MIT libraries have the same name.
+AC_DEFUN([_RRA_LIB_KRB5_KRB5],
+[AC_CHECK_LIB([krb5], [krb5_init_context],
+ [KRBLIBS="-lkrb5 -lasn1 -lroken -lcrypto -lcom_err"],
+ [KRB5EXTRA="-lk5crypto -lcom_err"
+ AC_CHECK_LIB([krb5support], [krb5int_getspecific],
+ [KRB5EXTRA="$KRB5EXTRA -lkrb5support"],
+ [AC_SEARCH_LIBS([pthread_setspecific], [pthreads pthread])
+ AC_CHECK_LIB([krb5support], [krb5int_setspecific],
+ [KRB5EXTRA="$KRB5EXTRA -lkrb5support"])])
+ AC_CHECK_LIB([krb5], [krb5_cc_default],
+ [KRBLIBS="-lkrb5 $KRB5EXTRA"],
+ [AC_MSG_ERROR([cannot find usable Kerberos v5 library])],
+ [$KRB5EXTRA])],
+ [-lasn1 -lroken -lcrypto -lcom_err])])
+
+dnl Does the appropriate library checks for krb4 linkage.
+AC_DEFUN([_RRA_LIB_KRB5_KRB4],
+[KRB4EXTRA=
+AC_CHECK_LIB([crypto], [des_set_key], [KRB4EXTRA="-lcrypto"],
+ [KRB4EXTRA="-ldes"])
+AC_CHECK_LIB([krb], [krb_get_svc_in_tkt],
+ [KRBLIBS="-lkrb $KRB4EXTRA"],
+ [KRB5EXTRA="-ldes425 -lkrb5 -lk5crypto -lcom_err"
+ AC_CHECK_LIB([krb5support], [krb5int_getspecific],
+ [KRB5EXTRA="$KRB5EXTRA -lkrb5support"],
+ [AC_SEARCH_LIBS([pthread_setspecific], [pthreads pthread])
+ AC_CHECK_LIB([krb5support], [krb5int_setspecific],
+ [KRB5EXTRA="$KRB5EXTRA -lkrb5support"])])
+ AC_CHECK_LIB([krb4], [krb_get_svc_in_tkt],
+ [KRBLIBS="-lkrb4 $KRB5EXTRA"],
+ [AC_MSG_ERROR([cannot find usable Kerberos v4 library])],
+ [$KRB5EXTRA])],
+ [$KRB4EXTRA])])
+
+dnl Additional checks for portability between MIT and Heimdal if GSSAPI
+dnl libraries were requested.
+AC_DEFUN([_RRA_LIB_KRB5_GSSAPI_EXTRA],
+[AC_CHECK_HEADERS([gssapi.h])
+AC_CHECK_DECL([GSS_C_NT_USER_NAME],
+ [AC_DEFINE([HAVE_GSS_RFC_OIDS], 1,
+ [Define to 1 if the GSS-API library uses RFC-compliant OIDs.])], ,
+[#ifdef HAVE_GSSAPI_H
+# include <gssapi.h>
+#else
+# include <gssapi/gssapi.h>
+#endif
+])
+AC_CHECK_DECLS([GSS_KRB5_MECHANISM], , ,
+[#ifdef HAVE_GSSAPI_H
+# include <gssapi.h>
+#else
+# include <gssapi/gssapi.h>
+#endif
+])])
+
+dnl Additional checks for portability between MIT and Heimdal if krb5
+dnl libraries were requested.
+AC_DEFUN([_RRA_LIB_KRB5_KRB5_EXTRA],
+[AC_CHECK_HEADERS([et/com_err.h])
+AC_CHECK_FUNCS([krb5_free_keytab_entry_contents])
+AC_CHECK_TYPES([krb5_realm], , , [#include <krb5.h>])])
+
+dnl Additional checks for portability if krb4 libraries were requested.
+AC_DEFUN([_RRA_LIB_KRB5_KRB4_EXTRA],
+[AC_CHECK_HEADERS([kerberosIV/krb.h])])
+
+dnl The main macro.
AC_DEFUN([RRA_LIB_KRB5],
[KRBROOT=
AC_ARG_WITH([kerberos],
@@ -34,14 +141,28 @@ AC_ARG_ENABLE([reduced-depends],
fi
LDFLAGS="$LDFLAGS -L$KRBROOT/lib"
fi
- AC_CHECK_LIB([gssapi], [gss_import_name],
- [KRBLIBS="-lgssapi"],
- [AC_CHECK_LIB([gssapi_krb5], [gss_import_name],
- [KRBLIBS="-lgssapi_krb5"],
- [AC_MSG_ERROR([cannot find usable GSSAPI library])])])
+ case "$1" in
+ gssapi) _RRA_LIB_KRB5_GSSAPI_REDUCED ;;
+ krb5) _RRA_LIB_KRB5_KRB5_REDUCED ;;
+ krb4) _RRA_LIB_KRB5_KRB4_REDUCED ;;
+ *) AC_MSG_ERROR([BUG: unknown library type $1]) ;;
+ esac
reduce_depends=true
fi])
+dnl Support static linkage as best we can. Set a variable and do the
+dnl wrapping later on.
+static=false
+AC_ARG_ENABLE([static],
+ AC_HELP_STRING([--enable-static],
+ [Link against the static Kerberos libraries]),
+ [if test x"$enableval" = xyes ; then
+ if test x"$reduce_depends" = xtrue ; then
+AC_MSG_ERROR([--enable-static cannot be used with --enable-reduced-depends])
+ fi
+ static=true
+ fi])
+
dnl Checking for the neworking libraries shouldn't be necessary for the
dnl krb5-config case, but apparently it is at least for MIT Kerberos 1.2.
dnl This will unfortunately mean multiple -lsocket -lnsl references when
@@ -62,7 +183,11 @@ if test x"$reduce_depends" != xtrue ; then
else
AC_PATH_PROG([KRB5_CONFIG], [krb5-config])
fi
- if test x"$KRB5_CONFIG" != x ; then
+
+ # We can't use krb5-config if building static since we can't tell what
+ # of the libraries it gives us should be static and which should be
+ # dynamic.
+ if test x"$KRB5_CONFIG" != x && test x"$static" != xtrue ; then
AC_MSG_CHECKING([for $1 support in krb5-config])
if "$KRB5_CONFIG" | grep '$1' > /dev/null 2>&1 ; then
AC_MSG_RESULT([yes])
@@ -79,54 +204,35 @@ if test x"$reduce_depends" != xtrue ; then
if test x"$KRBROOT" != x/usr ; then
KRBCPPFLAGS="-I$KRBROOT/include"
fi
- KRBLIBS="-L$KRBROOT/lib"
+ LDFLAGS="$LDFLAGS -L$KRBROOT/lib"
fi
- AC_SEARCH_LIBS([res_search], [resolv])
+ AC_SEARCH_LIBS([res_search], [resolv], ,
+ [AC_SEARCH_LIBS([__res_search], [resolv])])
AC_SEARCH_LIBS([crypt], [crypt])
- AC_CHECK_LIB([gssapi], [gss_import_name],
- [KRBLIBS="-lgssapi -lkrb5 -lasn1 -lroken -lcrypto -lcom_err"],
- [KRB5EXTRA="-lkrb5 -lk5crypto -lcom_err"
- AC_CHECK_LIB([krb5support], [main],
- [KRB5EXTRA="$KRB5EXTRA -lkrb5support"])
- AC_CHECK_LIB([gssapi_krb5], [gss_import_name],
- [KRBLIBS="-lgssapi_krb5 $KRB5EXTRA"],
- [AC_MSG_ERROR([cannot find usable GSSAPI library])],
- [$KRB5EXTRA])],
- [-lkrb5 -lasn1 -lroken -lcrypto -lcom_err])
+ case "$1" in
+ gssapi) _RRA_LIB_KRB5_GSSAPI ;;
+ krb5) _RRA_LIB_KRB5_KRB5 ;;
+ krb4) _RRA_LIB_KRB5_KRB4 ;;
+ *) AC_MSG_ERROR([BUG: unknown library type $1]) ;;
+ esac
fi
if test x"$KRBCPPFLAGS" != x ; then
CPPFLAGS="$CPPFLAGS $KRBCPPFLAGS"
fi
fi
-AC_ARG_ENABLE([static],
- AC_HELP_STRING([--enable-static],
- [Link against the static Kerberos libraries]),
- [if test x"$enableval" = xyes ; then
- LIBS="-Wl,-Bstatic $KRBLIBS -Wl,-Bdynamic $LIBS"
- else
- LIBS="$KRBLIBS $LIBS"
- fi],
- [LIBS="$KRBLIBS $LIBS"])
+dnl Generate the final library list and put it into the standard variables.
+if test x"$static" = xtrue ; then
+ LIBS="-Wl,-Bstatic $KRBLIBS -Wl,-Bdynamic $LIBS"
+else
+ LIBS="$KRBLIBS $LIBS"
+fi
CPPFLAGS=`echo "$CPPFLAGS" | sed 's/^ *//'`
LDFLAGS=`echo "$LDFLAGS" | sed 's/^ *//'`
-dnl Check a few more things for portability between MIT and Heimdal if GSSAPI
-dnl support was requested.
-AC_CHECK_HEADERS([gssapi.h])
-AC_CHECK_DECL([GSS_C_NT_USER_NAME],
- [AC_DEFINE([HAVE_GSS_RFC_OIDS], 1,
- [Define to 1 if the GSS-API library uses RFC-compliant OIDs.])], ,
-[#ifdef HAVE_GSSAPI_H
-# include <gssapi.h>
-#else
-# include <gssapi/gssapi.h>
-#endif
-])
-AC_CHECK_DECLS([GSS_KRB5_MECHANISM], , ,
-[#ifdef HAVE_GSSAPI_H
-# include <gssapi.h>
-#else
-# include <gssapi/gssapi.h>
-#endif
-])])
+dnl Run any extra checks for the desired libraries.
+case "$1" in
+gssapi) _RRA_LIB_KRB5_GSSAPI_EXTRA ;;
+krb5) _RRA_LIB_KRB5_KRB5_EXTRA ;;
+krb4) _RRA_LIB_KRB5_KRB4_EXTRA ;;
+esac])