From 3f64ca0c04f3b0482125d99c6b9566a406af48ed Mon Sep 17 00:00:00 2001
From: Matthew Jordan <mjordan@digium.com>
Date: Thu, 17 Jul 2014 19:31:05 +0000
Subject: [PATCH] configure: Fix libxml2 development library dependency
 checking

The commit that added libxml2 support didn't fully check for the libxml2
development script in the Asterisk configure file. As a result, Asterisk could
be configured, then fail on menuselect. This patch fixes it so that Asterisk
should detect the libxml2 dependency failure first.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418850 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 UPGRADE.txt             |   3 +-
 configure               | 261 ++++++++++++++++++++--------------------
 configure.ac            |  15 +--
 menuselect/configure    |   4 +-
 menuselect/configure.ac |   2 +-
 5 files changed, 144 insertions(+), 141 deletions(-)

diff --git a/UPGRADE.txt b/UPGRADE.txt
index ed52017c73..d25bf55d82 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -24,7 +24,8 @@
 From 12 to 13:
 
  - The menuselect utility has been pulled into the Asterisk repository. As a
-   result, the libxml2 library is now a required dependency for Asterisk.
+   result, the libxml2 development library is now a required dependency for
+   Asterisk.
 
  - The asterisk command line -I option and the asterisk.conf internal_timing
    option are removed and always enabled if any timing module is loaded.
diff --git a/configure b/configure
index 97fa53b829..1290e1d319 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 418035 .
+# From configure.ac Revision: 418834 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.68 for asterisk trunk.
 #
@@ -12646,133 +12646,6 @@ if test "x$JANSSON_LIB" == "x"; then
   as_fn_error $? "*** JSON support not found (this typically means the libjansson development package is missing)" "$LINENO" 5
 fi
 
-if test "x$PBX_LIBXML2" == "x"; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: *** Asterisk requires the 'libxml2' development package." >&5
-$as_echo "$as_me: *** Asterisk requires the 'libxml2' development package." >&6;}
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: *** Please install the 'libxml2' development package." >&5
-$as_echo "$as_me: *** Please install the 'libxml2' development package." >&6;}
-	exit 1
-fi
-
-
-if test "x${PBX_URIPARSER}" != "x1" -a "${USE_URIPARSER}" != "no"; then
-   pbxlibdir=""
-   # if --with-URIPARSER=DIR has been specified, use it.
-   if test "x${URIPARSER_DIR}" != "x"; then
-      if test -d ${URIPARSER_DIR}/lib; then
-         pbxlibdir="-L${URIPARSER_DIR}/lib"
-      else
-         pbxlibdir="-L${URIPARSER_DIR}"
-      fi
-   fi
-   pbxfuncname="uriParseUriA"
-   if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
-      AST_URIPARSER_FOUND=yes
-   else
-      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
-      CFLAGS="${CFLAGS} "
-      as_ac_Lib=`$as_echo "ac_cv_lib_uriparser_${pbxfuncname}" | $as_tr_sh`
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -luriparser" >&5
-$as_echo_n "checking for ${pbxfuncname} in -luriparser... " >&6; }
-if eval \${$as_ac_Lib+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-luriparser ${pbxlibdir}  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char ${pbxfuncname} ();
-int
-main ()
-{
-return ${pbxfuncname} ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  eval "$as_ac_Lib=yes"
-else
-  eval "$as_ac_Lib=no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-eval ac_res=\$$as_ac_Lib
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
-  AST_URIPARSER_FOUND=yes
-else
-  AST_URIPARSER_FOUND=no
-fi
-
-      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
-   fi
-
-   # now check for the header.
-   if test "${AST_URIPARSER_FOUND}" = "yes"; then
-      URIPARSER_LIB="${pbxlibdir} -luriparser "
-      # if --with-URIPARSER=DIR has been specified, use it.
-      if test "x${URIPARSER_DIR}" != "x"; then
-         URIPARSER_INCLUDE="-I${URIPARSER_DIR}/include"
-      fi
-      URIPARSER_INCLUDE="${URIPARSER_INCLUDE} "
-      if test "xuriparser/Uri.h" = "x" ; then	# no header, assume found
-         URIPARSER_HEADER_FOUND="1"
-      else				# check for the header
-         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${URIPARSER_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "uriparser/Uri.h" "ac_cv_header_uriparser_Uri_h" "$ac_includes_default"
-if test "x$ac_cv_header_uriparser_Uri_h" = xyes; then :
-  URIPARSER_HEADER_FOUND=1
-else
-  URIPARSER_HEADER_FOUND=0
-fi
-
-
-         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
-      fi
-      if test "x${URIPARSER_HEADER_FOUND}" = "x0" ; then
-         URIPARSER_LIB=""
-         URIPARSER_INCLUDE=""
-      else
-         if test "x${pbxfuncname}" = "x" ; then		# only checking headers -> no library
-            URIPARSER_LIB=""
-         fi
-         PBX_URIPARSER=1
-         cat >>confdefs.h <<_ACEOF
-#define HAVE_URIPARSER 1
-_ACEOF
-
-      fi
-   fi
-fi
-
-
-
-# Another mandatory item (unless it's explicitly disabled)
-# Check whether --enable-xmldoc was given.
-if test "${enable_xmldoc+set}" = set; then :
-  enableval=$enable_xmldoc; case "${enableval}" in
-		y|ye|yes) disable_xmldoc=no ;;
-		n|no)  disable_xmldoc=yes ;;
-		*) as_fn_error $? "bad value ${enableval} for --disable-xmldoc" "$LINENO" 5  ;;
-	esac
-else
-  disable_xmldoc=no
-fi
-
-
-if test "${disable_xmldoc}" != "yes"; then
 
 	if test "x${PBX_LIBXML2}" != "x1" -a "${USE_LIBXML2}" != "no"; then
 		PBX_LIBXML2=0
