Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | AM_PATH_XML2 uses xml-config which we disable through |
| 2 | binconfig-disabled.bbclass, so port it to use pkg-config instead. |
| 3 | |
| 4 | Upstream-Status: Pending |
| 5 | Signed-off-by: Ross Burton <ross.burton@intel.com> |
| 6 | |
| 7 | diff --git a/libxml.m4 b/libxml.m4 |
| 8 | index 68cd824..5fa0a9b 100644 |
| 9 | --- a/libxml.m4 |
| 10 | +++ b/libxml.m4 |
| 11 | @@ -1,188 +1,12 @@ |
| 12 | -# Configure paths for LIBXML2 |
| 13 | -# Mike Hommey 2004-06-19 |
| 14 | -# use CPPFLAGS instead of CFLAGS |
| 15 | -# Toshio Kuratomi 2001-04-21 |
| 16 | -# Adapted from: |
| 17 | -# Configure paths for GLIB |
| 18 | -# Owen Taylor 97-11-3 |
| 19 | - |
| 20 | dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) |
| 21 | dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS |
| 22 | dnl |
| 23 | -AC_DEFUN([AM_PATH_XML2],[ |
| 24 | -AC_ARG_WITH(xml-prefix, |
| 25 | - [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)], |
| 26 | - xml_config_prefix="$withval", xml_config_prefix="") |
| 27 | -AC_ARG_WITH(xml-exec-prefix, |
| 28 | - [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)], |
| 29 | - xml_config_exec_prefix="$withval", xml_config_exec_prefix="") |
| 30 | -AC_ARG_ENABLE(xmltest, |
| 31 | - [ --disable-xmltest Do not try to compile and run a test LIBXML program],, |
| 32 | - enable_xmltest=yes) |
| 33 | - |
| 34 | - if test x$xml_config_exec_prefix != x ; then |
| 35 | - xml_config_args="$xml_config_args" |
| 36 | - if test x${XML2_CONFIG+set} != xset ; then |
| 37 | - XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config |
| 38 | - fi |
| 39 | - fi |
| 40 | - if test x$xml_config_prefix != x ; then |
| 41 | - xml_config_args="$xml_config_args --prefix=$xml_config_prefix" |
| 42 | - if test x${XML2_CONFIG+set} != xset ; then |
| 43 | - XML2_CONFIG=$xml_config_prefix/bin/xml2-config |
| 44 | - fi |
| 45 | - fi |
| 46 | - |
| 47 | - AC_PATH_PROG(XML2_CONFIG, xml2-config, no) |
| 48 | - min_xml_version=ifelse([$1], ,2.0.0,[$1]) |
| 49 | - AC_MSG_CHECKING(for libxml - version >= $min_xml_version) |
| 50 | - no_xml="" |
| 51 | - if test "$XML2_CONFIG" = "no" ; then |
| 52 | - no_xml=yes |
| 53 | - else |
| 54 | - XML_CPPFLAGS=`$XML2_CONFIG $xml_config_args --cflags` |
| 55 | - XML_LIBS=`$XML2_CONFIG $xml_config_args --libs` |
| 56 | - xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \ |
| 57 | - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
| 58 | - xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \ |
| 59 | - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
| 60 | - xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \ |
| 61 | - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
| 62 | - if test "x$enable_xmltest" = "xyes" ; then |
| 63 | - ac_save_CPPFLAGS="$CPPFLAGS" |
| 64 | - ac_save_LIBS="$LIBS" |
| 65 | - CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS" |
| 66 | - LIBS="$XML_LIBS $LIBS" |
| 67 | -dnl |
| 68 | -dnl Now check if the installed libxml is sufficiently new. |
| 69 | -dnl (Also sanity checks the results of xml2-config to some extent) |
| 70 | -dnl |
| 71 | - rm -f conf.xmltest |
| 72 | - AC_TRY_RUN([ |
| 73 | -#include <stdlib.h> |
| 74 | -#include <stdio.h> |
| 75 | -#include <string.h> |
| 76 | -#include <libxml/xmlversion.h> |
| 77 | - |
| 78 | -int |
| 79 | -main() |
| 80 | -{ |
| 81 | - int xml_major_version, xml_minor_version, xml_micro_version; |
| 82 | - int major, minor, micro; |
| 83 | - char *tmp_version; |
| 84 | - |
| 85 | - system("touch conf.xmltest"); |
| 86 | - |
| 87 | - /* Capture xml2-config output via autoconf/configure variables */ |
| 88 | - /* HP/UX 9 (%@#!) writes to sscanf strings */ |
| 89 | - tmp_version = (char *)strdup("$min_xml_version"); |
| 90 | - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { |
| 91 | - printf("%s, bad version string from xml2-config\n", "$min_xml_version"); |
| 92 | - exit(1); |
| 93 | - } |
| 94 | - free(tmp_version); |
| 95 | - |
| 96 | - /* Capture the version information from the header files */ |
| 97 | - tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION); |
| 98 | - if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) { |
| 99 | - printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION"); |
| 100 | - exit(1); |
| 101 | - } |
| 102 | - free(tmp_version); |
| 103 | - |
| 104 | - /* Compare xml2-config output to the libxml headers */ |
| 105 | - if ((xml_major_version != $xml_config_major_version) || |
| 106 | - (xml_minor_version != $xml_config_minor_version) || |
| 107 | - (xml_micro_version != $xml_config_micro_version)) |
| 108 | - { |
| 109 | - printf("*** libxml header files (version %d.%d.%d) do not match\n", |
| 110 | - xml_major_version, xml_minor_version, xml_micro_version); |
| 111 | - printf("*** xml2-config (version %d.%d.%d)\n", |
| 112 | - $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version); |
| 113 | - return 1; |
| 114 | - } |
| 115 | -/* Compare the headers to the library to make sure we match */ |
| 116 | - /* Less than ideal -- doesn't provide us with return value feedback, |
| 117 | - * only exits if there's a serious mismatch between header and library. |
| 118 | - */ |
| 119 | - LIBXML_TEST_VERSION; |
| 120 | - |
| 121 | - /* Test that the library is greater than our minimum version */ |
| 122 | - if ((xml_major_version > major) || |
| 123 | - ((xml_major_version == major) && (xml_minor_version > minor)) || |
| 124 | - ((xml_major_version == major) && (xml_minor_version == minor) && |
| 125 | - (xml_micro_version >= micro))) |
| 126 | - { |
| 127 | - return 0; |
| 128 | - } |
| 129 | - else |
| 130 | - { |
| 131 | - printf("\n*** An old version of libxml (%d.%d.%d) was found.\n", |
| 132 | - xml_major_version, xml_minor_version, xml_micro_version); |
| 133 | - printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n", |
| 134 | - major, minor, micro); |
| 135 | - printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n"); |
| 136 | - printf("***\n"); |
| 137 | - printf("*** If you have already installed a sufficiently new version, this error\n"); |
| 138 | - printf("*** probably means that the wrong copy of the xml2-config shell script is\n"); |
| 139 | - printf("*** being found. The easiest way to fix this is to remove the old version\n"); |
| 140 | - printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n"); |
| 141 | - printf("*** correct copy of xml2-config. (In this case, you will have to\n"); |
| 142 | - printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); |
| 143 | - printf("*** so that the correct libraries are found at run-time))\n"); |
| 144 | - } |
| 145 | - return 1; |
| 146 | -} |
| 147 | -],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
| 148 | - CPPFLAGS="$ac_save_CPPFLAGS" |
| 149 | - LIBS="$ac_save_LIBS" |
| 150 | - fi |
| 151 | - fi |
| 152 | +AC_DEFUN([AM_PATH_XML2],[ |
| 153 | + AC_REQUIRE([PKG_PROG_PKG_CONFIG]) |
| 154 | |
| 155 | - if test "x$no_xml" = x ; then |
| 156 | - AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version)) |
| 157 | - ifelse([$2], , :, [$2]) |
| 158 | - else |
| 159 | - AC_MSG_RESULT(no) |
| 160 | - if test "$XML2_CONFIG" = "no" ; then |
| 161 | - echo "*** The xml2-config script installed by LIBXML could not be found" |
| 162 | - echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in" |
| 163 | - echo "*** your path, or set the XML2_CONFIG environment variable to the" |
| 164 | - echo "*** full path to xml2-config." |
| 165 | - else |
| 166 | - if test -f conf.xmltest ; then |
| 167 | - : |
| 168 | - else |
| 169 | - echo "*** Could not run libxml test program, checking why..." |
| 170 | - CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS" |
| 171 | - LIBS="$LIBS $XML_LIBS" |
| 172 | - AC_TRY_LINK([ |
| 173 | -#include <libxml/xmlversion.h> |
| 174 | -#include <stdio.h> |
| 175 | -], [ LIBXML_TEST_VERSION; return 0;], |
| 176 | - [ echo "*** The test program compiled, but did not run. This usually means" |
| 177 | - echo "*** that the run-time linker is not finding LIBXML or finding the wrong" |
| 178 | - echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your" |
| 179 | - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" |
| 180 | - echo "*** to the installed location Also, make sure you have run ldconfig if that" |
| 181 | - echo "*** is required on your system" |
| 182 | - echo "***" |
| 183 | - echo "*** If you have an old version installed, it is best to remove it, although" |
| 184 | - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], |
| 185 | - [ echo "*** The test program failed to compile or link. See the file config.log for the" |
| 186 | - echo "*** exact error that occured. This usually means LIBXML was incorrectly installed" |
| 187 | - echo "*** or that you have moved LIBXML since it was installed. In the latter case, you" |
| 188 | - echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ]) |
| 189 | - CPPFLAGS="$ac_save_CPPFLAGS" |
| 190 | - LIBS="$ac_save_LIBS" |
| 191 | - fi |
| 192 | - fi |
| 193 | + verdep=ifelse([$1], [], [], [>= $1]) |
| 194 | + PKG_CHECK_MODULES(XML, [libxml-2.0 $verdep], [$2], [$3]) |
| 195 | |
| 196 | - XML_CPPFLAGS="" |
| 197 | - XML_LIBS="" |
| 198 | - ifelse([$3], , :, [$3]) |
| 199 | - fi |
| 200 | + XML_CPPFLAGS=$XML_CFLAGS |
| 201 | AC_SUBST(XML_CPPFLAGS) |
| 202 | - AC_SUBST(XML_LIBS) |
| 203 | - rm -f conf.xmltest |
| 204 | ]) |