[Asterisk-code-review] autoconf: Use m4 conditional in AST EXT TOOL CHECK. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Mon Nov 27 13:48:45 CST 2017


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7377


Change subject: autoconf: Use m4 conditional in AST_EXT_TOOL_CHECK.
......................................................................

autoconf: Use m4 conditional in AST_EXT_TOOL_CHECK.

Change-Id: Iaed407519103c20501352d3f8b9d86d4f44c16a2
---
M autoconf/ast_ext_tool_check.m4
M configure
M menuselect/configure
3 files changed, 27 insertions(+), 148 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/77/7377/1

diff --git a/autoconf/ast_ext_tool_check.m4 b/autoconf/ast_ext_tool_check.m4
index 758720d..ef762eb 100644
--- a/autoconf/ast_ext_tool_check.m4
+++ b/autoconf/ast_ext_tool_check.m4
@@ -10,15 +10,13 @@
 		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_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/configure b/configure
index 63a3716..d07fee7 100755
--- a/configure
+++ b/configure
@@ -14506,16 +14506,13 @@
 fi
 
 		if test ! "x${CONFIG_LIBXML2}" = xNo; then
-			if test x"" = x ; then A=--cflags ; else A="" ; fi
-			LIBXML2_INCLUDE=$(${CONFIG_LIBXML2} $A)
+			LIBXML2_INCLUDE=$(${CONFIG_LIBXML2} --cflags)
 			LIBXML2_INCLUDE=$(echo ${LIBXML2_INCLUDE} | $SED -e "s|-I|-I${LIBXML2_DIR}|g")
 
-			if test x"" = x ; then A=--libs ; else A="" ; fi
-			LIBXML2_LIB=$(${CONFIG_LIBXML2} $A)
+			LIBXML2_LIB=$(${CONFIG_LIBXML2} --libs)
 			LIBXML2_LIB=$(echo ${LIBXML2_LIB} | $SED -e "s|-L|-L${LIBXML2_DIR}|g")
 
-			if test x"#include <libxml/tree.h>
-        #include <libxml/parser.h>" != x ; then
+
 				saved_cppflags="${CPPFLAGS}"
 				CPPFLAGS="${CPPFLAGS} ${LIBXML2_INCLUDE}"
 
@@ -14543,12 +14540,7 @@
     conftest$ac_exeext conftest.$ac_ext
 				CPPFLAGS="${saved_cppflags}"
 				LIBS="${saved_libs}"
-			else
-				PBX_LIBXML2=1
 
-$as_echo "#define HAVE_LIBXML2 1" >>confdefs.h
-
-			fi
 		fi
 	fi
 
@@ -23609,47 +23601,18 @@
 fi
 
 		if test ! "x${CONFIG_MYSQLCLIENT}" = xNo; then
-			if test x"" = x ; then A=--cflags ; else A="" ; fi
-			MYSQLCLIENT_INCLUDE=$(${CONFIG_MYSQLCLIENT} $A)
+			MYSQLCLIENT_INCLUDE=$(${CONFIG_MYSQLCLIENT} --cflags)
 			MYSQLCLIENT_INCLUDE=$(echo ${MYSQLCLIENT_INCLUDE} | $SED -e "s|-I|-I${MYSQLCLIENT_DIR}|g")
 
-			if test x"" = x ; then A=--libs ; else A="" ; fi
-			MYSQLCLIENT_LIB=$(${CONFIG_MYSQLCLIENT} $A)
+			MYSQLCLIENT_LIB=$(${CONFIG_MYSQLCLIENT} --libs)
 			MYSQLCLIENT_LIB=$(echo ${MYSQLCLIENT_LIB} | $SED -e "s|-L|-L${MYSQLCLIENT_DIR}|g")
 
-			if test x"" != x ; then
-				saved_cppflags="${CPPFLAGS}"
-				CPPFLAGS="${CPPFLAGS} ${MYSQLCLIENT_INCLUDE}"
 
-				saved_libs="${LIBS}"
-				LIBS=${MYSQLCLIENT_LIB}
-
-				cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
- ;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-   PBX_MYSQLCLIENT=1
-$as_echo "#define HAVE_MYSQLCLIENT 1" >>confdefs.h
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-				CPPFLAGS="${saved_cppflags}"
-				LIBS="${saved_libs}"
-			else
 				PBX_MYSQLCLIENT=1
 
 $as_echo "#define HAVE_MYSQLCLIENT 1" >>confdefs.h
 
