mutt_*mktemp--
[apps/madmutt.git] / m4 / funcdecl.m4
1 dnl ---------------------------------------------------------------------------
2 dnl Check if a function is declared by including a set of include files.
3 dnl Invoke the corresponding actions according to whether it is found or not.
4 dnl
5 dnl Gcc (unlike other compilers) will only warn about the miscast assignment
6 dnl in the first test, but most compilers will oblige with an error in the
7 dnl second test.
8 dnl
9 dnl CF_CHECK_FUNCDECL(INCLUDES, FUNCTION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
10 AC_DEFUN([CF_CHECK_FUNCDECL],
11 [
12 AC_MSG_CHECKING([for $2 declaration])
13 AC_CACHE_VAL(ac_cv_func_decl_$2,
14 [AC_TRY_COMPILE([$1],
15 [#ifndef ${ac_func}
16 extern  int     ${ac_func}();
17 #endif],[
18 AC_TRY_COMPILE([$1],
19 [#ifndef ${ac_func}
20 int     (*p)() = ${ac_func};
21 #endif],[
22 eval "ac_cv_func_decl_$2=yes"],[
23 eval "ac_cv_func_decl_$2=no"])],[
24 eval "ac_cv_func_decl_$2=yes"])])
25 if eval "test \"`echo '$ac_cv_func_'decl_$2`\" = yes"; then
26   AC_MSG_RESULT(yes)
27   ifelse([$3], , :, [$3])
28 else
29   AC_MSG_RESULT(no)
30 ifelse([$4], , , [$4
31 ])dnl
32 fi
33 ])dnl
34 dnl ---------------------------------------------------------------------------
35 dnl Check if functions are declared by including a set of include files.
36 dnl and define DECL_XXX if not.
37 dnl
38 dnl CF_CHECK_FUNCDECLS(INCLUDES, FUNCTION... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
39 AC_DEFUN([CF_CHECK_FUNCDECLS],
40 [for ac_func in $2
41 do
42 CF_CHECK_FUNCDECL([$1], $ac_func,
43 [
44   CF_UPPER(ac_tr_func,HAVE_$ac_func)
45   AC_DEFINE_UNQUOTED($ac_tr_func) $3],
46 [$4])dnl
47 dnl [$3],
48 dnl [
49 dnl   CF_UPPER(ac_tr_func,DECL_$ac_func)
50 dnl   AC_DEFINE_UNQUOTED($ac_tr_func) $4])dnl
51 done
52 ])dnl
53 dnl ---------------------------------------------------------------------------
54 dnl Make an uppercase version of a variable
55 dnl $1=uppercase($2)
56 AC_DEFUN([CF_UPPER],
57 [
58 changequote(,)dnl
59 $1=`echo $2 | tr '[a-z]' '[A-Z]'`
60 changequote([,])dnl
61 ])dnl
62 dnl ---------------------------------------------------------------------------