log4c.m4 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. # Configure paths for LOG4C
  2. # Owen Taylor 97-11-3
  3. dnl AM_PATH_LOG4C([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  4. dnl Test for LOG4C, and define LOG4C_CFLAGS and LOG4C_LIBS
  5. dnl
  6. AC_DEFUN([AM_PATH_LOG4C],
  7. [dnl
  8. dnl Get the cflags and libraries from the log4c-config script
  9. dnl
  10. AC_ARG_WITH(log4c-prefix,[ --with-log4c-prefix=PFX Prefix where LOG4C is installed (optional)],
  11. log4c_config_prefix="$withval", log4c_config_prefix="")
  12. AC_ARG_WITH(log4c-exec-prefix,[ --with-log4c-exec-prefix=PFX Exec prefix where LOG4C is installed (optional)],
  13. log4c_config_exec_prefix="$withval", log4c_config_exec_prefix="")
  14. AC_ARG_ENABLE(log4ctest, [ --disable-log4ctest Do not try to compile and run a test LOG4C program],
  15. , enable_log4ctest=yes)
  16. if test x$log4c_config_exec_prefix != x ; then
  17. log4c_config_args="$log4c_config_args --exec-prefix=$log4c_config_exec_prefix"
  18. if test x${LOG4C_CONFIG+set} != xset ; then
  19. LOG4C_CONFIG=$log4c_config_exec_prefix/bin/log4c-config
  20. fi
  21. fi
  22. if test x$log4c_config_prefix != x ; then
  23. log4c_config_args="$log4c_config_args --prefix=$log4c_config_prefix"
  24. if test x${LOG4C_CONFIG+set} != xset ; then
  25. LOG4C_CONFIG=$log4c_config_prefix/bin/log4c-config
  26. fi
  27. fi
  28. AC_PATH_PROG(LOG4C_CONFIG, log4c-config, no)
  29. min_log4c_version=ifelse([$1], ,0.99.7,$1)
  30. AC_MSG_CHECKING(for LOG4C - version >= $min_log4c_version)
  31. no_log4c=""
  32. if test "$LOG4C_CONFIG" = "no" ; then
  33. no_log4c=yes
  34. else
  35. LOG4C_CFLAGS=`$LOG4C_CONFIG $log4c_config_args --cflags`
  36. LOG4C_LIBS=`$LOG4C_CONFIG $log4c_config_args --libs`
  37. log4c_config_major_version=`$LOG4C_CONFIG $log4c_config_args --version | \
  38. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  39. log4c_config_minor_version=`$LOG4C_CONFIG $log4c_config_args --version | \
  40. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  41. log4c_config_micro_version=`$LOG4C_CONFIG $log4c_config_args --version | \
  42. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  43. if test "x$enable_log4ctest" = "xyes" ; then
  44. ac_save_CFLAGS="$CFLAGS"
  45. ac_save_LIBS="$LIBS"
  46. CFLAGS="$CFLAGS $LOG4C_CFLAGS"
  47. LIBS="$LOG4C_LIBS $LIBS"
  48. dnl
  49. dnl Now check if the installed LOG4C is sufficiently new. (Also sanity
  50. dnl checks the results of log4c-config to some extent
  51. dnl
  52. rm -f conf.log4ctest
  53. AC_TRY_RUN([
  54. #include <log4c.h>
  55. #include <stdio.h>
  56. #include <stdlib.h>
  57. #include <string.h>
  58. int
  59. main ()
  60. {
  61. int major, minor, micro;
  62. char *tmp_version;
  63. system ("touch conf.log4ctest");
  64. /* HP/UX 9 (%@#!) writes to sscanf strings */
  65. tmp_version = strdup("$min_log4c_version");
  66. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  67. printf("%s, bad version string\n", "$min_log4c_version");
  68. exit(1);
  69. }
  70. if ((log4c_major_version != $log4c_config_major_version) ||
  71. (log4c_minor_version != $log4c_config_minor_version) ||
  72. (log4c_micro_version != $log4c_config_micro_version))
  73. {
  74. printf("\n*** 'log4c-config --version' returned %d.%d.%d, but LOG4C (%d.%d.%d)\n",
  75. $log4c_config_major_version, $log4c_config_minor_version, $log4c_config_micro_version,
  76. log4c_major_version, log4c_minor_version, log4c_micro_version);
  77. printf ("*** was found! If log4c-config was correct, then it is best\n");
  78. printf ("*** to remove the old version of LOG4C. You may also be able to fix the error\n");
  79. printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
  80. printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
  81. printf("*** required on your system.\n");
  82. printf("*** If log4c-config was wrong, set the environment variable LOG4C_CONFIG\n");
  83. printf("*** to point to the correct copy of log4c-config, and remove the file config.cache\n");
  84. printf("*** before re-running configure\n");
  85. }
  86. else if ((log4c_major_version != LOG4C_MAJOR_VERSION) ||
  87. (log4c_minor_version != LOG4C_MINOR_VERSION) ||
  88. (log4c_micro_version != LOG4C_MICRO_VERSION))
  89. {
  90. printf("*** LOG4C header files (version %d.%d.%d) do not match\n",
  91. LOG4C_MAJOR_VERSION, LOG4C_MINOR_VERSION, LOG4C_MICRO_VERSION);
  92. printf("*** library (version %d.%d.%d)\n",
  93. log4c_major_version, log4c_minor_version, log4c_micro_version);
  94. }
  95. else
  96. {
  97. if ((log4c_major_version > major) ||
  98. ((log4c_major_version == major) && (log4c_minor_version > minor)) ||
  99. ((log4c_major_version == major) && (log4c_minor_version == minor) && (log4c_micro_version >= micro)))
  100. {
  101. return 0;
  102. }
  103. else
  104. {
  105. printf("\n*** An old version of LOG4C (%d.%d.%d) was found.\n",
  106. log4c_major_version, log4c_minor_version, log4c_micro_version);
  107. printf("*** You need a version of LOG4C newer than %d.%d.%d. The latest version of\n",
  108. major, minor, micro);
  109. printf("***\n");
  110. printf("*** If you have already installed a sufficiently new version, this error\n");
  111. printf("*** probably means that the wrong copy of the log4c-config shell script is\n");
  112. printf("*** being found. The easiest way to fix this is to remove the old version\n");
  113. printf("*** of LOG4C, but you can also set the LOG4C_CONFIG environment to point to the\n");
  114. printf("*** correct copy of log4c-config. (In this case, you will have to\n");
  115. printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
  116. printf("*** so that the correct libraries are found at run-time))\n");
  117. }
  118. }
  119. return 1;
  120. }
  121. ],, no_log4c=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  122. CFLAGS="$ac_save_CFLAGS"
  123. LIBS="$ac_save_LIBS"
  124. fi
  125. fi
  126. if test "x$no_log4c" = x ; then
  127. AC_MSG_RESULT(yes)
  128. ifelse([$2], , :, [$2])
  129. else
  130. AC_MSG_RESULT(no)
  131. if test "$LOG4C_CONFIG" = "no" ; then
  132. echo "*** The log4c-config script installed by LOG4C could not be found"
  133. echo "*** If LOG4C was installed in PREFIX, make sure PREFIX/bin is in"
  134. echo "*** your path, or set the LOG4C_CONFIG environment variable to the"
  135. echo "*** full path to log4c-config."
  136. else
  137. if test -f conf.log4ctest ; then
  138. :
  139. else
  140. echo "*** Could not run LOG4C test program, checking why..."
  141. CFLAGS="$CFLAGS $LOG4C_CFLAGS"
  142. LIBS="$LIBS $LOG4C_LIBS"
  143. AC_TRY_LINK([
  144. #include <log4c.h>
  145. #include <stdio.h>
  146. ], [ return ((log4c_major_version) || (log4c_minor_version) || (log4c_micro_version)); ],
  147. [ echo "*** The test program compiled, but did not run. This usually means"
  148. echo "*** that the run-time linker is not finding LOG4C or finding the wrong"
  149. echo "*** version of LOG4C. If it is not finding LOG4C, you'll need to set your"
  150. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  151. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  152. echo "*** is required on your system"
  153. echo "***"
  154. echo "*** If you have an old version installed, it is best to remove it, although"
  155. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
  156. echo "***" ],
  157. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  158. echo "*** exact error that occured. This usually means LOG4C was incorrectly installed"
  159. echo "*** or that you have moved LOG4C since it was installed. In the latter case, you"
  160. echo "*** may want to edit the log4c-config script: $LOG4C_CONFIG" ])
  161. CFLAGS="$ac_save_CFLAGS"
  162. LIBS="$ac_save_LIBS"
  163. fi
  164. fi
  165. LOG4C_CFLAGS=""
  166. LOG4C_LIBS=""
  167. ifelse([$3], , :, [$3])
  168. fi
  169. AC_SUBST(LOG4C_CFLAGS)
  170. AC_SUBST(LOG4C_LIBS)
  171. rm -f conf.log4ctest
  172. ])