autoconf: Use m4 conditionals where possible.

Change-Id: I530c0a72f965437acef6a9a4fbfe5c487f078b65
This commit is contained in:
Corey Farrell
2017-11-17 11:38:48 -05:00
parent 87a57e8d46
commit ce5cfc8ffb
7 changed files with 2048 additions and 3823 deletions

View File

@@ -4,11 +4,7 @@
AC_DEFUN([AST_C_COMPILE_CHECK],
[
if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
if test "x$5" != "x"; then
AC_MSG_CHECKING([for $5])
else
AC_MSG_CHECKING([if "$2" compiles using $3])
fi
AC_MSG_CHECKING(m4_ifval([$5],[for $5],[if "$2" compiles using $3]))
saved_cppflags="${CPPFLAGS}"
if test "x${$1_DIR}" != "x"; then
$1_INCLUDE="-I${$1_DIR}/include"

View File

@@ -191,11 +191,7 @@ fi
])
AC_DEFUN([AST_CHECK_PWLIB_VERSION], [
if test "x$7" != "x"; then
VNAME="$7"
else
VNAME="$2_VERSION"
fi
VNAME="m4_default([$7],[$2_VERSION])"
if test "${HAS_$2:-unset}" != "unset"; then
$2_VERSION=`grep "$VNAME \"" ${$2_INCDIR}/$3 | sed -e 's/[[[:space:]]]\{1,\}/ /g' | cut -f3 -d ' ' | sed -e 's/"//g'`
@@ -204,11 +200,7 @@ AC_DEFUN([AST_CHECK_PWLIB_VERSION], [
$2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
$2_VER=$((${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}))
$2_REQ=$(($4*10000+$5*100+$6))
if test "x$10" = "x"; then
$2_MAX=9999999
else
$2_MAX=$(($8*10000+$9*100+$10))
fi
$2_MAX=m4_ifblank([$10], [9999999], [$(($8*10000+$9*100+$10))])
AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
if test ${$2_VER} -lt ${$2_REQ}; then

View File

@@ -117,15 +117,15 @@ if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
pbxlibdir="-L${$1_DIR}"
fi
fi
pbxfuncname="$3"
if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers
m4_ifblank([$3], [
# empty lib, assume only headers
AST_$1_FOUND=yes
else
], [
ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} $6"
AC_CHECK_LIB([$2], [${pbxfuncname}], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], [${pbxlibdir} $5])
AC_CHECK_LIB([$2], [$3], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], [${pbxlibdir} $5])
CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
fi
])
# now check for the header.
if test "${AST_$1_FOUND}" = "yes"; then
@@ -135,21 +135,24 @@ if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
$1_INCLUDE="-I${$1_DIR}/include"
fi
$1_INCLUDE="${$1_INCLUDE} $6"
if test "x$4" = "x" ; then # no header, assume found
m4_ifblank([$4], [
# no header, assume found
$1_HEADER_FOUND="1"
else # check for the header
], [
# check for the header
ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
CPPFLAGS="${ast_ext_lib_check_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
m4_ifblank([$3], [
# only checking headers -> no library
$1_LIB=""
fi
])
PBX_$1=1
cat >>confdefs.h <<_ACEOF
[@%:@define] HAVE_$1 1

View File

@@ -10,15 +10,13 @@ AC_DEFUN([AST_EXT_TOOL_CHECK],
PBX_$1=0
AC_PATH_TOOL(CONFIG_$1, $2, No, [${$1_DIR}/bin:$PATH])
if test ! "x${CONFIG_$1}" = xNo; then
if test x"$3" = x ; then A=--cflags ; else A="$3" ; fi
$1_INCLUDE=$(${CONFIG_$1} $A)
$1_INCLUDE=$(${CONFIG_$1} m4_default([$3],[--cflags]))
$1_INCLUDE=$(echo ${$1_INCLUDE} | $SED -e "s|-I|-I${$1_DIR}|g")
if test x"$4" = x ; then A=--libs ; else A="$4" ; fi
$1_LIB=$(${CONFIG_$1} $A)
$1_LIB=$(${CONFIG_$1} m4_default([$4],[--libs]))
$1_LIB=$(echo ${$1_LIB} | $SED -e "s|-L|-L${$1_DIR}|g")
if test x"$5" != x ; then
m4_ifval([$5], [
saved_cppflags="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
@@ -28,15 +26,15 @@ AC_DEFUN([AST_EXT_TOOL_CHECK],
AC_LINK_IFELSE(
[ AC_LANG_PROGRAM( [ $5 ], [ $6; ])],
[ PBX_$1=1 AC_DEFINE([HAVE_$1], 1,
[Define if your system has the $1 headers.])],
[Define if your system has the $1 libraries.])],
[]
)
CPPFLAGS="${saved_cppflags}"
LIBS="${saved_libs}"
else
], [
PBX_$1=1
AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 libraries.])
fi
])
fi
fi
])

View File

@@ -9,28 +9,17 @@ CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
m4_ifval([$4],$4=0)
ax_cv_have_func_attribute_$1=0
if test "x$2" = "x"
then
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([$3 void __attribute__(($1)) *test(void *muffin, ...) {return (void *) 0;}],
[])],
[AC_LANG_PROGRAM(
m4_ifblank([$2],
[$3 void __attribute__(($1)) *test(void *muffin, ...) {return (void *) 0;}],
[$3 void __attribute__(($2)) *test(void *muffin, ...) ;]))],
AC_MSG_RESULT(yes)
m4_ifval([$4],$4=1)
ax_cv_have_func_attribute_$1=1
AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
AC_MSG_RESULT(no)
)
else
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([$3 void __attribute__(($2)) *test(void *muffin, ...) ;],
[])],
AC_MSG_RESULT(yes)
m4_ifval([$4],$4=1)
ax_cv_have_func_attribute_$1=1
AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
AC_MSG_RESULT(no)
)
fi
m4_ifval([$4],[AC_SUBST($4)])
CFLAGS="$saved_CFLAGS"