-if test "$with_krb5" != no; then
- cpp_bak="$CPPFLAGS"
- ld_bak="$LDFLAGS"
- if test "$with_krb5" != yes; then
- CPPFLAGS="$CPPFLAGS -I${with_krb5}/include"
- LDFLAGS="$LDFLAGS -L${with_krb5}/lib"
- fi
- AC_CHECK_LIB(krb5, krb5_init_context, [HAS_KRB5=yes], [HAS_KRB5=no])
- if test "$HAS_KRB5" = yes; then
- AC_CHECK_HEADER(com_err.h, [HAS_COMERR=yes], [HAS_COMERR=no])
- if test "$HAS_COMERR" = no; then
- AC_CHECK_HEADER(et/com_err.h, [HAS_COMERR=yes; CPPFLAGS="$CPPFLAGS -I/usr/include/et"], [])
- fi
- fi
- if test "$HAS_COMERR" = no; then
- HAS_KRB5=no
- fi
- if test "$HAS_KRB5" = no; then
- CPPFLAGS="$cpp_bak"
- LDFLAGS="$ld_bak"
- fi
-fi
-KRB5_LDADD=
-if test -n "$with_krb5" -a "$with_krb5" != no -a "$HAS_KRB5" != yes; then
- AC_MSG_ERROR([*** cannot find Kerberos 5 on this system - try passing --with-krb5=/path/to/kerberos])
+AC_CHECK_PROG(KRBCONF, krb5-config, yes, no)
+DOLDA_PKG([HAS_COMERR], [AC_CHECK_HEADER(com_err.h, [COMERR_CFLAGS=""; HAS_COMERR=yes], [])],
+ [AC_CHECK_HEADER(et/com_err.h, [COMERR_CFLAGS="-I/usr/include/et"; HAS_COMERR=yes], [])],
+ [HAS_COMERR=no])
+DOLDA_PKG([HAS_KRB5], [test "$with_krb5" = no && HAS_KRB5=no],
+ [test "$KRBCONF" != yes && HAS_KRB5=no],
+ [test "$HAS_COMERR" = no && HAS_KRB5=no],
+ [KRB5_LIBS="`krb5-config --libs krb5`"
+ KRB5_CFLAGS="`krb5-config --cflags krb5` $COMERR_CFLAGS"]
+ [AC_CHECK_LIB(krb5, krb5_init_context, [:], [HAS_KRB5=no], $KRB5_LIBS)],
+ [DOLDA_CHECK_HEADER(krb5.h, [], [HAS_KRB5=no], $KRB5_CFLAGS)])
+if test -n "$with_krb5" -a "$with_krb5" != no -a "$HAS_KRB5" = no; then
+ AC_MSG_ERROR([*** cannot find Kerberos 5 on this system])