You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
6.9 KiB

  1. # Configure paths for CLN
  2. # Richard Kreckel 11/17/2000
  3. # stolen from Christian Bauer
  4. # stolen from Sam Lantinga
  5. # stolen from Manish Singh
  6. # stolen back from Frank Belew
  7. # stolen from Manish Singh
  8. # Shamelessly stolen from Owen Taylor
  9. dnl AC_PATH_LIBCLN([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  10. dnl Test for installed CLN library, and define LIBCLN_CPPFLAGS and LIBCLN_LIBS
  11. dnl
  12. AC_DEFUN(AC_PATH_LIBCLN,
  13. [dnl
  14. dnl Get the cppflags and libraries from the cln-config script
  15. dnl
  16. AC_ARG_WITH(cln-prefix,[ --with-cln-prefix=PFX Prefix where CLN is installed (optional)],
  17. cln_config_prefix="$withval", cln_config_prefix="")
  18. AC_ARG_WITH(cln-exec-prefix,[ --with-cln-exec-prefix=PFX Exec prefix where CLN is installed (optional)],
  19. cln_config_exec_prefix="$withval", cln_config_exec_prefix="")
  20. AC_ARG_ENABLE(clntest, [ --disable-clntest Do not try to compile and run a test CLN program],
  21. , enable_clntest=yes)
  22. if test x$cln_config_exec_prefix != x ; then
  23. cln_config_args="$cln_config_args --exec-prefix=$cln_config_exec_prefix"
  24. if test x${CLN_CONFIG+set} != xset ; then
  25. CLN_CONFIG=$cln_config_exec_prefix/bin/cln-config
  26. fi
  27. fi
  28. if test x$cln_config_prefix != x ; then
  29. cln_config_args="$cln_config_args --prefix=$cln_config_prefix"
  30. if test x${CLN_CONFIG+set} != xset ; then
  31. CLN_CONFIG=$cln_config_prefix/bin/cln-config
  32. fi
  33. fi
  34. AC_PATH_PROG(CLN_CONFIG, cln-config, no)
  35. min_cln_version=ifelse([$1], ,1.1.0,$1)
  36. AC_MSG_CHECKING(for CLN - version >= $min_cln_version)
  37. no_cln=""
  38. if test "$CLN_CONFIG" = "no" ; then
  39. no_cln=yes
  40. else
  41. LIBCLN_CPPFLAGS=`$CLN_CONFIG $cln_config_args --cppflags`
  42. LIBCLN_LIBS=`$CLN_CONFIG $cln_config_args --libs`
  43. cln_config_major_version=`$CLN_CONFIG $cln_config_args --version | \
  44. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  45. cln_config_minor_version=`$CLN_CONFIG $cln_config_args --version | \
  46. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  47. cln_config_micro_version=`$CLN_CONFIG $cln_config_args --version | \
  48. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  49. if test "x$enable_clntest" = "xyes" ; then
  50. ac_save_CPPFLAGS="$CPPFLAGS"
  51. ac_save_LIBS="$LIBS"
  52. CPPFLAGS="$CPPFLAGS $LIBCLN_CPPFLAGS"
  53. LIBS="$LIBS $LIBCLN_LIBS"
  54. dnl
  55. dnl Now check if the installed CLN is sufficiently new. (Also sanity
  56. dnl checks the results of cln-config to some extent
  57. dnl
  58. rm -f conf.clntest
  59. AC_TRY_RUN([
  60. #include <stdio.h>
  61. #include <string.h>
  62. #include <cln/config.h>
  63. /* we do not #include <stdlib.h> because autoconf in C++ mode inserts a
  64. prototype for exit() that conflicts with the one in stdlib.h */
  65. extern "C" int system(const char *);
  66. char* my_strdup (char *str)
  67. {
  68. char *new_str;
  69. if (str) {
  70. new_str = new char[(strlen (str) + 1) * sizeof(char)];
  71. strcpy (new_str, str);
  72. } else
  73. new_str = NULL;
  74. return new_str;
  75. }
  76. int main()
  77. {
  78. int major, minor, micro;
  79. char *tmp_version;
  80. system("touch conf.clntest");
  81. /* HP/UX 9 (%@#!) writes to sscanf strings */
  82. tmp_version = my_strdup("$min_cln_version");
  83. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  84. printf("%s, bad version string\n", "$min_cln_version");
  85. return 1;
  86. }
  87. if (($cln_config_major_version > major) ||
  88. (($cln_config_major_version == major) && ($cln_config_minor_version > minor)) ||
  89. (($cln_config_major_version == major) && ($cln_config_minor_version == minor) && ($cln_config_micro_version >= micro))) {
  90. if ((CL_VERSION_MAJOR == $cln_config_major_version) &&
  91. (CL_VERSION_MINOR == $cln_config_minor_version) &&
  92. (CL_VERSION_PATCHLEVEL == $cln_config_micro_version)) {
  93. return 0;
  94. } else {
  95. printf("\n*** 'cln-config --version' returned %d.%d.%d, but the header file I found\n", $cln_config_major_version, $cln_config_minor_version, $cln_config_micro_version);
  96. printf("*** corresponds to %d.%d.%d. This mismatch suggests your installation of CLN\n", CL_VERSION_MAJOR, CL_VERSION_MINOR, CL_VERSION_PATCHLEVEL);
  97. printf("*** is corrupted. Please inquire and consider reinstalling CLN.\n");
  98. return 1;
  99. }
  100. } else {
  101. printf("\n*** 'cln-config --version' returned %d.%d.%d, but the minimum version\n", $cln_config_major_version, $cln_config_minor_version, $cln_config_micro_version);
  102. printf("*** of CLN required is %d.%d.%d. If cln-config is correct, then it is\n", major, minor, micro);
  103. printf("*** best to upgrade to the required version.\n");
  104. printf("*** If cln-config was wrong, set the environment variable CLN_CONFIG\n");
  105. printf("*** to point to the correct copy of cln-config, and remove the file\n");
  106. printf("*** config.cache before re-running configure\n");
  107. return 1;
  108. }
  109. }
  110. ],, no_cln=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  111. CPPFLAGS="$ac_save_CPPFLAGS"
  112. LIBS="$ac_save_LIBS"
  113. fi
  114. fi
  115. if test "x$no_cln" = x ; then
  116. AC_MSG_RESULT([yes, `$CLN_CONFIG --version`])
  117. ifelse([$2], , :, [$2])
  118. else
  119. AC_MSG_RESULT(no)
  120. if test "$CLN_CONFIG" = "no" ; then
  121. echo "*** The cln-config script installed by CLN could not be found"
  122. echo "*** If CLN was installed in PREFIX, make sure PREFIX/bin is in"
  123. echo "*** your path, or set the CLN_CONFIG environment variable to the"
  124. echo "*** full path to cln-config."
  125. else
  126. if test -f conf.clntest ; then
  127. :
  128. else
  129. echo "*** Could not run CLN test program, checking why..."
  130. CPPFLAGS="$CFLAGS $LIBCLN_CPPFLAGS"
  131. LIBS="$LIBS $LIBCLN_LIBS"
  132. AC_TRY_LINK([
  133. #include <stdio.h>
  134. #include <cln/cln.h>
  135. ], [ return 0; ],
  136. [ echo "*** The test program compiled, but did not run. This usually means"
  137. echo "*** that the run-time linker is not finding CLN or finding the wrong"
  138. echo "*** version of CLN. If it is not finding CLN, you'll need to set your"
  139. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  140. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  141. echo "*** is required on your system"
  142. echo "***"
  143. echo "*** If you have an old version installed, it is best to remove it, although"
  144. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  145. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  146. echo "*** exact error that occured. This usually means CLN was incorrectly installed"
  147. echo "*** or that you have moved CLN since it was installed. In the latter case, you"
  148. echo "*** may want to edit the cln-config script: $CLN_CONFIG" ])
  149. CPPFLAGS="$ac_save_CPPFLAGS"
  150. LIBS="$ac_save_LIBS"
  151. fi
  152. fi
  153. LIBCLN_CPPFLAGS=""
  154. LIBCLN_LIBS=""
  155. ifelse([$3], , :, [$3])
  156. fi
  157. AC_SUBST(LIBCLN_CPPFLAGS)
  158. AC_SUBST(LIBCLN_LIBS)
  159. rm -f conf.clntest
  160. ])