1 dnl $Heimdal: check-compile-et.m4 19252 2006-12-06 13:32:55Z lha $
5 AC_DEFUN([CHECK_COMPILE_ET], [
7 AC_CHECK_PROG(COMPILE_ET, compile_et, [compile_et])
10 krb_cv_com_err_need_r=""
11 krb_cv_compile_et_cross=no
12 if test "${COMPILE_ET}" = "compile_et"; then
14 dnl We have compile_et. Now let's see if it supports `prefix' and `index'.
15 AC_MSG_CHECKING(whether compile_et has the features we need)
16 cat > conftest_et.et <<'EOF'
20 error_code CODE1, "CODE1"
22 error_code CODE2, "CODE2"
25 if ${COMPILE_ET} conftest_et.et >/dev/null 2>&1; then
26 dnl XXX Some systems have <et/com_err.h>.
27 save_CPPFLAGS="${CPPFLAGS}"
28 if test -d "/usr/include/et"; then
29 CPPFLAGS="-I/usr/include/et ${CPPFLAGS}"
31 dnl Check that the `prefix' and `index' directives were honored.
35 #include "conftest_et.h"
36 int main(int argc, char **argv){
37 #ifndef ERROR_TABLE_BASE_conf
38 #error compile_et does not handle error_table N M
40 return (CONFTEST_CODE2 - CONFTEST_CODE1) != 127;}
41 ], [krb_cv_compile_et="yes"],[CPPFLAGS="${save_CPPFLAGS}"],
42 [krb_cv_compile_et="yes" krb_cv_compile_et_cross=yes] )
44 AC_MSG_RESULT(${krb_cv_compile_et})
45 if test "${krb_cv_compile_et}" = "yes" -a "${krb_cv_compile_et_cross}" = no; then
46 AC_MSG_CHECKING([for if com_err generates a initialize_conf_error_table_r])
47 AC_EGREP_CPP([initialize_conf_error_table_r.*struct et_list],
48 [#include "conftest_et.h"],
49 [krb_cv_com_err_need_r="ok"])
50 if test X"$krb_cv_com_err_need_r" = X ; then
60 if test "${krb_cv_compile_et_cross}" = yes ; then
61 krb_cv_com_err="cross"
62 elif test "${krb_cv_compile_et}" = "yes"; then
63 dnl Since compile_et seems to work, let's check libcom_err
64 krb_cv_save_LIBS="${LIBS}"
65 LIBS="${LIBS} -lcom_err"
66 AC_MSG_CHECKING(for com_err)
67 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <com_err.h>]],[[
70 initialize_error_table_r(0,0,0,0);
71 ]])],[krb_cv_com_err="yes"],[krb_cv_com_err="no"; CPPFLAGS="${save_CPPFLAGS}"])
72 AC_MSG_RESULT(${krb_cv_com_err})
73 LIBS="${krb_cv_save_LIBS}"
75 dnl Since compile_et doesn't work, forget about libcom_err
79 dnl Only use the system's com_err if we found compile_et, libcom_err, and
81 if test "${krb_cv_com_err}" = "yes"; then
83 LIB_com_err="-lcom_err"
86 AC_MSG_NOTICE(Using the already-installed com_err)
88 elif test "${krb_cv_com_err}" = "cross"; then
90 LIB_com_err="\$(top_builddir)/lib/com_err/libcom_err.la"
91 LIB_com_err_a="\$(top_builddir)/lib/com_err/.libs/libcom_err.a"
92 LIB_com_err_so="\$(top_builddir)/lib/com_err/.libs/libcom_err.so"
93 AC_MSG_NOTICE(Using our own com_err with toolchain compile_et)
96 COMPILE_ET="\$(top_builddir)/lib/com_err/compile_et"
98 LIB_com_err="\$(top_builddir)/lib/com_err/libcom_err.la"
99 LIB_com_err_a="\$(top_builddir)/lib/com_err/.libs/libcom_err.a"
100 LIB_com_err_so="\$(top_builddir)/lib/com_err/.libs/libcom_err.so"
101 AC_MSG_NOTICE(Using our own com_err)
104 AM_CONDITIONAL(COM_ERR, test "$localcomerr" = yes)dnl
105 AC_SUBST(DIR_com_err)
106 AC_SUBST(LIB_com_err)
107 AC_SUBST(LIB_com_err_a)
108 AC_SUBST(LIB_com_err_so)