Home | History | Annotate | Line # | Download | only in cf
check-compile-et.m4 revision 1.1.1.3
      1 dnl Id
      2 dnl
      3 dnl CHECK_COMPILE_ET
      4 AC_DEFUN([CHECK_COMPILE_ET], [
      5 
      6 AC_CHECK_PROG(COMPILE_ET, compile_et, [compile_et])
      7 
      8 krb_cv_compile_et="no"
      9 krb_cv_com_err_need_r=""
     10 krb_cv_compile_et_cross=no
     11 if test "${COMPILE_ET}" = "compile_et"; then
     12 
     13 dnl We have compile_et.  Now let's see if it supports `prefix' and `index'.
     14 AC_MSG_CHECKING(whether compile_et has the features we need)
     15 cat > conftest_et.et <<'EOF'
     16 error_table test conf
     17 prefix CONFTEST
     18 index 1
     19 error_code CODE1, "CODE1"
     20 index 128
     21 error_code CODE2, "CODE2"
     22 end
     23 EOF
     24 if ${COMPILE_ET} conftest_et.et >/dev/null 2>&1; then
     25   dnl XXX Some systems have <et/com_err.h>.
     26   save_CPPFLAGS="${CPPFLAGS}"
     27   if test -d "/usr/include/et"; then
     28     CPPFLAGS="-I/usr/include/et ${CPPFLAGS}"
     29   fi
     30   dnl Check that the `prefix' and `index' directives were honored.
     31   AC_RUN_IFELSE([
     32 #include <com_err.h>
     33 #include <string.h>
     34 #include "conftest_et.h"
     35 int main(int argc, char **argv){
     36 #ifndef ERROR_TABLE_BASE_conf
     37 #error compile_et does not handle error_table N M
     38 #endif
     39 return (CONFTEST_CODE2 - CONFTEST_CODE1) != 127;}
     40   ], [krb_cv_compile_et="yes"],[CPPFLAGS="${save_CPPFLAGS}"],
     41   [krb_cv_compile_et="yes" krb_cv_compile_et_cross=yes] )
     42 fi
     43 AC_MSG_RESULT(${krb_cv_compile_et})
     44 if test "${krb_cv_compile_et}" = "yes" -a "${krb_cv_compile_et_cross}" = no; then
     45   AC_MSG_CHECKING([for if com_err generates a initialize_conf_error_table_r])
     46   AC_EGREP_CPP([initialize_conf_error_table_r.*struct et_list],
     47      [#include "conftest_et.h"],
     48      [krb_cv_com_err_need_r="ok"])
     49   if test X"$krb_cv_com_err_need_r" = X ; then
     50     AC_MSG_RESULT(no)
     51     krb_cv_compile_et=no
     52   else
     53     AC_MSG_RESULT(yes)
     54   fi
     55 fi
     56 rm -fr conftest*
     57 fi
     58 
     59 if test "${krb_cv_compile_et_cross}" = yes ; then
     60   krb_cv_com_err="cross"
     61 elif test "${krb_cv_compile_et}" = "yes"; then
     62   dnl Since compile_et seems to work, let's check libcom_err
     63   krb_cv_save_LIBS="${LIBS}"
     64   LIBS="${LIBS} -lcom_err"
     65   AC_MSG_CHECKING(for com_err)
     66   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <com_err.h>]],[[
     67     const char *p;
     68     p = error_message(0);
     69     initialize_error_table_r(0,0,0,0);
     70     com_right_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}"
     74 else
     75   dnl Since compile_et doesn't work, forget about libcom_err
     76   krb_cv_com_err="no"
     77 fi
     78 
     79 dnl Only use the system's com_err if we found compile_et, libcom_err, and
     80 dnl com_err.h.
     81 if test "${krb_cv_com_err}" = "yes"; then
     82     DIR_com_err=""
     83     LIB_com_err="-lcom_err"
     84     LIB_com_err_a=""
     85     LIB_com_err_so=""
     86     AC_MSG_NOTICE(Using the already-installed com_err)
     87     COMPILE_ET="${ac_cv_prog_COMPILE_ET}"
     88     localcomerr=no
     89 elif test "${krb_cv_com_err}" = "cross"; then
     90     DIR_com_err="com_err"
     91     LIB_com_err="\$(top_builddir)/lib/com_err/libcom_err.la"
     92     LIB_com_err_a="\$(top_builddir)/lib/com_err/.libs/libcom_err.a"
     93     LIB_com_err_so="\$(top_builddir)/lib/com_err/.libs/libcom_err.so"
     94     AC_MSG_NOTICE(Using our own com_err with toolchain compile_et)
     95     COMPILE_ET="${ac_cv_prog_COMPILE_ET}"
     96     localcomerr=yes
     97 else
     98     COMPILE_ET="\$(top_builddir)/lib/com_err/compile_et"
     99     DIR_com_err="com_err"
    100     LIB_com_err="\$(top_builddir)/lib/com_err/libcom_err.la"
    101     LIB_com_err_a="\$(top_builddir)/lib/com_err/.libs/libcom_err.a"
    102     LIB_com_err_so="\$(top_builddir)/lib/com_err/.libs/libcom_err.so"
    103     AC_MSG_NOTICE(Using our own com_err)
    104     localcomerr=yes
    105 fi
    106 AM_CONDITIONAL(COM_ERR, test "$localcomerr" = yes)dnl
    107 AC_SUBST(COMPILE_ET)
    108 AC_SUBST(DIR_com_err)
    109 AC_SUBST(LIB_com_err)
    110 AC_SUBST(LIB_com_err_a)
    111 AC_SUBST(LIB_com_err_so)
    112 
    113 ])
    114