]> granicus.if.org Git - php/commitdiff
Fixes bug #75871 Use pkg-config for libxml2 if available
authorPedro Magalhães <mail@pmmaga.net>
Tue, 6 Feb 2018 19:16:22 +0000 (19:16 +0000)
committerJoe <krakjoe@php.net>
Thu, 8 Feb 2018 09:50:22 +0000 (10:50 +0100)
NEWS
acinclude.m4
ext/dom/config.m4
ext/libxml/config0.m4
ext/simplexml/config.m4
ext/soap/config.m4
ext/wddx/config.m4
ext/xml/config.m4
ext/xmlreader/config.m4
ext/xmlrpc/config.m4
ext/xmlwriter/config.m4

diff --git a/NEWS b/NEWS
index 4716446bf8923fbe441a2898afb3f718bebacc50..3561319f4d1c2cce82b9ffffc7f2f94df0b7460d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,9 @@ PHP                                                                        NEWS
 - LDAP:
   . Fixed bug #49876 (Fix LDAP path lookup on 64-bit distros). (dzuelke)
 
+- libxml2:
+  . Fixed bug #75871 (use pkg-config where available). (pmmaga)
+
 - Phar:
   . Fixed bug #65414 (deal with leading slash when adding files correctly).
     (bishopb)
index 151722d951c36b86916de5de15ac47af5317104d..0e6fb5de855c1fc71c665535e13916c53932156d 100644 (file)
@@ -2534,15 +2534,18 @@ dnl
 dnl Common setup macro for libxml
 dnl
 AC_DEFUN([PHP_SETUP_LIBXML], [
-AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
-[
-  for i in $PHP_LIBXML_DIR /usr/local /usr; do
-    if test -x "$i/bin/xml2-config"; then
-      ac_cv_php_xml2_config_path="$i/bin/xml2-config"
-      break
-    fi
-  done
-])
+  found_libxml=no
+
+  dnl First try to find xml2-config
+  AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
+  [
+    for i in $PHP_LIBXML_DIR /usr/local /usr; do
+      if test -x "$i/bin/xml2-config"; then
+        ac_cv_php_xml2_config_path="$i/bin/xml2-config"
+        break
+      fi
+    done
+  ])
 
   if test -x "$ac_cv_php_xml2_config_path"; then
     XML2_CONFIG="$ac_cv_php_xml2_config_path"
@@ -2553,30 +2556,52 @@ AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
     IFS=$ac_IFS
     LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
     if test "$LIBXML_VERSION" -ge "2006011"; then
+      found_libxml=yes
       LIBXML_LIBS=`$XML2_CONFIG --libs`
       LIBXML_INCS=`$XML2_CONFIG --cflags`
-      PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
-      PHP_EVAL_INCLINE($LIBXML_INCS)
-
-      dnl Check that build works with given libs
-      AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
-        PHP_TEST_BUILD(xmlInitParser,
-        [
-          php_cv_libxml_build_works=yes
-        ], [
-          AC_MSG_RESULT(no)
-          AC_MSG_ERROR([build test failed.  Please check the config.log for details.])
-        ], [
-          [$]$1
-        ])
-      ])
-      if test "$php_cv_libxml_build_works" = "yes"; then
-        AC_DEFINE(HAVE_LIBXML, 1, [ ])
-      fi
-      $2
     else
       AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
     fi
+  fi
+
+  dnl If xml2-config fails, try pkg-config
+  if test "$found_libxml" = "no"; then
+    if test -z "$PKG_CONFIG"; then
+      AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+    fi
+
+    dnl If pkg-config is found try using it
+    if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libxml-2.0; then
+      if $PKG_CONFIG --atleast-version=2.6.11 libxml-2.0; then
+        found_libxml=yes
+        LIBXML_LIBS=`$PKG_CONFIG --libs libxml-2.0`
+        LIBXML_INCS=`$PKG_CONFIG --cflags-only-I libxml-2.0`
+      else
+        AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
+      fi
+    fi
+  fi
+
+  if test "$found_libxml" = "yes"; then
+    PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
+    PHP_EVAL_INCLINE($LIBXML_INCS)
+
+    dnl Check that build works with given libs
+    AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
+      PHP_TEST_BUILD(xmlInitParser,
+      [
+        php_cv_libxml_build_works=yes
+      ], [
+        AC_MSG_RESULT(no)
+        AC_MSG_ERROR([build test failed.  Please check the config.log for details.])
+      ], [
+        [$]$1
+      ])
+    ])
+    if test "$php_cv_libxml_build_works" = "yes"; then
+      AC_DEFINE(HAVE_LIBXML, 1, [ ])
+    fi
+    $2
 ifelse([$3],[],,[else $3])
   fi
 ])
