xref: /netbsd-src/external/bsd/tre/dist/m4/ax_check_funcs_comp.m4 (revision 63d4abf06d37aace2f9e41a494102a64fe3abddb)
1*63d4abf0Sagcdnl Like AC_CHECK_FUNCS, but allows the function definition to be
2*63d4abf0Sagcdnl a macro.  This allows for detection of functions which are renamed
3*63d4abf0Sagcdnl with macros to something other than the name we are testing with.
4*63d4abf0SagcAC_DEFUN([AX_CHECK_FUNCS_COMP],[
5*63d4abf0Sagc  dnl This is magic to make autoheader pick up the config.h.in templates
6*63d4abf0Sagc  dnl automatically.  This uses macros which are probably not public
7*63d4abf0Sagc  dnl (not documented anyway) but this works at least with Automake 2.59.
8*63d4abf0Sagc  AC_FOREACH([AX_Func], [$1],
9*63d4abf0Sagc    [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AX_Func),
10*63d4abf0Sagc                 [Define to 1 if you have the `]AX_Func[' function or macro.])])dnl
11*63d4abf0Sagc  for ax_func in $1; do
12*63d4abf0Sagc    ax_fname=`echo $ax_func | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g"`
13*63d4abf0Sagc    ax_symbolname=`echo $ax_func | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g" | tr "@<:@a-z@:>@" "@<:@A-Z@:>@"`
14*63d4abf0Sagc    AC_CACHE_CHECK([for $ax_func], ax_cv_func_${ax_fname}, [
15*63d4abf0Sagc      AC_LINK_IFELSE(
16*63d4abf0Sagc        [ AC_LANG_PROGRAM(
17*63d4abf0Sagc            [$4
18*63d4abf0Sagcvoid *foo = $ax_func;
19*63d4abf0Sagc],
20*63d4abf0Sagc            [  return foo != $ax_func; ])],
21*63d4abf0Sagc	[ eval "ax_cv_func_${ax_fname}=\"yes\"" ],
22*63d4abf0Sagc	[ eval "ax_cv_func_${ax_fname}=\"no\"" ])])
23*63d4abf0Sagc    if eval "test \"\${ax_cv_func_${ax_fname}}\" = \"yes\""; then
24*63d4abf0Sagc      AC_DEFINE_UNQUOTED(HAVE_${ax_symbolname}, 1,
25*63d4abf0Sagc        [Define to 1 if you have the $ax_func() function.])
26*63d4abf0Sagc      $2
27*63d4abf0Sagc    else
28*63d4abf0Sagc      true
29*63d4abf0Sagc      $3
30*63d4abf0Sagc    fi
31*63d4abf0Sagc  done
32*63d4abf0Sagc])dnl
33