@@ -2534,15 +2534,18 @@ dnl
2534
2534
dnl Common setup macro for libxml
2535
2535
dnl
2536
2536
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
+ ] )
2546
2549
2547
2550
if test -x "$ac_cv_php_xml2_config_path"; then
2548
2551
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,
2553
2556
IFS=$ac_IFS
2554
2557
LIBXML_VERSION=`expr [ $] 1 \* 1000000 + [ $] 2 \* 1000 + [ $] 3`
2555
2558
if test "$LIBXML_VERSION" -ge "2006011"; then
2559
+ found_libxml=yes
2556
2560
LIBXML_LIBS=`$XML2_CONFIG --libs`
2557
2561
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
2577
2562
else
2578
2563
AC_MSG_ERROR ( [ libxml2 version 2.6.11 or greater required.] )
2579
2564
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
2580
2605
ifelse ( [ $3 ] ,[ ] ,,[ else $3 ] )
2581
2606
fi
2582
2607
] )
0 commit comments