expat.m4 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. # Configure paths for EXPAT
  2. # Owen Taylor 97-11-3
  3. dnl AM_PATH_EXPAT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  4. dnl Test for EXPAT, and define EXPAT_CFLAGS and EXPAT_LIBS
  5. dnl
  6. AC_DEFUN([AM_PATH_EXPAT],
  7. [dnl
  8. dnl Get the cflags and libraries from the expat-config script
  9. dnl
  10. AC_ARG_WITH(expat-prefix,
  11. AC_HELP_STRING([--with-expat-prefix=PFX],
  12. [LOG4C: Prefix where EXPAT is installed (defaults to just
  13. looking in the standard library locations). If
  14. --without-expat is set to yes then this option has
  15. no effect)]))
  16. AC_ARG_ENABLE(expattest,
  17. AC_HELP_STRING([--disable-expattest],
  18. [LOG4C: Do not try to compile and run a test EXPAT program.
  19. (default is no). If without-expat is set to yes this
  20. option has no effect.]),
  21. , enable_expattest=yes)
  22. if test x$with_expat_prefix != x ; then
  23. EXPAT_CFLAGS="-I$with_expat_prefix/include"
  24. EXPAT_LIBS="-L$with_expat_prefix/lib"
  25. fi
  26. min_expat_version=ifelse([$1], ,1.95.1, $1)
  27. dnl AC_MSG_NOTICE([value of with_expat_prefix=$with_expat_prefix \
  28. dnl value of with_expat=$with_expat])
  29. AC_MSG_CHECKING(for EXPAT - version >= $min_expat_version)
  30. EXPAT_CFLAGS="$EXPAT_CFLAGS"
  31. EXPAT_LIBS="$EXPAT_LIBS -lexpat"
  32. if test "x$enable_expattest" = "xyes" ; then
  33. ac_save_CFLAGS="$CFLAGS"
  34. ac_save_LIBS="$LIBS"
  35. CFLAGS="$CFLAGS $EXPAT_CFLAGS"
  36. LIBS="$EXPAT_LIBS $LIBS"
  37. dnl
  38. dnl Now check if the installed EXPAT is sufficiently new. (Also sanity
  39. dnl checks the results of expat-config to some extent
  40. dnl
  41. rm -f conf.expattest
  42. AC_TRY_RUN([
  43. #include <expat.h>
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #include <string.h>
  47. int
  48. main ()
  49. {
  50. int expat_major, expat_minor, expat_micro;
  51. int major, minor, micro;
  52. char *tmp_expat_version;
  53. char *tmp_version;
  54. system ("touch conf.expattest");
  55. /* HP/UX 9 (%@#!) writes to sscanf strings */
  56. tmp_expat_version = strdup(XML_ExpatVersion());
  57. if (sscanf(tmp_expat_version, "expat_%d.%d.%d", &expat_major, &expat_minor, &expat_micro) != 3) {
  58. printf("%s, bad expat version string\n", XML_ExpatVersion());
  59. exit(1);
  60. }
  61. /* HP/UX 9 (%@#!) writes to sscanf strings */
  62. tmp_version = strdup("$min_expat_version");
  63. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  64. printf("%s, bad version string\n", "$min_expat_version");
  65. exit(1);
  66. }
  67. if ((expat_major > major) ||
  68. ((expat_major == major) && (expat_minor > minor)) ||
  69. ((expat_major == major) && (expat_minor == minor) && (expat_micro >= micro)))
  70. {
  71. return 0;
  72. }
  73. else
  74. {
  75. printf("\n*** An old version of EXPAT (%d.%d.%d) was found.\n",
  76. expat_major, expat_minor, expat_micro);
  77. printf("*** You need a version of EXPAT newer than %d.%d.%d. The latest version of\n",
  78. major, minor, micro);
  79. printf("***\n");
  80. printf("*** If you have already installed a sufficiently new version, this error\n");
  81. printf("*** probably means that the wrong copy of the expat-config shell script is\n");
  82. printf("*** being found. The easiest way to fix this is to remove the old version\n");
  83. printf("*** of EXPAT, but you can also set the EXPAT_CONFIG environment to point to the\n");
  84. printf("*** correct copy of expat-config. (In this case, you will have to\n");
  85. printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
  86. printf("*** so that the correct libraries are found at run-time))\n");
  87. }
  88. return 1;
  89. }
  90. ],, no_expat=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  91. CFLAGS="$ac_save_CFLAGS"
  92. LIBS="$ac_save_LIBS"
  93. fi
  94. if test "x$no_expat" = x ; then
  95. AC_MSG_RESULT(yes)
  96. use_expat=yes
  97. ifelse([$2], , :, [$2])
  98. else
  99. AC_MSG_RESULT(no)
  100. use_expat=no
  101. if test -f conf.expattest ; then
  102. :
  103. else
  104. echo "*** Could not run EXPAT test program, checking why..."
  105. CFLAGS="$CFLAGS $EXPAT_CFLAGS"
  106. LIBS="$LIBS $EXPAT_LIBS"
  107. AC_TRY_LINK([
  108. #include <expat.h>
  109. #include <stdio.h>
  110. ], [ return (XML_ExpatVersion()); ],
  111. [ echo "*** The test program compiled, but did not run. This usually means"
  112. echo "*** that the run-time linker is not finding EXPAT or finding the wrong"
  113. echo "*** version of EXPAT. If it is not finding EXPAT you can specify"
  114. echo "*** an install location using --with-expat-prefix option to"
  115. echo "*** configure. You can also set the "
  116. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  117. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  118. echo "*** is required on your system"
  119. echo "***"
  120. echo "*** If you have an old version installed, it is best to remove it, although"
  121. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
  122. echo "***"
  123. echo "*** Log4C will still run without EXPAT--it uses some bundled"
  124. echo "*** lex/yacc code to parse the configuration file"],
  125. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  126. echo "*** exact error that occured. This usually means EXPAT was incorrectly installed"
  127. echo "*** or that you have moved EXPAT since it was installed. In the latter case, you"
  128. echo "*** may want to edit the expat-config script: '$EXPAT_CONFIG'"
  129. echo "*** Log4C will still run without EXPAT--it uses some bundled"
  130. echo "*** lex/yacc code to parse the configuration file"])
  131. CFLAGS="$ac_save_CFLAGS"
  132. LIBS="$ac_save_LIBS"
  133. fi
  134. EXPAT_CFLAGS=""
  135. EXPAT_LIBS=""
  136. ifelse([$3], , :, [$3])
  137. fi
  138. AC_SUBST(EXPAT_CFLAGS)
  139. AC_SUBST(EXPAT_LIBS)
  140. rm -f conf.expattest
  141. ])