Merged revisions 151240 via svnmerge from
[asterisk/asterisk.git] / autoconf / ast_c_define_check.m4
1 # Check if a given macro is defined in a certain header.
2
3 # AST_C_DEFINE_CHECK([package], [macro name], [header file], [version])
4 AC_DEFUN([AST_C_DEFINE_CHECK],
5 [
6     if test "x${PBX_$1}" != "x1"; then
7         AC_MSG_CHECKING([for $2 in $3])
8         saved_cppflags="${CPPFLAGS}"
9         if test "x${$1_DIR}" != "x"; then
10             $1_INCLUDE="-I${$1_DIR}/include"
11         fi
12         CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
13
14         AC_COMPILE_IFELSE(
15             [ AC_LANG_PROGRAM( [#include <$3>],
16                                [#if defined($2)
17                                 int foo = 0;
18                                 #else
19                                 int foo = bar;
20                                 #endif
21                                 0
22                                ])],
23             [   AC_MSG_RESULT(yes)
24                 PBX_$1=1
25                 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
26                 AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
27             ],
28             [   AC_MSG_RESULT(no) ] 
29         )
30         CPPFLAGS="${saved_cppflags}"
31     fi
32     AC_SUBST(PBX_$1)
33 ])