Skip to content

Commit 47b90e9

Browse files
committed
Merge branch 'PHP-7.2'
* PHP-7.2: Fixes bug #75871 Use pkg-config for libxml2 if available
2 parents 812303a + f9a16d4 commit 47b90e9

File tree

11 files changed

+64
-37
lines changed

11 files changed

+64
-37
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ PHP NEWS
7979
. Added full support for sending and parsing ldap controls (Come)
8080
. Fixed bug #49876 (Fix LDAP path lookup on 64-bit distros). (dzuelke)
8181

82+
- libxml2:
83+
. Fixed bug #75871 (use pkg-config where available). (pmmaga)
8284

8385
- litespeed:
8486
. Fixed bug #75248 (Binary directory doesn't get created when building

acinclude.m4

+53-28
Original file line numberDiff line numberDiff line change
@@ -2523,15 +2523,18 @@ dnl
25232523
dnl Common setup macro for libxml
25242524
dnl
25252525
AC_DEFUN([PHP_SETUP_LIBXML], [
2526-
AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
2527-
[
2528-
for i in $PHP_LIBXML_DIR /usr/local /usr; do
2529-
if test -x "$i/bin/xml2-config"; then
2530-
ac_cv_php_xml2_config_path="$i/bin/xml2-config"
2531-
break
2532-
fi
2533-
done
2534-
])
2526+
found_libxml=no
2527+
2528+
dnl First try to find xml2-config
2529+
AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
2530+
[
2531+
for i in $PHP_LIBXML_DIR /usr/local /usr; do
2532+
if test -x "$i/bin/xml2-config"; then
2533+
ac_cv_php_xml2_config_path="$i/bin/xml2-config"
2534+
break
2535+
fi
2536+
done
2537+
])
25352538
25362539
if test -x "$ac_cv_php_xml2_config_path"; then
25372540
XML2_CONFIG="$ac_cv_php_xml2_config_path"
@@ -2542,30 +2545,52 @@ AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
25422545
IFS=$ac_IFS
25432546
LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
25442547
if test "$LIBXML_VERSION" -ge "2006011"; then
2548+
found_libxml=yes
25452549
LIBXML_LIBS=`$XML2_CONFIG --libs`
25462550
LIBXML_INCS=`$XML2_CONFIG --cflags`
2547-
PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
2548-
PHP_EVAL_INCLINE($LIBXML_INCS)
2549-
2550-
dnl Check that build works with given libs
2551-
AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
2552-
PHP_TEST_BUILD(xmlInitParser,
2553-
[
2554-
php_cv_libxml_build_works=yes
2555-
], [
2556-
AC_MSG_RESULT(no)
2557-
AC_MSG_ERROR([build test failed. Please check the config.log for details.])
2558-
], [
2559-
[$]$1
2560-
])
2561-
])
2562-
if test "$php_cv_libxml_build_works" = "yes"; then
2563-
AC_DEFINE(HAVE_LIBXML, 1, [ ])
2564-
fi
2565-
$2
25662551
else
25672552
AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
25682553
fi
2554+
fi
2555+
2556+
dnl If xml2-config fails, try pkg-config
2557+
if test "$found_libxml" = "no"; then
2558+
if test -z "$PKG_CONFIG"; then
2559+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2560+
fi
2561+
2562+
dnl If pkg-config is found try using it
2563+
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libxml-2.0; then
2564+
if $PKG_CONFIG --atleast-version=2.6.11 libxml-2.0; then
2565+
found_libxml=yes
2566+
LIBXML_LIBS=`$PKG_CONFIG --libs libxml-2.0`
2567+
LIBXML_INCS=`$PKG_CONFIG --cflags-only-I libxml-2.0`
2568+
else
2569+
AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
2570+
fi
2571+
fi
2572+
fi
2573+
2574+
if test "$found_libxml" = "yes"; then
2575+
PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
2576+
PHP_EVAL_INCLINE($LIBXML_INCS)
2577+
2578+
dnl Check that build works with given libs
2579+
AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
2580+
PHP_TEST_BUILD(xmlInitParser,
2581+
[
2582+
php_cv_libxml_build_works=yes
2583+
], [
2584+
AC_MSG_RESULT(no)
2585+
AC_MSG_ERROR([build test failed. Please check the config.log for details.])
2586+
], [
2587+
[$]$1
2588+
])
2589+
])
2590+
if test "$php_cv_libxml_build_works" = "yes"; then
2591+
AC_DEFINE(HAVE_LIBXML, 1, [ ])
2592+
fi
2593+
$2
25692594
ifelse([$3],[],,[else $3])
25702595
fi
25712596
])