-			fi
+
 		fi
 	fi
 
@@ -23855,47 +23818,18 @@
 fi
 
 		if test ! "x${CONFIG_NEON}" = xNo; then
-			if test x"" = x ; then A=--cflags ; else A="" ; fi
-			NEON_INCLUDE=$(${CONFIG_NEON} $A)
+			NEON_INCLUDE=$(${CONFIG_NEON} --cflags)
 			NEON_INCLUDE=$(echo ${NEON_INCLUDE} | $SED -e "s|-I|-I${NEON_DIR}|g")
 
-			if test x"" = x ; then A=--libs ; else A="" ; fi
-			NEON_LIB=$(${CONFIG_NEON} $A)
+			NEON_LIB=$(${CONFIG_NEON} --libs)
 			NEON_LIB=$(echo ${NEON_LIB} | $SED -e "s|-L|-L${NEON_DIR}|g")
 
-			if test x"" != x ; then
-				saved_cppflags="${CPPFLAGS}"
-				CPPFLAGS="${CPPFLAGS} ${NEON_INCLUDE}"
 
-				saved_libs="${LIBS}"
-				LIBS=${NEON_LIB}
-
-				cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
- ;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-   PBX_NEON=1
-$as_echo "#define HAVE_NEON 1" >>confdefs.h
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-				CPPFLAGS="${saved_cppflags}"
-				LIBS="${saved_libs}"
-			else
 				PBX_NEON=1
 
 $as_echo "#define HAVE_NEON 1" >>confdefs.h
 
-			fi
+
 		fi
 	fi
 
@@ -24004,15 +23938,13 @@
 fi
 
 		if test ! "x${CONFIG_NEON29}" = xNo; then
-			if test x"" = x ; then A=--cflags ; else A="" ; fi
-			NEON29_INCLUDE=$(${CONFIG_NEON29} $A)
+			NEON29_INCLUDE=$(${CONFIG_NEON29} --cflags)
 			NEON29_INCLUDE=$(echo ${NEON29_INCLUDE} | $SED -e "s|-I|-I${NEON29_DIR}|g")
 
-			if test x"--libs" = x ; then A=--libs ; else A="--libs" ; fi
-			NEON29_LIB=$(${CONFIG_NEON29} $A)
+			NEON29_LIB=$(${CONFIG_NEON29} --libs)
 			NEON29_LIB=$(echo ${NEON29_LIB} | $SED -e "s|-L|-L${NEON29_DIR}|g")
 
-			if test x"#include <ne_auth.h>" != x ; then
+
 				saved_cppflags="${CPPFLAGS}"
 				CPPFLAGS="${CPPFLAGS} ${NEON29_INCLUDE}"
 
@@ -24041,12 +23973,7 @@
     conftest$ac_exeext conftest.$ac_ext
 				CPPFLAGS="${saved_cppflags}"
 				LIBS="${saved_libs}"
-			else
-				PBX_NEON29=1
 
-$as_echo "#define HAVE_NEON29 1" >>confdefs.h
-
-			fi
 		fi
 	fi
 
@@ -24155,17 +24082,13 @@
 fi
 
 		if test ! "x${CONFIG_NETSNMP}" = xNo; then
-			if test x"" = x ; then A=--cflags ; else A="" ; fi
-			NETSNMP_INCLUDE=$(${CONFIG_NETSNMP} $A)
+			NETSNMP_INCLUDE=$(${CONFIG_NETSNMP} --cflags)
 			NETSNMP_INCLUDE=$(echo ${NETSNMP_INCLUDE} | $SED -e "s|-I|-I${NETSNMP_DIR}|g")
 
-			if test x"--agent-libs" = x ; then A=--libs ; else A="--agent-libs" ; fi
-			NETSNMP_LIB=$(${CONFIG_NETSNMP} $A)
+			NETSNMP_LIB=$(${CONFIG_NETSNMP} --agent-libs)
 			NETSNMP_LIB=$(echo ${NETSNMP_LIB} | $SED -e "s|-L|-L${NETSNMP_DIR}|g")
 
