8a217b8a304d493cf5ad5ab7a54dcce104109067
[platform/upstream/gnome-common.git] / macros / need-declaration.m4
1 dnl See whether we need a declaration for a function.
2 dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
3 AC_DEFUN([GCC_NEED_DECLARATION],
4 [AC_MSG_CHECKING([whether $1 must be declared])
5 AC_CACHE_VAL(gcc_cv_decl_needed_$1,
6 [AC_TRY_COMPILE([
7 #include <stdio.h>
8 #ifdef HAVE_STRING_H
9 #include <string.h>
10 #else
11 #ifdef HAVE_STRINGS_H
12 #include <strings.h>
13 #endif
14 #endif
15 #ifdef HAVE_STDLIB_H
16 #include <stdlib.h>
17 #endif
18 #ifdef HAVE_UNISTD_H
19 #include <unistd.h>
20 #endif
21 $2],
22 [char *(*pfn) = (char *(*)) $1],
23 eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
24 if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
25   AC_MSG_RESULT(yes)
26   gcc_need_declarations="$gcc_need_declarations $1"
27   gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
28   AC_DEFINE_UNQUOTED($gcc_tr_decl)
29 else
30   AC_MSG_RESULT(no)
31 fi
32 ])dnl
33
34 dnl Check multiple functions to see whether each needs a declaration.
35 dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
36 AC_DEFUN([GCC_NEED_DECLARATIONS],
37 [for ac_func in $1
38 do
39 GCC_NEED_DECLARATION($ac_func, $2)
40 done
41 ]
42 )