@@ -2523,15 +2523,18 @@ dnl
2523
2523
dnl Common setup macro for libxml
2524
2524
dnl
2525
2525
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
+ ] )
2535
2538
2536
2539
if test -x "$ac_cv_php_xml2_config_path"; then
2537
2540
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,
2542
2545
IFS=$ac_IFS
2543
2546
LIBXML_VERSION=`expr [ $] 1 \* 1000000 + [ $] 2 \* 1000 + [ $] 3`
2544
2547
if test "$LIBXML_VERSION" -ge "2006011"; then
2548
+ found_libxml=yes
2545
2549
LIBXML_LIBS=`$XML2_CONFIG --libs`
2546
2550
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
2566
2551
else
2567
2552
AC_MSG_ERROR ( [ libxml2 version 2.6.11 or greater required.] )
2568
2553
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
2569
2594
ifelse ( [ $3 ] ,[ ] ,,[ else $3 ] )
2570
2595
fi
2571
2596
] )
0 commit comments