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