3 AC_REVISION($Revision$)
4 AC_DEFUN(modname,[rlm_krb5])
6 if test x$with_[]modname != xno; then
11 dnl extra argument: --with-rlm-krb5-dir
13 AC_ARG_WITH(rlm-krb5-dir,
14 [ --with-rlm-krb5-dir=DIR Directory for krb5 files []],
17 AC_MSG_ERROR(Need rlm-krb5-dir)
22 rlm_krb5_dir="$withval"
27 AC_PATH_PROG(krb5_config, krb5-config, not-found, [${rlm_krb5_dir}/bin:${PATH}:/usr/bin:/usr/local/bin])
29 dnl # If we can find krb5-config we can get the version of the library and determine
30 dnl # whether it's safe to enable threading.
32 if test "$krb5_config" != 'not-found'; then
33 AC_MSG_CHECKING([krb5-config CFLAGS])
34 SMART_CPPFLAGS=$($krb5_config --cflags)
35 SMART_CPPFLAGS=[$(echo "$SMART_CPPFLAGS" | sed 's/-I[ ]*/-include /g')]
36 AC_MSG_RESULT("$SMART_CPPFLAGS")
38 AC_MSG_CHECKING([krb5-config LDFLAGS])
39 SMART_LIBS=$($krb5_config --libs)
40 AC_MSG_RESULT(${SMART_LIBS})
42 AC_MSG_CHECKING([krb5-config reported version])
43 krb5_version_raw=$($krb5_config --version)
45 dnl # AWK originally from from https://github.com/hpc/lustre
46 krb5_version=$(echo "$krb5_version_raw" | head -n 1 | \
47 awk '{split($(4),v,"."); if (v@<:@"3"@:>@ == "") v@<:@"3"@:>@ = "0"; print v@<:@"1"@:>@v@<:@"2"@:>@v@<:@"3"@:>@ }')
48 AC_MSG_RESULT([${krb5_version_raw} ($krb5_version)])
50 AC_MSG_CHECKING([krb5-config reported vendor])
51 krb5_vendor=$($krb5_config --vendor)
52 AC_MSG_RESULT([${krb5_vendor}])
54 AC_MSG_CHECKING([canonical API type])
55 if test "$krb5_vendor" = "Massachusetts Institute of Technology" || \
56 echo "$krb5_vendor" | grep -i 'MIT' > /dev/null 2>&1 || \
57 echo "$krb5_version_raw" | grep -i 'MIT' > /dev/null 2>&1 ; then
61 AC_MSG_RESULT([HEIMDAL])
62 krb5_api_type='heimdal'
65 smart_try_dir="$rlm_krb5_dir/include"
66 FR_SMART_CHECK_INCLUDE(krb5.h)
67 if test "$ac_cv_header_krb5_h" != "yes"; then
72 smart_try_dir="$rlm_krb5_dir/lib"
73 FR_SMART_CHECK_LIB(k5crypto, krb5_encrypt_data)
74 if test "x$ac_cv_lib_k5crypto_krb5_encrypt_data" = xyes; then
75 krb5libcrypto="-lk5crypto"
78 if test "x$krb5libcrypto" = x; then
79 FR_SMART_CHECK_LIB(crypto, DH_new)
80 if test "x$ac_cv_lib_crypto_DH_new" = xyes; then
81 krb5libcrypto="-lcrypto"
85 if test "x$krb5libcrypto" = x; then
86 AC_MSG_WARN([neither krb5 'k5crypto' nor 'crypto' libraries are found!])
89 FR_SMART_CHECK_LIB(com_err, set_com_err_hook)
90 if test "x$ac_cv_lib_com_err_set_com_err_hook" != xyes; then
91 AC_MSG_WARN([the comm_err library isn't found!])
95 dnl # Only the heimdal version of the library has this function
97 FR_SMART_CHECK_LIB(krb5, krb5_verify_user_opt)
98 if test "x$ac_cv_lib_krb5_krb5_verify_user_opt" == xyes; then
99 krb5_api_type='heimdal'
103 FR_SMART_CHECK_LIB(krb5, krb5_get_init_creds_password)
104 if test "x$ac_cv_lib_krb5_krb5_get_init_creds_password" != xyes; then
112 dnl # Need to ensure the test program(s) link against the right library
114 LDFLAGS="${LDFLAGS} ${SMART_LIBS}"
115 CFLAGS="${CFLAGS} ${SMART_CFLAGS}"
118 dnl # Check how to free things returned by krb5_get_error_message
120 AC_CHECK_FUNCS([krb5_get_error_message krb5_free_error_string krb5_free_error_message])
121 if test "x$ac_cv_func_krb5_get_error_message" == xyes; then
122 krb5mod_cflags="${krb5mod_cflags} -D HAVE_KRB5_GET_ERROR_MESSAGE"
124 if test "x$ac_cv_func_krb5_free_error_message" == xyes; then
125 krb5mod_cflags="${krb5mod_cflags} -D HAVE_KRB5_FREE_ERROR_MESSAGE"
127 if test "x$ac_cv_func_krb5_free_error_string" == xyes; then
128 krb5mod_cflags="${krb5mod_cflags} -D HAVE_KRB5_FREE_ERROR_STRING"
132 dnl # Only check if version checks have not found kerberos to be thread unsafe
134 if test "$krb5threadsafe" != "no"; then
137 FR_SMART_CHECK_LIB(krb5, krb5_is_thread_safe)
138 if test "x$ac_cv_lib_krb5_krb5_is_thread_safe" == xyes; then
139 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <krb5.h>]], [[return krb5_is_thread_safe() ? 0 : 1]])],
140 [krb5threadsafe="-DKRB5_IS_THREAD_SAFE"], [AC_MSG_WARN([[libkrb5 is not threadsafe]])])
146 if test "$krb5_api_type" == "mit"; then
148 dnl # This lives in different places depending on the distro
150 FR_SMART_CHECK_INCLUDE([com_err.h])
151 if test "$ac_cv_header_com_err_h" != "yes"; then
152 FR_SMART_CHECK_INCLUDE([et/com_err.h])
153 if test "$ac_cv_header_et_com_err_h" != "yes"; then
154 fail="$fail com_err.h"
156 krb5mod_cflags="$krb5mod_cflags -DET_COMM_ERR "
160 krb5mod_cflags="$krb5mod_cflags -DHEIMDAL_KRB5"
165 echo \*\*\* module modname is disabled.
168 if test x"$fail" != x""; then
169 if test x"${enable_strict_dependencies}" = x"yes"; then
170 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
172 AC_MSG_WARN([silently not building ]modname[.])
173 AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.]);
178 mod_ldflags="${krb5mod_ldflags} ${krb5libcrypto} ${SMART_LIBS}"
179 mod_cflags="${krb5mod_cflags} ${krb5threadsafe} ${SMART_CFLAGS}"
181 AC_SUBST(mod_ldflags)