Skip to content

Commit 5673c64

Browse files
pmmagakrakjoe
authored andcommitted
Fixes bug #75871 Use pkg-config for libxml2 if available
1 parent 8000334 commit 5673c64

File tree

11 files changed

+65
-37
lines changed

11 files changed

+65
-37
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ PHP NEWS
1515
- LDAP:
1616
. Fixed bug #49876 (Fix LDAP path lookup on 64-bit distros). (dzuelke)
1717

18+
- libxml2:
19+
. Fixed bug #75871 (use pkg-config where available). (pmmaga)
20+
1821
- Phar:
1922
. Fixed bug #65414 (deal with leading slash when adding files correctly).
2023
(bishopb)

acinclude.m4

+53-28
Original file line numberDiff line numberDiff line change
@@ -2534,15 +2534,18 @@ dnl
25342534
dnl Common setup macro for libxml
25352535
dnl
25362536
AC_DEFUN([PHP_SETUP_LIBXML], [
2537-
AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
2538-
[
2539-
for i in $PHP_LIBXML_DIR /usr/local /usr; do
2540-
if test -x "$i/bin/xml2-config"; then
2541-
ac_cv_php_xml2_config_path="$i/bin/xml2-config"
2542-
break
2543-
fi
2544-
done
2545-
])
2537+
found_libxml=no
2538+
2539+
dnl First try to find xml2-config
2540+
AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
2541+
[
2542+
for i in $PHP_LIBXML_DIR /usr/local /usr; do
2543+
if test -x "$i/bin/xml2-config"; then
2544+
ac_cv_php_xml2_config_path="$i/bin/xml2-config"
2545+
break
2546+
fi
2547+
done
2548+
])
25462549
25472550
if test -x "$ac_cv_php_xml2_config_path"; then
25482551
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,
25532556
IFS=$ac_IFS
25542557
LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
25552558
if test "$LIBXML_VERSION" -ge "2006011"; then
2559+
found_libxml=yes
25562560
LIBXML_LIBS=`$XML2_CONFIG --libs`
25572561
LIBXML_INCS=`$XML2_CONFIG --cflags`
2558-
PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
2559-
PHP_EVAL_INCLINE($LIBXML_INCS)
2560-
2561-
dnl Check that build works with given libs
2562-
AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
2563-
PHP_TEST_BUILD(xmlInitParser,
2564-
[
2565-
php_cv_libxml_build_works=yes
2566-
], [
2567-
AC_MSG_RESULT(no)
2568-
AC_MSG_ERROR([build test failed. Please check the config.log for details.])
2569-
], [
2570-
[$]$1
2571-
])
2572-
])
2573-
if test "$php_cv_libxml_build_works" = "yes"; then
2574-
AC_DEFINE(HAVE_LIBXML, 1, [ ])
2575-
fi
2576-
$2
25772562
else
25782563
AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
25792564
fi
2565+
fi
2566+
2567+
dnl If xml2-config fails, try pkg-config
2568+
if test "$found_libxml" = "no"; then
2569+
if test -z "$PKG_CONFIG"; then
2570+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2571+
fi
2572+
2573+
dnl If pkg-config is found try using it
2574+
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libxml-2.0; then
2575+
if $PKG_CONFIG --atleast-version=2.6.11 libxml-2.0; then
2576+
found_libxml=yes
2577+
LIBXML_LIBS=`$PKG_CONFIG --libs libxml-2.0`
2578+
LIBXML_INCS=`$PKG_CONFIG --cflags-only-I libxml-2.0`
2579+
else
2580+
AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
2581+
fi
2582+
fi
2583+
fi
2584+
2585+
if test "$found_libxml" = "yes"; then
2586+
PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
2587+
PHP_EVAL_INCLINE($LIBXML_INCS)
2588+
2589+
dnl Check that build works with given libs
2590+
AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
2591+
PHP_TEST_BUILD(xmlInitParser,
2592+
[
2593+
php_cv_libxml_build_works=yes
2594+
], [
2595+
AC_MSG_RESULT(no)
2596+
AC_MSG_ERROR([build test failed. Please check the config.log for details.])
2597+
], [
2598+
[$]$1
2599+
])
2600+
])
2601+
if test "$php_cv_libxml_build_works" = "yes"; then
2602+
AC_DEFINE(HAVE_LIBXML, 1, [ ])
2603+
fi
2604+
$2
25802605
ifelse([$3],[],,[else $3])
25812606
fi
25822607
])

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)