Macro AST_PKG_CONFIG_CHECK to use chkconfig
[asterisk/asterisk.git] / autoconf / ast_c_compile_check.m4
1 # Check if a given expression will compile using a certain header.
2
3 # AST_C_COMPILE_CHECK([package], [expression], [header file], [version], [description])
4 AC_DEFUN([AST_C_COMPILE_CHECK],
5 [
6     if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
7         if test "x$5" != "x"; then
8             AC_MSG_CHECKING([for $5])
9         else
10             AC_MSG_CHECKING([if "$2" compiles using $3])
11         fi
12         saved_cppflags="${CPPFLAGS}"
13         if test "x${$1_DIR}" != "x"; then
14             $1_INCLUDE="-I${$1_DIR}/include"
15         fi
16         CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
17
18         AC_COMPILE_IFELSE(
19             [ AC_LANG_PROGRAM( [#include <$3>],
20                                [ $2; ]
21                                )],
22             [   AC_MSG_RESULT(yes)
23                 PBX_$1=1
24                 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
25                 m4_ifval([$4], [AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])])
26             ],
27             [       AC_MSG_RESULT(no) ] 
28         )
29         CPPFLAGS="${saved_cppflags}"
30     fi
31 ])