libxslt.m4 7.9 KB

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