-			if test x"#include <net-snmp/net-snmp-config.h>
-#include <net-snmp/net-snmp-includes.h>
-#include <net-snmp/agent/net-snmp-agent-includes.h>" != x ; then
+
 				saved_cppflags="${CPPFLAGS}"
 				CPPFLAGS="${CPPFLAGS} ${NETSNMP_INCLUDE}"
 
@@ -24194,12 +24117,7 @@
     conftest$ac_exeext conftest.$ac_ext
 				CPPFLAGS="${saved_cppflags}"
 				LIBS="${saved_libs}"
-			else
-				PBX_NETSNMP=1
 
-$as_echo "#define HAVE_NETSNMP 1" >>confdefs.h
-
-			fi
 		fi
 	fi
 
@@ -35038,47 +34956,18 @@
 fi
 
 		if test ! "x${CONFIG_SDL}" = xNo; then
-			if test x"" = x ; then A=--cflags ; else A="" ; fi
-			SDL_INCLUDE=$(${CONFIG_SDL} $A)
+			SDL_INCLUDE=$(${CONFIG_SDL} --cflags)
 			SDL_INCLUDE=$(echo ${SDL_INCLUDE} | $SED -e "s|-I|-I${SDL_DIR}|g")
 
-			if test x"" = x ; then A=--libs ; else A="" ; fi
-			SDL_LIB=$(${CONFIG_SDL} $A)
+			SDL_LIB=$(${CONFIG_SDL} --libs)
 			SDL_LIB=$(echo ${SDL_LIB} | $SED -e "s|-L|-L${SDL_DIR}|g")
 
-			if test x"" != x ; then
-				saved_cppflags="${CPPFLAGS}"
-				CPPFLAGS="${CPPFLAGS} ${SDL_INCLUDE}"
 
-				saved_libs="${LIBS}"
-				LIBS=${SDL_LIB}
-
-				cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
- ;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-   PBX_SDL=1
-$as_echo "#define HAVE_SDL 1" >>confdefs.h
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-				CPPFLAGS="${saved_cppflags}"
-				LIBS="${saved_libs}"
-			else
 				PBX_SDL=1
 
 $as_echo "#define HAVE_SDL 1" >>confdefs.h
 
-			fi
+
 		fi
 	fi
 
diff --git a/menuselect/configure b/menuselect/configure
index ddd3af8..6e5331e 100755
--- a/menuselect/configure
+++ b/menuselect/configure
@@ -4391,16 +4391,13 @@
 fi
 
 		if test ! "x${CONFIG_LIBXML2}" = xNo; then
-			if test x"" = x ; then A=--cflags ; else A="" ; fi
-			LIBXML2_INCLUDE=$(${CONFIG_LIBXML2} $A)
+			LIBXML2_INCLUDE=$(${CONFIG_LIBXML2} --cflags)
 			LIBXML2_INCLUDE=$(echo ${LIBXML2_INCLUDE} | $SED -e "s|-I|-I${LIBXML2_DIR}|g")
 
-			if test x"" = x ; then A=--libs ; else A="" ; fi
-			LIBXML2_LIB=$(${CONFIG_LIBXML2} $A)
+			LIBXML2_LIB=$(${CONFIG_LIBXML2} --libs)
 			LIBXML2_LIB=$(echo ${LIBXML2_LIB} | $SED -e "s|-L|-L${LIBXML2_DIR}|g")
 
-			if test x"#include <libxml/tree.h>
-        #include <libxml/parser.h>" != x ; then
+
 				saved_cppflags="${CPPFLAGS}"
 				CPPFLAGS="${CPPFLAGS} ${LIBXML2_INCLUDE}"
 
@@ -4428,12 +4425,7 @@
     conftest$ac_exeext conftest.$ac_ext
 				CPPFLAGS="${saved_cppflags}"
 				LIBS="${saved_libs}"
-			else
-				PBX_LIBXML2=1
 
-$as_echo "#define HAVE_LIBXML2 1" >>confdefs.h
-
-			fi
 		fi
 	fi
 

-- 
To view, visit https://gerrit.asterisk.org/7377
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaed407519103c20501352d3f8b9d86d4f44c16a2
Gerrit-Change-Number: 7377
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171127/c5826cd6/attachment-0001.html>


More information about the asterisk-code-review mailing list