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