ext/dom/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ if test "$PHP_DOM" != "no"; then
3333
PHP_INSTALL_HEADERS([ext/dom/xml_common.h])
3434
PHP_ADD_EXTENSION_DEP(dom, libxml)
3535
], [
36-
AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
36+
AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
3737
])
3838
fi

ext/libxml/config0.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ if test "$PHP_LIBXML" != "no"; then
2020
PHP_NEW_EXTENSION(libxml, [libxml.c], $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
2121
PHP_INSTALL_HEADERS([ext/libxml/php_libxml.h])
2222
], [
23-
AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
23+
AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
2424
])
2525
fi

ext/simplexml/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if test "$PHP_SIMPLEXML" != "no"; then
2121
PHP_INSTALL_HEADERS([ext/simplexml/php_simplexml.h ext/simplexml/php_simplexml_exports.h])
2222
PHP_SUBST(SIMPLEXML_SHARED_LIBADD)
2323
], [
24-
AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
24+
AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
2525
])
2626
PHP_ADD_EXTENSION_DEP(simplexml, libxml)
2727
PHP_ADD_EXTENSION_DEP(simplexml, spl, true)

ext/soap/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ if test "$PHP_SOAP" != "no"; then
2020
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)
2121
PHP_SUBST(SOAP_SHARED_LIBADD)
2222
], [
23-
AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
23+
AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
2424
])
2525
fi

ext/wddx/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if test "$PHP_WDDX" != "no"; then
2929
PHP_ADD_BUILD_DIR(ext/xml)
3030
fi
3131
], [
32-
AC_MSG_ERROR([xml2-config not found. Use --with-libxml-dir=<DIR>])
32+
AC_MSG_ERROR([libxml2 not found. Use --with-libxml-dir=<DIR>])
3333
])
3434
fi
3535

ext/xml/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if test "$PHP_XML" != "no"; then
2828
xml_extra_sources="compat.c"
2929
PHP_ADD_EXTENSION_DEP(xml, libxml)
3030
], [
31-
AC_MSG_ERROR([xml2-config not found. Use --with-libxml-dir=<DIR>])
31+
AC_MSG_ERROR([libxml2 not found. Use --with-libxml-dir=<DIR>])
3232
])
3333
fi
3434

ext/xmlreader/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ if test "$PHP_XMLREADER" != "no"; then
2222
PHP_ADD_EXTENSION_DEP(xmlreader, dom, true)
2323
PHP_SUBST(XMLREADER_SHARED_LIBADD)
2424
], [
25-
AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
25+
AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
2626
])
2727
fi

ext/xmlrpc/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if test "$PHP_XMLRPC" != "no"; then
4242
PHP_ADD_BUILD_DIR(ext/xml)
4343
fi
4444
], [
45-
AC_MSG_ERROR([xml2-config not found. Use --with-libxml-dir=<DIR>])
45+
AC_MSG_ERROR([libxml2 not found. Use --with-libxml-dir=<DIR>])
4646
])
4747
else
4848
testval=no

ext/xmlwriter/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ if test "$PHP_XMLWRITER" != "no"; then
2121
PHP_NEW_EXTENSION(xmlwriter, php_xmlwriter.c, $ext_shared)
2222
PHP_SUBST(XMLWRITER_SHARED_LIBADD)
2323
], [
24-
AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
24+
AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.])
2525
])
2626
fi

0 commit comments

Comments
 (0)