summaryrefslogtreecommitdiff
path: root/autoconf/ast_ext_lib.m4
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2008-10-20 04:59:04 +0000
committerKevin P. Fleming <kpfleming@digium.com>2008-10-20 04:59:04 +0000
commit3d67e2adeabf663491afdaf3e233e04256f48c41 (patch)
tree0ec85d50e9f71c64d80d2ea17a8b48ee8b2883cd /autoconf/ast_ext_lib.m4
parent3ebf483d2d95a4278b4013f8a16bdd00c44647d9 (diff)
Merged revisions 151240 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r151240 | kpfleming | 2008-10-20 07:45:56 +0300 (Mon, 20 Oct 2008) | 3 lines break up acinclude.m4 into individual files, which will make it easier to maintain, easier to add new macros (less patching) and will ease maintenance of these macros across Asterisk branches ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@151242 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'autoconf/ast_ext_lib.m4')
-rw-r--r--autoconf/ast_ext_lib.m490
1 files changed, 90 insertions, 0 deletions
diff --git a/autoconf/ast_ext_lib.m4 b/autoconf/ast_ext_lib.m4
new file mode 100644
index 000000000..57d83a5d1
--- /dev/null
+++ b/autoconf/ast_ext_lib.m4
@@ -0,0 +1,90 @@
+# Helper function to setup variables for a package.
+# $1 -> the package name. Used in configure.ac and also as a prefix
+# for the variables ($1_DIR, $1_INCLUDE, $1_LIB) in makeopts
+# $3 -> option name, used in --with-$3 or --without-$3 when calling configure.
+# $2 and $4 are just text describing the package (short and long form)
+
+# AST_EXT_LIB_SETUP([package], [short description], [configure option name], [long description])
+
+AC_DEFUN([AST_EXT_LIB_SETUP],
+[
+ $1_DESCRIP="$2"
+ $1_OPTION="$3"
+ AC_ARG_WITH([$3], AC_HELP_STRING([--with-$3=PATH],[use $2 files in PATH $4]),
+ [
+ case ${withval} in
+ n|no)
+ USE_$1=no
+ ;;
+ y|ye|yes)
+ ac_mandatory_list="${ac_mandatory_list} $1"
+ ;;
+ *)
+ $1_DIR="${withval}"
+ ac_mandatory_list="${ac_mandatory_list} $1"
+ ;;
+ esac
+ ])
+ PBX_$1=0
+ AC_SUBST([$1_LIB])
+ AC_SUBST([$1_INCLUDE])
+ AC_SUBST([$1_DIR])
+ AC_SUBST([PBX_$1])
+])
+
+# Check for existence of a given package ($1), either looking up a function
+# in a library, or, if no function is supplied, only check for the
+# existence of the header files.
+
+# AST_EXT_LIB_CHECK([package], [library], [function], [header],
+# [extra libs], [extra cflags], [version])
+AC_DEFUN([AST_EXT_LIB_CHECK],
+[
+if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
+ pbxlibdir=""
+ # if --with-$1=DIR has been specified, use it.
+ if test "x${$1_DIR}" != "x"; then
+ if test -d ${$1_DIR}/lib; then
+ pbxlibdir="-L${$1_DIR}/lib"
+ else
+ pbxlibdir="-L${$1_DIR}"
+ fi
+ fi
+ pbxfuncname="$3"
+ if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers
+ AST_$1_FOUND=yes
+ else
+ AC_CHECK_LIB([$2], [${pbxfuncname}], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
+ fi
+
+ # now check for the header.
+ if test "${AST_$1_FOUND}" = "yes"; then
+ $1_LIB="${pbxlibdir} -l$2 $5"
+ # if --with-$1=DIR has been specified, use it.
+ if test "x${$1_DIR}" != "x"; then
+ $1_INCLUDE="-I${$1_DIR}/include"
+ fi
+ $1_INCLUDE="${$1_INCLUDE} $6"
+ if test "x$4" = "x" ; then # no header, assume found
+ $1_HEADER_FOUND="1"
+ else # check for the header
+ saved_cppflags="${CPPFLAGS}"
+ CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
+ AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
+ CPPFLAGS="${saved_cppflags}"
+ fi
+ if test "x${$1_HEADER_FOUND}" = "x0" ; then
+ $1_LIB=""
+ $1_INCLUDE=""
+ else
+ if test "x${pbxfuncname}" = "x" ; then # only checking headers -> no library
+ $1_LIB=""
+ fi
+ PBX_$1=1
+ # XXX don't know how to evaluate the description (third argument) in AC_DEFINE_UNQUOTED
+ AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define this to indicate the ${$1_DESCRIP} library])
+ AC_DEFINE_UNQUOTED([HAVE_$1_VERSION], [$7], [Define to indicate the ${$1_DESCRIP} library version])
+ fi
+ fi
+fi
+])