From 6274e58a25d5d21c4483d047e4ea7ae2600e2470 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Fri, 17 Nov 2017 11:38:48 -0500 Subject: autoconf: Use m4 conditionals where possible. Change-Id: I530c0a72f965437acef6a9a4fbfe5c487f078b65 --- autoconf/ast_c_compile_check.m4 | 6 +----- autoconf/ast_check_pwlib.m4 | 12 ++---------- autoconf/ast_ext_lib.m4 | 23 +++++++++++++---------- autoconf/ast_ext_tool_check.m4 | 14 ++++++-------- autoconf/ast_gcc_attribute.m4 | 19 ++++--------------- 5 files changed, 26 insertions(+), 48 deletions(-) (limited to 'autoconf') diff --git a/autoconf/ast_c_compile_check.m4 b/autoconf/ast_c_compile_check.m4 index ed1563017..ebdaefa89 100644 --- a/autoconf/ast_c_compile_check.m4 +++ b/autoconf/ast_c_compile_check.m4 @@ -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" diff --git a/autoconf/ast_check_pwlib.m4 b/autoconf/ast_check_pwlib.m4 index 81c3f4086..4588fa3b1 100644 --- a/autoconf/ast_check_pwlib.m4 +++ b/autoconf/ast_check_pwlib.m4 @@ -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 diff --git a/autoconf/ast_ext_lib.m4 b/autoconf/ast_ext_lib.m4 index cd5a3a779..e8ce2013d 100644 --- a/autoconf/ast_ext_lib.m4 +++ b/autoconf/ast_ext_lib.m4 @@ -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 diff --git a/autoconf/ast_ext_tool_check.m4 b/autoconf/ast_ext_tool_check.m4 index 758720d24..ef762eb87 100644 --- a/autoconf/ast_ext_tool_check.m4 +++ b/autoconf/ast_ext_tool_check.m4 @@ -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 ]) diff --git a/autoconf/ast_gcc_attribute.m4 b/autoconf/ast_gcc_attribute.m4 index b1972bedf..9d5a32045 100644 --- a/autoconf/ast_gcc_attribute.m4 +++ b/autoconf/ast_gcc_attribute.m4 @@ -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" -- cgit v1.2.3