another variable to clear out before configuring mxml
[asterisk-bristuff.git] / acinclude.m4
blobb621923ef398e972e75befba1f6547b0b41659f8
1 # AST_GCC_ATTRIBUTE([attribute name])
3 AC_DEFUN([AST_GCC_ATTRIBUTE],
5 AC_MSG_CHECKING(checking for compiler 'attribute $1' support)
6 AC_COMPILE_IFELSE(
7         AC_LANG_PROGRAM([static int __attribute__(($1)) test(void) {}],
8                         []),
9         AC_MSG_RESULT(yes)
10         AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
11         AC_MSG_RESULT(no))
14 # AST_EXT_LIB_SETUP([package symbol name], [package friendly name], [package option name], [additional help text])
16 AC_DEFUN([AST_EXT_LIB_SETUP],
18 $1_DESCRIP="$2"
19 $1_OPTION="$3"
20 AC_ARG_WITH([$3], AC_HELP_STRING([--with-$3=PATH],[use $2 files in PATH $4]),[
21 case ${withval} in
22      n|no)
23      USE_$1=no
24      ;;
25      y|ye|yes)
26      $1_MANDATORY="yes"
27      ;;
28      *)
29      $1_DIR="${withval}"
30      $1_MANDATORY="yes"
31      ;;
32 esac
34 PBX_$1=0
35 AC_SUBST([$1_LIB])
36 AC_SUBST([$1_INCLUDE])
37 AC_SUBST([PBX_$1])
40 # AST_EXT_LIB_CHECK([package symbol name], [package library name], [function to check], [package header], [additional LIB data])
42 AC_DEFUN([AST_EXT_LIB_CHECK],
44 if test "${USE_$1}" != "no"; then
45    pbxlibdir=""
46    if test "x${$1_DIR}" != "x"; then
47       if test -d ${$1_DIR}/lib; then
48          pbxlibdir="-L${$1_DIR}/lib"
49       else
50          pbxlibdir="-L${$1_DIR}"
51       fi
52    fi
53    AC_CHECK_LIB([$2], [$3], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
55    if test "${AST_$1_FOUND}" = "yes"; then
56       $1_LIB="-l$2 $5"
57       $1_HEADER_FOUND="1"
58       if test "x${$1_DIR}" != "x"; then
59          $1_LIB="${pbxlibdir} ${$1_LIB}"
60          $1_INCLUDE="-I${$1_DIR}/include"
61          if test "x$4" != "x" ; then
62             AC_CHECK_HEADER([${$1_DIR}/include/$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0] )
63          fi
64       else
65          if test "x$4" != "x" ; then
66             AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0] )
67          fi
68       fi
69       if test "x${$1_HEADER_FOUND}" = "x0" ; then
70          if test ! -z "${$1_MANDATORY}" ;
71          then
72             AC_MSG_NOTICE( ***)
73             AC_MSG_NOTICE( *** It appears that you do not have the $2 development package installed.)
74             AC_MSG_NOTICE( *** Please install it to include ${$1_DESCRIP} support, or re-run configure)
75             AC_MSG_NOTICE( *** without explicitly specifying --with-${$1_OPTION})
76             exit 1
77          fi
78          $1_LIB=""
79          $1_INCLUDE=""
80          PBX_$1=0
81       else
82          PBX_$1=1
83          AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define to indicate the ${$1_DESCRIP} library])
84       fi
85    elif test ! -z "${$1_MANDATORY}";
86    then
87       AC_MSG_NOTICE(***)
88       AC_MSG_NOTICE(*** The ${$1_DESCRIP} installation on this system appears to be broken.)
89       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
90       AC_MSG_NOTICE(*** without explicitly specifying --with-${$1_OPTION})
91       exit 1
92    fi
97 AC_DEFUN(
98 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
99    GNU_MAKE='Not Found' ;
100    GNU_MAKE_VERSION_MAJOR=0 ;
101    GNU_MAKE_VERSION_MINOR=0 ;
102    for a in make gmake gnumake ; do
103       if test -z "$a" ; then continue ; fi ;
104       if ( sh -c "$a --version" 2> /dev/null | grep GNU  2>&1 > /dev/null ) ;  then
105          GNU_MAKE=$a ;
106          GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
107          GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
108          break;
109       fi
110    done ;
111 ) ;
112 if test  "x$GNU_MAKE" = "xNot Found"  ; then
113    AC_MSG_ERROR( *** Please install GNU make.  It is required to build Asterisk!)
114    exit 1
116 AC_SUBST([GNU_MAKE])
119 # AST_FUNC_FORK
120 # -------------
121 AN_FUNCTION([fork],  [AST_FUNC_FORK])
122 AN_FUNCTION([vfork], [AST_FUNC_FORK])
123 AC_DEFUN([AST_FUNC_FORK],
124 [AC_REQUIRE([AC_TYPE_PID_T])dnl
125 AC_CHECK_HEADERS(vfork.h)
126 AC_CHECK_FUNCS(fork vfork)
127 if test "x$ac_cv_func_fork" = xyes; then
128   _AST_FUNC_FORK
129 else
130   ac_cv_func_fork_works=$ac_cv_func_fork
132 if test "x$ac_cv_func_fork_works" = xcross; then
133   case $host in
134     *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
135       # Override, as these systems have only a dummy fork() stub
136       ac_cv_func_fork_works=no
137       ;;
138     *)
139       ac_cv_func_fork_works=yes
140       ;;
141   esac
142   AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
144 ac_cv_func_vfork_works=$ac_cv_func_vfork
145 if test "x$ac_cv_func_vfork" = xyes; then
146   _AC_FUNC_VFORK
148 if test "x$ac_cv_func_fork_works" = xcross; then
149   ac_cv_func_vfork_works=$ac_cv_func_vfork
150   AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
153 if test "x$ac_cv_func_vfork_works" = xyes; then
154   AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
155 else
156   AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
158 if test "x$ac_cv_func_fork_works" = xyes; then
159   AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
161 ])# AST_FUNC_FORK
164 # _AST_FUNC_FORK
165 # -------------
166 AC_DEFUN([_AST_FUNC_FORK],
167   [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
168     [AC_RUN_IFELSE(
169       [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
170         [
171           /* By Ruediger Kuhlmann. */
172           return fork () < 0;
173         ])],
174       [ac_cv_func_fork_works=yes],
175       [ac_cv_func_fork_works=no],
176       [ac_cv_func_fork_works=cross])])]
177 )# _AST_FUNC_FORK