don't use lower and upper temporaries
[gnulib.git] / m4 / decl.m4
1 AC_DEFUN(jm_CHECK_DECLARATION,
2 [
3   AC_REQUIRE(AC_HEADER_STDC)
4   test -z "$ac_cv_header_memory_h" && AC_CHECK_HEADERS(memory.h)
5   test -z "$ac_cv_header_string_h" && AC_CHECK_HEADERS(string.h)
6   test -z "$ac_cv_header_strings_h" && AC_CHECK_HEADERS(strings.h)
7   test -z "$ac_cv_header_unistd_h" && AC_CHECK_HEADERS(unistd.h)
8   AC_MSG_CHECKING([whether $1 is declared])
9   AC_CACHE_VAL(jm_cv_func_decl_$1,
10     [AC_TRY_COMPILE([
11 #include <stdio.h>
12 #ifdef HAVE_STRING_H
13 # if !STDC_HEADERS && HAVE_MEMORY_H
14 #  include <memory.h>
15 # endif
16 # include <string.h>
17 #else
18 # ifdef HAVE_STRINGS_H
19 #  include <strings.h>
20 # endif
21 #endif
22 #ifdef STDC_HEADERS
23 # include <stdlib.h>
24 #endif
25 #ifdef HAVE_UNISTD_H
26 # include <unistd.h>
27 #endif],
28 [
29 #ifndef $1
30 char *(*pfn) = (char *(*)) $1
31 #endif
32 ],
33   eval "jm_cv_func_decl_$1=yes",
34   eval "jm_cv_func_decl_$1=no")])
35
36 if eval "test \"`echo '$jm_cv_func_decl_'$1`\" = yes"; then
37   AC_MSG_RESULT(yes)
38   ifelse([$2], , :, [$2])
39 else
40   AC_MSG_RESULT(no)
41   ifelse([$3], , , [$3
42 ])dnl
43 fi
44 ])dnl
45
46 dnl jm_CHECK_DECLARATIONS(FUNCTION... [, ACTION-IF-DECLARED
47 dnl                       [, ACTION-IF-NOT-DECLARED]])
48 AC_DEFUN(jm_CHECK_DECLARATIONS,
49 [
50   for jm_func in $1
51   do
52     jm_CHECK_DECLARATION($jm_func,
53     [
54       jm_tr_func=HAVE_DECLARATION_`echo $jm_func | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
55       AC_DEFINE_UNQUOTED($jm_tr_func) $2], $3)dnl
56   done
57 ])