libxml.m4 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. # Configure paths for LIBXML2
  2. # Toshio Kuratomi 2001-04-21
  3. # Adapted from:
  4. # Configure paths for GLIB
  5. # Owen Taylor 97-11-3
  6. dnl AM_PATH_XML([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  7. dnl Test for XML, and define XML_CFLAGS and XML_LIBS
  8. dnl
  9. AC_DEFUN([AM_PATH_XML],[
  10. AC_ARG_WITH(xml-prefix,
  11. [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
  12. xml_config_prefix="$withval", xml_config_prefix="")
  13. AC_ARG_WITH(xml-exec-prefix,
  14. [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
  15. xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
  16. AC_ARG_ENABLE(xmltest,
  17. [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
  18. enable_xmltest=yes)
  19. if test x$xml_config_exec_prefix != x ; then
  20. xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
  21. if test x${XML_CONFIG+set} != xset ; then
  22. XML_CONFIG=$xml_config_exec_prefix/bin/xml-config
  23. fi
  24. fi
  25. if test x$xml_config_prefix != x ; then
  26. xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
  27. if test x${XML_CONFIG+set} != xset ; then
  28. XML_CONFIG=$xml_config_prefix/bin/xml-config
  29. fi
  30. fi
  31. AC_PATH_PROG(XML_CONFIG, xml-config, no)
  32. min_xml_version=ifelse([$1], ,1.0.0,[$1])
  33. AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
  34. no_xml=""
  35. if test "$XML_CONFIG" = "no" ; then
  36. no_xml=yes
  37. else
  38. XML_CFLAGS=`$XML_CONFIG $xml_config_args --cflags`
  39. XML_LIBS=`$XML_CONFIG $xml_config_args --libs`
  40. xml_config_major_version=`$XML_CONFIG $xml_config_args --version | \
  41. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  42. xml_config_minor_version=`$XML_CONFIG $xml_config_args --version | \
  43. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  44. xml_config_micro_version=`$XML_CONFIG $xml_config_args --version | \
  45. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  46. if test "x$enable_xmltest" = "xyes" ; then
  47. ac_save_CFLAGS="$CFLAGS"
  48. ac_save_LIBS="$LIBS"
  49. CFLAGS="$CFLAGS $XML_CFLAGS"
  50. LIBS="$XML_LIBS $LIBS"
  51. dnl
  52. dnl Now check if the installed libxml is sufficiently new.
  53. dnl (Also sanity checks the results of xml-config to some extent)
  54. dnl
  55. rm -f conf.xmltest
  56. AC_TRY_RUN([
  57. #include <stdlib.h>
  58. #include <stdio.h>
  59. #include <string.h>
  60. #include <libxml/tree.h>
  61. int
  62. main()
  63. {
  64. int xml_major_version, xml_minor_version, xml_micro_version;
  65. int major, minor, micro;
  66. char *tmp_version;
  67. int tmp_int_version;
  68. system("touch conf.xmltest");
  69. /* Capture xml-config output via autoconf/configure variables */
  70. /* HP/UX 9 (%@#!) writes to sscanf strings */
  71. tmp_version = (char *)strdup("$min_xml_version");
  72. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  73. printf("%s, bad version string from xml-config\n", "$min_xml_version");
  74. exit(1);
  75. }
  76. free(tmp_version);
  77. /* Capture the version information from the header files */
  78. tmp_int_version = LIBXML_VERSION;
  79. xml_major_version=tmp_int_version / 10000;
  80. xml_minor_version=(tmp_int_version - xml_major_version * 10000) / 100;
  81. xml_micro_version=(tmp_int_version - xml_minor_version * 100 - xml_major_version * 10000);
  82. /* Compare xml-config output to the libxml headers */
  83. if ((xml_major_version != $xml_config_major_version) ||
  84. (xml_minor_version != $xml_config_minor_version)
  85. #if 0
  86. ||
  87. /* The last released version of libxml-1.x has an incorrect micro version in
  88. * the header file so neither the includes nor the library will match the
  89. * micro_version to the output of xml-config
  90. */
  91. (xml_micro_version != $xml_config_micro_version)
  92. #endif
  93. )
  94. {
  95. printf("*** libxml header files (version %d.%d.%d) do not match\n",
  96. xml_major_version, xml_minor_version, xml_micro_version);
  97. printf("*** xml-config (version %d.%d.%d)\n",
  98. $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
  99. return 1;
  100. }
  101. /* Compare the headers to the library to make sure we match */
  102. /* Less than ideal -- doesn't provide us with return value feedback,
  103. * only exits if there's a serious mismatch between header and library.
  104. */
  105. LIBXML_TEST_VERSION;
  106. /* Test that the library is greater than our minimum version */
  107. if (($xml_config_major_version > major) ||
  108. (($xml_config_major_version == major) && ($xml_config_minor_version > minor)) ||
  109. (($xml_config_major_version == major) && ($xml_config_minor_version == minor) &&
  110. ($xml_config_micro_version >= micro)))
  111. {
  112. return 0;
  113. }
  114. else
  115. {
  116. printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
  117. xml_major_version, xml_minor_version, xml_micro_version);
  118. printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
  119. major, minor, micro);
  120. printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
  121. printf("***\n");
  122. printf("*** If you have already installed a sufficiently new version, this error\n");
  123. printf("*** probably means that the wrong copy of the xml-config shell script is\n");
  124. printf("*** being found. The easiest way to fix this is to remove the old version\n");
  125. printf("*** of LIBXML, but you can also set the XML_CONFIG environment to point to the\n");
  126. printf("*** correct copy of xml-config. (In this case, you will have to\n");
  127. printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
  128. printf("*** so that the correct libraries are found at run-time))\n");
  129. }
  130. return 1;
  131. }
  132. ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  133. CFLAGS="$ac_save_CFLAGS"
  134. LIBS="$ac_save_LIBS"
  135. fi
  136. fi
  137. if test "x$no_xml" = x ; then
  138. AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
  139. ifelse([$2], , :, [$2])
  140. else
  141. AC_MSG_RESULT(no)
  142. if test "$XML_CONFIG" = "no" ; then
  143. echo "*** The xml-config script installed by LIBXML could not be found"
  144. echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
  145. echo "*** your path, or set the XML_CONFIG environment variable to the"
  146. echo "*** full path to xml-config."
  147. else
  148. if test -f conf.xmltest ; then
  149. :
  150. else
  151. echo "*** Could not run libxml test program, checking why..."
  152. CFLAGS="$CFLAGS $XML_CFLAGS"
  153. LIBS="$LIBS $XML_LIBS"
  154. AC_TRY_LINK([
  155. #include <libxml/tree.h>
  156. #include <stdio.h>
  157. ], [ LIBXML_TEST_VERSION; return 0;],
  158. [ echo "*** The test program compiled, but did not run. This usually means"
  159. echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
  160. echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
  161. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  162. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  163. echo "*** is required on your system"
  164. echo "***"
  165. echo "*** If you have an old version installed, it is best to remove it, although"
  166. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
  167. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  168. echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
  169. echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
  170. echo "*** may want to edit the xml-config script: $XML_CONFIG" ])
  171. CFLAGS="$ac_save_CFLAGS"
  172. LIBS="$ac_save_LIBS"
  173. fi
  174. fi
  175. XML_CFLAGS=""
  176. XML_LIBS=""
  177. ifelse([$3], , :, [$3])
  178. fi
  179. AC_SUBST(XML_CFLAGS)
  180. AC_SUBST(XML_LIBS)
  181. rm -f conf.xmltest
  182. ])
  183. # Configure paths for LIBXML2
  184. # Toshio Kuratomi 2001-04-21
  185. # Adapted from:
  186. # Configure paths for GLIB
  187. # Owen Taylor 97-11-3
  188. dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  189. dnl Test for XML, and define XML_CFLAGS and XML_LIBS
  190. dnl
  191. AC_DEFUN([AM_PATH_XML2],[
  192. AC_ARG_WITH(xml-prefix,
  193. [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
  194. xml_config_prefix="$withval", xml_config_prefix="")
  195. AC_ARG_WITH(xml-exec-prefix,
  196. [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
  197. xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
  198. AC_ARG_ENABLE(xmltest,
  199. [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
  200. enable_xmltest=yes)
  201. if test x$xml_config_exec_prefix != x ; then
  202. xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
  203. if test x${XML2_CONFIG+set} != xset ; then
  204. XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
  205. fi
  206. fi
  207. if test x$xml_config_prefix != x ; then
  208. xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
  209. if test x${XML2_CONFIG+set} != xset ; then
  210. XML2_CONFIG=$xml_config_prefix/bin/xml2-config
  211. fi
  212. fi
  213. AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
  214. min_xml_version=ifelse([$1], ,2.0.0,[$1])
  215. AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
  216. no_xml=""
  217. if test "$XML2_CONFIG" = "no" ; then
  218. no_xml=yes
  219. else
  220. XML_CFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
  221. XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
  222. xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
  223. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  224. xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
  225. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  226. xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
  227. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  228. if test "x$enable_xmltest" = "xyes" ; then
  229. ac_save_CFLAGS="$CFLAGS"
  230. ac_save_CXXFLAGS="$CXXFLAGS"
  231. ac_save_LIBS="$LIBS"
  232. CFLAGS="$CFLAGS $XML_CFLAGS"
  233. CXXFLAGS="$CXXFLAGS $XML_CFLAGS"
  234. LIBS="$XML_LIBS $LIBS"
  235. dnl
  236. dnl Now check if the installed libxml is sufficiently new.
  237. dnl (Also sanity checks the results of xml2-config to some extent)
  238. dnl
  239. rm -f conf.xmltest
  240. AC_TRY_RUN([
  241. #include <stdlib.h>
  242. #include <stdio.h>
  243. #include <string.h>
  244. #include <libxml/xmlversion.h>
  245. int
  246. main()
  247. {
  248. int xml_major_version, xml_minor_version, xml_micro_version;
  249. int major, minor, micro;
  250. char *tmp_version;
  251. system("touch conf.xmltest");
  252. /* Capture xml2-config output via autoconf/configure variables */
  253. /* HP/UX 9 (%@#!) writes to sscanf strings */
  254. tmp_version = (char *)strdup("$min_xml_version");
  255. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  256. printf("%s, bad version string from xml2-config\n", "$min_xml_version");
  257. exit(1);
  258. }
  259. free(tmp_version);
  260. /* Capture the version information from the header files */
  261. tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
  262. if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
  263. printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
  264. exit(1);
  265. }
  266. free(tmp_version);
  267. /* Compare xml2-config output to the libxml headers */
  268. if ((xml_major_version != $xml_config_major_version) ||
  269. (xml_minor_version != $xml_config_minor_version) ||
  270. (xml_micro_version != $xml_config_micro_version))
  271. {
  272. printf("*** libxml header files (version %d.%d.%d) do not match\n",
  273. xml_major_version, xml_minor_version, xml_micro_version);
  274. printf("*** xml2-config (version %d.%d.%d)\n",
  275. $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
  276. return 1;
  277. }
  278. /* Compare the headers to the library to make sure we match */
  279. /* Less than ideal -- doesn't provide us with return value feedback,
  280. * only exits if there's a serious mismatch between header and library.
  281. */
  282. LIBXML_TEST_VERSION;
  283. /* Test that the library is greater than our minimum version */
  284. if ((xml_major_version > major) ||
  285. ((xml_major_version == major) && (xml_minor_version > minor)) ||
  286. ((xml_major_version == major) && (xml_minor_version == minor) &&
  287. (xml_micro_version >= micro)))
  288. {
  289. return 0;
  290. }
  291. else
  292. {
  293. printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
  294. xml_major_version, xml_minor_version, xml_micro_version);
  295. printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
  296. major, minor, micro);
  297. printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
  298. printf("***\n");
  299. printf("*** If you have already installed a sufficiently new version, this error\n");
  300. printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
  301. printf("*** being found. The easiest way to fix this is to remove the old version\n");
  302. printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
  303. printf("*** correct copy of xml2-config. (In this case, you will have to\n");
  304. printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
  305. printf("*** so that the correct libraries are found at run-time))\n");
  306. }
  307. return 1;
  308. }
  309. ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  310. CFLAGS="$ac_save_CFLAGS"
  311. CXXFLAGS="$ac_save_CXXFLAGS"
  312. LIBS="$ac_save_LIBS"
  313. fi
  314. fi
  315. if test "x$no_xml" = x ; then
  316. AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
  317. ifelse([$2], , :, [$2])
  318. else
  319. AC_MSG_RESULT(no)
  320. if test "$XML2_CONFIG" = "no" ; then
  321. echo "*** The xml2-config script installed by LIBXML could not be found"
  322. echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
  323. echo "*** your path, or set the XML2_CONFIG environment variable to the"
  324. echo "*** full path to xml2-config."
  325. else
  326. if test -f conf.xmltest ; then
  327. :
  328. else
  329. echo "*** Could not run libxml test program, checking why..."
  330. CFLAGS="$CFLAGS $XML_CFLAGS"
  331. CXXFLAGS="$CXXFLAGS $XML_CFLAGS"
  332. LIBS="$LIBS $XML_LIBS"
  333. AC_TRY_LINK([
  334. #include <libxml/xmlversion.h>
  335. #include <stdio.h>
  336. ], [ LIBXML_TEST_VERSION; return 0;],
  337. [ echo "*** The test program compiled, but did not run. This usually means"
  338. echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
  339. echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
  340. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  341. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  342. echo "*** is required on your system"
  343. echo "***"
  344. echo "*** If you have an old version installed, it is best to remove it, although"
  345. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
  346. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  347. echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
  348. echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
  349. echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
  350. CFLAGS="$ac_save_CFLAGS"
  351. CXXFLAGS="$ac_save_CXXFLAGS"
  352. LIBS="$ac_save_LIBS"
  353. fi
  354. fi
  355. XML_CFLAGS=""
  356. XML_LIBS=""
  357. $3
  358. ifelse([$3], , :, [$3])
  359. fi
  360. AC_SUBST(XML_CFLAGS)
  361. AC_SUBST(XML_LIBS)
  362. rm -f conf.xmltest
  363. ])