support ./configure --silent
[asterisk/asterisk.git] / acinclude.m4
1 # AST_EXT_LIB_SETUP([package symbol name], [package friendly name], [package option name], [additional help text])
2
3 AC_DEFUN([AST_EXT_LIB_SETUP],
4 [
5 $1_DESCRIP="$2"
6 $1_OPTION="$3"
7 AC_ARG_WITH([$3], AC_HELP_STRING([--with-$3=PATH],[use $2 files in PATH $4]),[
8 case ${withval} in
9      n|no)
10      USE_$1=no
11      ;;
12      y|ye|yes)
13      $1_MANDATORY="yes"
14      ;;
15      *)
16      $1_DIR="${withval}"
17      $1_MANDATORY="yes"
18      ;;
19 esac
20 ])
21 PBX_$1=0
22 AC_SUBST([$1_LIB])
23 AC_SUBST([$1_INCLUDE])
24 AC_SUBST([PBX_$1])
25 ])
26
27 # AST_EXT_LIB_CHECK([package symbol name], [package library name], [function to check], [package header], [additional LIB data])
28
29 AC_DEFUN([AST_EXT_LIB_CHECK],
30 [
31 if test "${USE_$1}" != "no"; then
32    pbxlibdir=""
33    if test "x${$1_DIR}" != "x"; then
34       if test -d ${$1_DIR}/lib; then
35          pbxlibdir="-L${$1_DIR}/lib"
36       else
37          pbxlibdir="-L${$1_DIR}"
38       fi
39    fi
40    AC_CHECK_LIB([$2], [$3], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
41
42    if test "${AST_$1_FOUND}" = "yes"; then
43       $1_LIB="-l$2 $5"
44       $1_HEADER_FOUND="1"
45       if test "x${$1_DIR}" != "x"; then
46          $1_LIB="${pbxlibdir} ${$1_LIB}"
47          $1_INCLUDE="-I${$1_DIR}/include"
48          if test "x$4" != "x" ; then
49             AC_CHECK_HEADER([${$1_DIR}/include/$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0] )
50          fi
51       else
52          if test "x$4" != "x" ; then
53             AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0] )
54          fi
55       fi
56       if test "x${$1_HEADER_FOUND}" = "x0" ; then
57          if test ! -z "${$1_MANDATORY}" ;
58          then
59             AC_MSG_NOTICE( ***)
60             AC_MSG_NOTICE( *** It appears that you do not have the $2 development package installed.)
61             AC_MSG_NOTICE( *** Please install it to include ${$1_DESCRIP} support, or re-run configure)
62             AC_MSG_NOTICE( *** without explicitly specifying --with-${$1_OPTION})
63             exit 1
64          fi
65          $1_LIB=""
66          $1_INCLUDE=""
67          PBX_$1=0
68       else
69          PBX_$1=1
70          AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define to indicate the ${$1_DESCRIP} library])
71       fi
72    elif test ! -z "${$1_MANDATORY}";
73    then
74       AC_MSG_NOTICE(***)
75       AC_MSG_NOTICE(*** The ${$1_DESCRIP} installation on this system appears to be broken.)
76       AC_MSG_NOTICE(*** Either correct the installation, or run configure)
77       AC_MSG_NOTICE(*** without explicitly specifying --with-${$1_OPTION})
78       exit 1
79    fi
80 fi
81 ])
82
83
84 AC_DEFUN(
85 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
86    GNU_MAKE='Not Found' ;
87    for a in make gmake gnumake ; do
88       if test -z "$a" ; then continue ; fi ;
89       if ( sh -c "$a --version" 2> /dev/null | grep GNU  2>&1 > /dev/null ) ;  then
90          GNU_MAKE=$a ;
91          break;
92       fi
93    done ;
94 ) ;
95 if test  "x$GNU_MAKE" = "xNot Found"  ; then
96    AC_MSG_ERROR( *** Please install GNU make.  It is required to build Asterisk!)
97    exit 1
98 fi
99 AC_SUBST([GNU_MAKE])
100 ])