index 7882483b305e4699cd1c3f8167908ecd2b79c0f8..5ea62ad24cf7ecd5001e1cf99e637060fe385343 100644 (file)
@@ -33,6 +33,6 @@ if test "$PHP_DOM" != "no"; then
     PHP_INSTALL_HEADERS([ext/dom/xml_common.h])
     PHP_ADD_EXTENSION_DEP(dom, libxml)
   ], [
-    AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
+    AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
   ])
 fi
index 79e94a40ad8765398a6466fed6cf7ca9e102bf5f..5d44c77846e14551324bcd8400c685402408e63e 100644 (file)
@@ -20,6 +20,6 @@ if test "$PHP_LIBXML" != "no"; then
     PHP_NEW_EXTENSION(libxml, [libxml.c], $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
     PHP_INSTALL_HEADERS([ext/libxml/php_libxml.h])
   ], [
-    AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
+    AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
   ])
 fi
index b06f5b00f0494139af179781c0573290c03b7c74..ec1b2b2cc5f2830e8c33ada02fbdf9e0d3a128ec 100644 (file)
@@ -21,7 +21,7 @@ if test "$PHP_SIMPLEXML" != "no"; then
     PHP_INSTALL_HEADERS([ext/simplexml/php_simplexml.h ext/simplexml/php_simplexml_exports.h])
     PHP_SUBST(SIMPLEXML_SHARED_LIBADD)
   ], [
-    AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
+    AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
   ])
   PHP_ADD_EXTENSION_DEP(simplexml, libxml)
   PHP_ADD_EXTENSION_DEP(simplexml, spl, true)
index 5fcb8bd44766c5ac8eb009a40576cac128a828f5..ea39dd78946a15ed80639fa742b1bb69e62f6f77 100644 (file)
@@ -20,6 +20,6 @@ if test "$PHP_SOAP" != "no"; then
     PHP_NEW_EXTENSION(soap, soap.c php_encoding.c php_http.c php_packet_soap.c php_schema.c php_sdl.c php_xml.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
     PHP_SUBST(SOAP_SHARED_LIBADD)
   ], [
-    AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
+    AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
   ])
 fi
index 8f933d490aac2431443e4616b7d2e87b2745265e..96b566e2e35978f1e0dd6274edff01a2a8a0a690 100644 (file)
@@ -29,7 +29,7 @@ if test "$PHP_WDDX" != "no"; then
         PHP_ADD_BUILD_DIR(ext/xml)
       fi
     ], [
-      AC_MSG_ERROR([xml2-config not found. Use --with-libxml-dir=<DIR>])
+      AC_MSG_ERROR([libxml2 not found. Use --with-libxml-dir=<DIR>])
     ])
   fi
 
index 812032bc6a935b099698a88b5ce39c8e44828d4d..715f65a915881f1f70eb0924400aa387a1143a50 100644 (file)
@@ -28,7 +28,7 @@ if test "$PHP_XML" != "no"; then
       xml_extra_sources="compat.c"
       PHP_ADD_EXTENSION_DEP(xml, libxml)
     ], [
-      AC_MSG_ERROR([xml2-config not found. Use --with-libxml-dir=<DIR>])
+      AC_MSG_ERROR([libxml2 not found. Use --with-libxml-dir=<DIR>])
     ])
   fi
   
index d346b58eea4fc54b471e7e998ef70261d6e37f15..4ada113a0059f6dc451f3ff56a4f454e3344791a 100644 (file)
@@ -22,6 +22,6 @@ if test "$PHP_XMLREADER" != "no"; then
     PHP_ADD_EXTENSION_DEP(xmlreader, dom, true)
     PHP_SUBST(XMLREADER_SHARED_LIBADD)
   ], [
-    AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
+    AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
   ])
 fi
index f82016edcb000aa34517ea39d276283be42bcbe7..6ed7a6312aee325facfda5591a8e212bfb7ea3f7 100644 (file)
@@ -42,7 +42,7 @@ if test "$PHP_XMLRPC" != "no"; then
         PHP_ADD_BUILD_DIR(ext/xml)
       fi
     ], [
-      AC_MSG_ERROR([xml2-config not found. Use --with-libxml-dir=<DIR>])
+      AC_MSG_ERROR([libxml2 not found. Use --with-libxml-dir=<DIR>])
     ])
   else
     testval=no
index b3b98012f8f8c99086b209f64f8efe321840f005..8261e2114ce470b0bc1eec54c7509e1bd1fb19e3 100644 (file)
@@ -21,6 +21,6 @@ if test "$PHP_XMLWRITER" != "no"; then
     PHP_NEW_EXTENSION(xmlwriter, php_xmlwriter.c, $ext_shared)
     PHP_SUBST(XMLWRITER_SHARED_LIBADD)
   ], [
-    AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
+    AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
   ])
 fi