@@ -12886,7 +12759,7 @@ fi
 			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
+        #include <libxml/parser.h>" != x ; then
 				saved_cppflags="${CPPFLAGS}"
 				CPPFLAGS="${CPPFLAGS} ${LIBXML2_INCLUDE}"
 
@@ -12896,7 +12769,7 @@ fi
 				cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
   #include <libxml/tree.h>
-	#include <libxml/parser.h>
+        #include <libxml/parser.h>
 int
 main ()
 {
@@ -12924,6 +12797,134 @@ $as_echo "#define HAVE_LIBXML2 1" >>confdefs.h
 	fi
 
 
+if test "${PBX_LIBXML2}" != 1; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: *** The Asterisk menuselect tool requires the 'libxml2' development package." >&5
+$as_echo "$as_me: *** The Asterisk menuselect tool requires the 'libxml2' development package." >&6;}
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: *** Please install the 'libxml2' development package." >&5
+$as_echo "$as_me: *** Please install the 'libxml2' development package." >&6;}
+	exit 1
+fi
+
+
+if test "x${PBX_URIPARSER}" != "x1" -a "${USE_URIPARSER}" != "no"; then
+   pbxlibdir=""
+   # if --with-URIPARSER=DIR has been specified, use it.
+   if test "x${URIPARSER_DIR}" != "x"; then
+      if test -d ${URIPARSER_DIR}/lib; then
+         pbxlibdir="-L${URIPARSER_DIR}/lib"
+      else
+         pbxlibdir="-L${URIPARSER_DIR}"
+      fi
+   fi
+   pbxfuncname="uriParseUriA"
+   if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
+      AST_URIPARSER_FOUND=yes
+   else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} "
+      as_ac_Lib=`$as_echo "ac_cv_lib_uriparser_${pbxfuncname}" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -luriparser" >&5
+$as_echo_n "checking for ${pbxfuncname} in -luriparser... " >&6; }
+if eval \${$as_ac_Lib+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-luriparser ${pbxlibdir}  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ${pbxfuncname} ();
+int
+main ()
+{
+return ${pbxfuncname} ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$as_ac_Lib=yes"
+else
+  eval "$as_ac_Lib=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+eval ac_res=\$$as_ac_Lib
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
+  AST_URIPARSER_FOUND=yes
+else
+  AST_URIPARSER_FOUND=no
+fi
+
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
+   fi
+
+   # now check for the header.
+   if test "${AST_URIPARSER_FOUND}" = "yes"; then
+      URIPARSER_LIB="${pbxlibdir} -luriparser "
+      # if --with-URIPARSER=DIR has been specified, use it.
+      if test "x${URIPARSER_DIR}" != "x"; then
+         URIPARSER_INCLUDE="-I${URIPARSER_DIR}/include"
+      fi
+      URIPARSER_INCLUDE="${URIPARSER_INCLUDE} "
+      if test "xuriparser/Uri.h" = "x" ; then	# no header, assume found
+         URIPARSER_HEADER_FOUND="1"
+      else				# check for the header
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+         CPPFLAGS="${CPPFLAGS} ${URIPARSER_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "uriparser/Uri.h" "ac_cv_header_uriparser_Uri_h" "$ac_includes_default"
+if test "x$ac_cv_header_uriparser_Uri_h" = xyes; then :
+  URIPARSER_HEADER_FOUND=1
+else
+  URIPARSER_HEADER_FOUND=0
+fi
+
+
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
+      fi
+      if test "x${URIPARSER_HEADER_FOUND}" = "x0" ; then
+         URIPARSER_LIB=""
+         URIPARSER_INCLUDE=""
+      else
+         if test "x${pbxfuncname}" = "x" ; then		# only checking headers -> no library
+            URIPARSER_LIB=""
+         fi
+         PBX_URIPARSER=1
+         cat >>confdefs.h <<_ACEOF
+#define HAVE_URIPARSER 1
+_ACEOF
+
+      fi
+   fi
+fi
+
+
+
+# Another mandatory item (unless it's explicitly disabled)
+# Check whether --enable-xmldoc was given.
+if test "${enable_xmldoc+set}" = set; then :
+  enableval=$enable_xmldoc; case "${enableval}" in
+		y|ye|yes) disable_xmldoc=no ;;
+		n|no)  disable_xmldoc=yes ;;
+		*) as_fn_error $? "bad value ${enableval} for --disable-xmldoc" "$LINENO" 5  ;;
+	esac
+else
+  disable_xmldoc=no
+fi
+
+
+if test "${disable_xmldoc}" != "yes"; then
+
 if test "x${PBX_LIBXSLT}" != "x1" -a "${USE_LIBXSLT}" != "no"; then
    pbxlibdir=""
    # if --with-LIBXSLT=DIR has been specified, use it.
diff --git a/configure.ac b/configure.ac
index 017f0d7c9b..0042dbf089 100644
--- a/configure.ac
+++ b/configure.ac
@@ -550,9 +550,14 @@ if test "x$JANSSON_LIB" == "x"; then
   AC_MSG_ERROR([*** JSON support not found (this typically means the libjansson development package is missing)])
 fi
 
-if test "x$PBX_LIBXML2" == "x"; then
-	AC_MSG_NOTICE(*** The Asterisk menuselect tool requires the 'libxml2' package.)
-	AC_MSG_NOTICE(*** Please install the 'libxml2' package.)
+AST_EXT_TOOL_CHECK([LIBXML2], [xml2-config], , ,
+        [#include <libxml/tree.h>
+        #include <libxml/parser.h>],
+        [LIBXML_TEST_VERSION])
+
+if test "${PBX_LIBXML2}" != 1; then
+	AC_MSG_NOTICE(*** The Asterisk menuselect tool requires the 'libxml2' development package.)
+	AC_MSG_NOTICE(*** Please install the 'libxml2' development package.)
 	exit 1
 fi
 
@@ -569,10 +574,6 @@ AC_ARG_ENABLE([xmldoc],
 	esac], [disable_xmldoc=no])
 
 if test "${disable_xmldoc}" != "yes"; then
-	AST_EXT_TOOL_CHECK([LIBXML2], [xml2-config], , ,
-	[#include <libxml/tree.h>
-	#include <libxml/parser.h>],
-	[LIBXML_TEST_VERSION])
         AST_EXT_LIB_CHECK([LIBXSLT], [xslt], [xsltLoadStylesheetPI], [libxslt/xsltInternals.h], [${LIBXML2_LIB}], [${LIBXML2_INCLUDE}])
         AST_EXT_LIB_CHECK([LIBXSLT_CLEANUP], [xslt], [xsltCleanupGlobals], [libxslt/xsltInternals.h], [${LIBXML2_LIB}], [${LIBXML2_INCLUDE}])
 
diff --git a/menuselect/configure b/menuselect/configure
index 4316ccf5fb..eded6ab93c 100755
--- a/menuselect/configure
+++ b/menuselect/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 418832 .
+# From configure.ac Revision: 418834 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.68.
 #
@@ -4685,7 +4685,7 @@ $as_echo "#define HAVE_LIBXML2 1" >>confdefs.h
 
 
 if test "${PBX_LIBXML2}" != 1; then
-  as_fn_error $? "coult not find required 'Libxml2' development package" "$LINENO" 5
+  as_fn_error $? "Could not find required 'Libxml2' development package" "$LINENO" 5
 fi
 
 PBX_GTK2=0
diff --git a/menuselect/configure.ac b/menuselect/configure.ac
index 516d19eb5a..5989f5cd38 100644
--- a/menuselect/configure.ac
+++ b/menuselect/configure.ac
@@ -131,7 +131,7 @@ AST_EXT_TOOL_CHECK([LIBXML2], [xml2-config], , ,
         [LIBXML_TEST_VERSION])
 
 if test "${PBX_LIBXML2}" != 1; then
-  AC_MSG_ERROR([coult not find required 'Libxml2' development package])
+  AC_MSG_ERROR([Could not find required 'Libxml2' development package])
 fi
 
 PBX_GTK2=0
-- 
GitLab