Thanks to the fine work of Russell Bryant and Dancho Lazarov, we now have autoconf...
[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], AC_DEFINE_UNQUOTED([HAVE_$4], 1,
24    [Define to indicate the $5 library]), [], -L${$1_DIR}/lib $6)
25
26    if test "${ac_cv_lib_$1_$2}" = "yes"; then
27       $1_LIB="-l$1 $6"
28       $4_HEADER_FOUND="1"
29       if test "x${$1_DIR}" != "x"; then
30          $1_LIB="-L${$1_DIR}/lib ${$1_LIB}"
31          $1_INCLUDE="-I${$1_DIR}/include"
32          if test "x$3" != "x" ; then
33             AC_CHECK_HEADER([${$1_DIR}/include/$3], [$4_HEADER_FOUND=1], [$4_HEADER_FOUND=0] )
34          fi
35       else
36          if test "x$3" != "x" ; then
37             AC_CHECK_HEADER([$3], [$4_HEADER_FOUND=1], [$4_HEADER_FOUND=0] )
38          fi
39       fi
40       if test "x${$4_HEADER_FOUND}" = "x0" ; then
41         echo " ***"
42         echo " *** It appears that you do not have the $5 development package installed."
43         echo " *** Please install it to include $5 support, or re-run configure"
44         echo " *** with the argument --without-$1"
45         exit 1
46       fi
47       PBX_LIB$1=1 
48    elif test ! -z "${$1_MANDATORY}";
49    then
50       echo "***"
51       echo "*** The $5 installation on this system appears to be broken."
52       echo "*** Either correct the installation, or run configure"
53       echo "*** including --without-$1"
54       exit 1
55    fi
56 fi
57 AC_SUBST([$1_LIB])
58 AC_SUBST([$1_INCLUDE])
59 AC_SUBST([PBX_LIB$1])
60 ])
61
62
63 AC_DEFUN(
64 [AST_CHECK_GNU_MAKE], [ AC_CACHE_CHECK( for GNU make, GNU_MAKE,
65    GNU_MAKE='Not Found' ;
66    for a in make gmake gnumake ; do
67       if test -z "$a" ; then continue ; fi ;
68       if ( sh -c "$a --version" 2> /dev/null | grep GNU  2>&1 > /dev/null ) ;  then
69          GNU_MAKE=$a ;
70          break;
71       fi
72    done ;
73 ) ;
74 if test  "x$GNU_MAKE" = "xNot Found"  ; then
75    echo " *** Please install GNU make.  It is required to build Asterisk!"
76    exit 1
77 fi
78 AC_SUBST([GNU_MAKE])
79 ] )