summaryrefslogtreecommitdiffstats
path: root/third_party/heimdal/cf/check-compile-et.m4
blob: e580cbb49587a73671cb257722069f5f7d7293b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
dnl $Id$
dnl
dnl CHECK_COMPILE_ET
AC_DEFUN([CHECK_COMPILE_ET], [

AC_CHECK_PROG(COMPILE_ET, compile_et, [compile_et], [no])

krb_cv_compile_et="no"
krb_cv_com_err_need_r=""
krb_cv_compile_et_cross=no
if test "${COMPILE_ET}" != "no"; then

dnl We have compile_et.  Now let's see if it supports `prefix' and `index'.
AC_MSG_CHECKING(whether compile_et has the features we need)
cat > conftest_et.et <<'EOF'
error_table test conf
prefix CONFTEST
index 1
error_code CODE1, "CODE1"
index 128
error_code CODE2, "CODE2"
end
EOF
if ${COMPILE_ET} conftest_et.et >/dev/null 2>&1; then
  dnl XXX Some systems have <et/com_err.h>.
  save_CPPFLAGS="${CPPFLAGS}"
  if test -d "/usr/include/et"; then
    CPPFLAGS="-I/usr/include/et ${CPPFLAGS}"
  fi
  dnl Check that the `prefix' and `index' directives were honored.
  AC_LANG(C)
  AC_RUN_IFELSE([AC_LANG_SOURCE([
#include <com_err.h>
#include <string.h>
#include "conftest_et.h"
int main(int argc, char **argv){
#ifndef ERROR_TABLE_BASE_conf
#error compile_et does not handle error_table N M
#endif
return (CONFTEST_CODE2 - CONFTEST_CODE1) != 127;}
  ])], [krb_cv_compile_et="yes"],[CPPFLAGS="${save_CPPFLAGS}"],
  [krb_cv_compile_et="yes" krb_cv_compile_et_cross=yes] )
fi
AC_MSG_RESULT(${krb_cv_compile_et})
if test "${krb_cv_compile_et}" = "yes" -a "${krb_cv_compile_et_cross}" = no; then
  AC_MSG_CHECKING([for if com_err generates a initialize_conf_error_table_r])
  AC_EGREP_CPP([initialize_conf_error_table_r.*struct et_list],
     [#include "conftest_et.h"],
     [krb_cv_com_err_need_r="ok"])
  if test X"$krb_cv_com_err_need_r" = X ; then
    AC_MSG_RESULT(no)
    krb_cv_compile_et=no
  else
    AC_MSG_RESULT(yes)
  fi
fi
rm -fr conftest*
fi

if test "${krb_cv_compile_et_cross}" = yes ; then
  krb_cv_com_err="cross"
elif test "${krb_cv_compile_et}" = "yes"; then
  dnl Since compile_et seems to work, let's check libcom_err
  krb_cv_save_LIBS="${LIBS}"
  LIBS="${LIBS} -lcom_err"
  AC_MSG_CHECKING(for com_err)
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <com_err.h>]],[[
    const char *p;
    p = error_message(0);
    initialize_error_table_r(0,0,0,0);
    com_right_r(0, 0, 0, 0);
  ]])],[krb_cv_com_err="yes"],[krb_cv_com_err="no"; CPPFLAGS="${save_CPPFLAGS}"])
  AC_MSG_RESULT(${krb_cv_com_err})
  LIBS="${krb_cv_save_LIBS}"
else
  dnl Since compile_et doesn't work, forget about libcom_err
  krb_cv_com_err="no"
fi

dnl Only use the system's com_err if we found compile_et, libcom_err, and
dnl com_err.h.
if test "${krb_cv_com_err}" = "yes"; then
    DIR_com_err=""
    LIB_com_err="-lcom_err"
    LIB_com_err_a=""
    LIB_com_err_so=""
    AC_MSG_NOTICE(Using the already-installed com_err)
    COMPILE_ET="${ac_cv_prog_COMPILE_ET}"
    localcomerr=no
elif test "${krb_cv_com_err}" = "cross"; then
    DIR_com_err="com_err"
    LIB_com_err="\$(top_builddir)/lib/com_err/libcom_err.la"
    LIB_com_err_a="\$(top_builddir)/lib/com_err/.libs/libcom_err.a"
    LIB_com_err_so="\$(top_builddir)/lib/com_err/.libs/libcom_err.so"
    AC_MSG_NOTICE(Using our own com_err with toolchain compile_et)
    COMPILE_ET="${ac_cv_prog_COMPILE_ET}"
    localcomerr=yes
else
    COMPILE_ET="\$(top_builddir)/lib/com_err/compile_et"
    DIR_com_err="com_err"
    LIB_com_err="\$(top_builddir)/lib/com_err/libcom_err.la"
    LIB_com_err_a="\$(top_builddir)/lib/com_err/.libs/libcom_err.a"
    LIB_com_err_so="\$(top_builddir)/lib/com_err/.libs/libcom_err.so"
    AC_MSG_NOTICE(Using our own com_err)
    localcomerr=yes
fi
AM_CONDITIONAL(COM_ERR, test "$localcomerr" = yes)dnl
AC_SUBST(COMPILE_ET)
AC_SUBST(DIR_com_err)
AC_SUBST(LIB_com_err)
AC_SUBST(LIB_com_err_a)
AC_SUBST(LIB_com_err_so)

])