summaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2000-04-25 18:29:12 +0000
committerThomas Roessler <roessler@does-not-exist.org>2000-04-25 18:29:12 +0000
commit09afe8b3b6555b3163a470a9cb3b29d7de60a1cf (patch)
tree59e18d0ecc29d9628e3d332b99a1c48ef59b898b /m4
parentfdbc2cfe0a156ebf17ce49ad844c183a5d9fdb63 (diff)
New macros CF_CHECK_FUNCDECL, CF_CHECK_FUNCDECLS, CF_UPPER. These
are slightly modified versions of T. E. Dickey's macros from the lynx distribution. (From Lars Hecking.)
Diffstat (limited to 'm4')
-rw-r--r--m4/funcdecl.m462
1 files changed, 62 insertions, 0 deletions
diff --git a/m4/funcdecl.m4 b/m4/funcdecl.m4
new file mode 100644
index 00000000..f46be2ef
--- /dev/null
+++ b/m4/funcdecl.m4
@@ -0,0 +1,62 @@
+dnl ---------------------------------------------------------------------------
+dnl Check if a function is declared by including a set of include files.
+dnl Invoke the corresponding actions according to whether it is found or not.
+dnl
+dnl Gcc (unlike other compilers) will only warn about the miscast assignment
+dnl in the first test, but most compilers will oblige with an error in the
+dnl second test.
+dnl
+dnl CF_CHECK_FUNCDECL(INCLUDES, FUNCTION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+AC_DEFUN([CF_CHECK_FUNCDECL],
+[
+AC_MSG_CHECKING([for $2 declaration])
+AC_CACHE_VAL(ac_cv_func_decl_$2,
+[AC_TRY_COMPILE([$1],
+[#ifndef ${ac_func}
+extern int ${ac_func}();
+#endif],[
+AC_TRY_COMPILE([$1],
+[#ifndef ${ac_func}
+int (*p)() = ${ac_func};
+#endif],[
+eval "ac_cv_func_decl_$2=yes"],[
+eval "ac_cv_func_decl_$2=no"])],[
+eval "ac_cv_func_decl_$2=yes"])])
+if eval "test \"`echo '$ac_cv_func_'decl_$2`\" = yes"; then
+ AC_MSG_RESULT(yes)
+ ifelse([$3], , :, [$3])
+else
+ AC_MSG_RESULT(no)
+ifelse([$4], , , [$4
+])dnl
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl Check if functions are declared by including a set of include files.
+dnl and define DECL_XXX if not.
+dnl
+dnl CF_CHECK_FUNCDECLS(INCLUDES, FUNCTION... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+AC_DEFUN([CF_CHECK_FUNCDECLS],
+[for ac_func in $2
+do
+CF_CHECK_FUNCDECL([$1], $ac_func,
+[
+ CF_UPPER(ac_tr_func,HAVE_$ac_func)
+ AC_DEFINE_UNQUOTED($ac_tr_func) $3],
+[$4])dnl
+dnl [$3],
+dnl [
+dnl CF_UPPER(ac_tr_func,DECL_$ac_func)
+dnl AC_DEFINE_UNQUOTED($ac_tr_func) $4])dnl
+done
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl Make an uppercase version of a variable
+dnl $1=uppercase($2)
+AC_DEFUN([CF_UPPER],
+[
+changequote(,)dnl
+$1=`echo $2 | tr '[a-z]' '[A-Z]'`
+changequote([,])dnl
+])dnl
+dnl ---------------------------------------------------------------------------