2
0

libxml2.m4 7.7 KB

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