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