Merge from vendor branch BIND:
[dragonfly.git] / crypto / heimdal / cf / check-compile-et.m4
1 dnl $Id: check-compile-et.m4,v 1.6 2001/09/02 17:08:48 assar Exp $
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 if test "${COMPILE_ET}" = "compile_et"; then
10
11 dnl We have compile_et.  Now let's see if it supports `prefix' and `index'.
12 AC_MSG_CHECKING(whether compile_et has the features we need)
13 cat > conftest_et.et <<'EOF'
14 error_table conf
15 prefix CONFTEST
16 index 1
17 error_code CODE1, "CODE1"
18 index 128
19 error_code CODE2, "CODE2"
20 end
21 EOF
22 if ${COMPILE_ET} conftest_et.et >/dev/null 2>&1; then
23   dnl XXX Some systems have <et/com_err.h>.
24   save_CPPFLAGS="${save_CPPFLAGS}"
25   if test -d "/usr/include/et"; then
26     CPPFLAGS="-I/usr/include/et ${CPPFLAGS}"
27   fi
28   dnl Check that the `prefix' and `index' directives were honored.
29   AC_TRY_RUN([
30 #include <com_err.h>
31 #include <string.h>
32 #include "conftest_et.h"
33 int main(){return (CONFTEST_CODE2 - CONFTEST_CODE1) != 127;}
34   ], [krb_cv_compile_et="yes"],[CPPFLAGS="${save_CPPFLAGS}"])
35 fi
36 AC_MSG_RESULT(${krb_cv_compile_et})
37 rm -fr conftest*
38 fi
39
40 if test "${krb_cv_compile_et}" = "yes"; then
41   dnl Since compile_et seems to work, let's check libcom_err
42   krb_cv_save_LIBS="${LIBS}"
43   LIBS="${LIBS} -lcom_err"
44   AC_MSG_CHECKING(for com_err)
45   AC_TRY_LINK([#include <com_err.h>],[
46     const char *p;
47     p = error_message(0);
48   ],[krb_cv_com_err="yes"],[krb_cv_com_err="no"; CPPFLAGS="${save_CPPFLAGS}"])
49   AC_MSG_RESULT(${krb_cv_com_err})
50   LIBS="${krb_cv_save_LIBS}"
51 else
52   dnl Since compile_et doesn't work, forget about libcom_err
53   krb_cv_com_err="no"
54 fi
55
56 dnl Only use the system's com_err if we found compile_et, libcom_err, and
57 dnl com_err.h.
58 if test "${krb_cv_com_err}" = "yes"; then
59     DIR_com_err=""
60     LIB_com_err="-lcom_err"
61     LIB_com_err_a=""
62     LIB_com_err_so=""
63     AC_MSG_NOTICE(Using the already-installed com_err)
64 else
65     COMPILE_ET="\$(top_builddir)/lib/com_err/compile_et"
66     DIR_com_err="com_err"
67     LIB_com_err="\$(top_builddir)/lib/com_err/libcom_err.la"
68     LIB_com_err_a="\$(top_builddir)/lib/com_err/.libs/libcom_err.a"
69     LIB_com_err_so="\$(top_builddir)/lib/com_err/.libs/libcom_err.so"
70     AC_MSG_NOTICE(Using our own com_err)
71 fi
72 AC_SUBST(DIR_com_err)
73 AC_SUBST(LIB_com_err)
74 AC_SUBST(LIB_com_err_a)
75 AC_SUBST(LIB_com_err_so)
76
77 ])