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.

155 lines
6.2 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_prefix="$withval", cln_prefix="")
  18. AC_ARG_WITH(cln-exec-prefix,[ --with-cln-exec-prefix=PFX Exec prefix where CLN is installed (optional)],
  19. cln_exec_prefix="$withval", cln_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_exec_prefix != x ; then
  23. cln_args="$cln_args --exec-prefix=$cln_exec_prefix"
  24. if test x${CLN_CONFIG+set} != xset ; then
  25. CLN_CONFIG=$cln_exec_prefix/bin/cln-config
  26. fi
  27. fi
  28. if test x$cln_prefix != x ; then
  29. cln_args="$cln_args --prefix=$cln_prefix"
  30. if test x${CLN_CONFIG+set} != xset ; then
  31. CLN_CONFIG=$cln_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 $clnconf_args --cppflags`
  42. LIBCLN_LIBS=`$CLN_CONFIG $clnconf_args --libs`
  43. cln_major_version=`$CLN_CONFIG $cln_args --version | \
  44. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  45. cln_minor_version=`$CLN_CONFIG $cln_args --version | \
  46. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  47. cln_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 <stdlib.h>
  62. #include <string.h>
  63. #include <cln/config.h>
  64. int main ()
  65. {
  66. int major, minor, micro;
  67. char *tmp_version;
  68. system("touch conf.clntest");
  69. tmp_version = strdup("$min_cln_version");
  70. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  71. printf("%s, bad version string\n", "$min_cln_version");
  72. exit(1);
  73. }
  74. if (($cln_major_version > major) ||
  75. (($cln_major_version == major) && ($cln_minor_version > minor)) ||
  76. (($cln_major_version == major) && ($cln_minor_version == minor) && ($cln_micro_version >= micro))) {
  77. if ((CL_VERSION_MAJOR == $cln_major_version) &&
  78. (CL_VERSION_MINOR == $cln_minor_version) &&
  79. (CL_VERSION_PATCHLEVEL == $cln_micro_version)) {
  80. return 0;
  81. } else {
  82. printf("\n*** 'cln-config --version' returned %d.%d.%d, but the header file I found\n", $cln_major_version, $cln_minor_version, $cln_micro_version);
  83. printf("*** corresponds to %d.%d.%d. This mismatch suggests your installation of CLN\n", CL_VERSION_MAJOR, CL_VERSION_MINOR, CL_VERSION_PATCHLEVEL);
  84. printf("*** is corrupted. Please inquire and consider reinstalling CLN.\n");
  85. return 1;
  86. }
  87. } else {
  88. printf("\n*** 'cln-config --version' returned %d.%d.%d, but the minimum version\n", $cln_major_version, $cln_minor_version, $cln_micro_version);
  89. printf("*** of CLN required is %d.%d.%d. If cln-config is correct, then it is\n", major, minor, micro);
  90. printf("*** best to upgrade to the required version.\n");
  91. printf("*** If cln-config was wrong, set the environment variable CLN_CONFIG\n");
  92. printf("*** to point to the correct copy of cln-config, and remove the file\n");
  93. printf("*** config.cache before re-running configure\n");
  94. return 1;
  95. }
  96. }
  97. ],, no_cln=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  98. CPPFLAGS="$ac_save_CPPFLAGS"
  99. LIBS="$ac_save_LIBS"
  100. fi
  101. fi
  102. if test "x$no_cln" = x ; then
  103. AC_MSG_RESULT(yes)
  104. ifelse([$2], , :, [$2])
  105. else
  106. AC_MSG_RESULT(no)
  107. if test "$CLN_CONFIG" = "no" ; then
  108. echo "*** The cln-config script installed by CLN could not be found"
  109. echo "*** If CLN was installed in PREFIX, make sure PREFIX/bin is in"
  110. echo "*** your path, or set the CLN_CONFIG environment variable to the"
  111. echo "*** full path to cln-config."
  112. else
  113. if test -f conf.clntest ; then
  114. :
  115. else
  116. echo "*** Could not run CLN test program, checking why..."
  117. CPPFLAGS="$CFLAGS $LIBCLN_CPPFLAGS"
  118. LIBS="$LIBS $LIBCLN_LIBS"
  119. AC_TRY_LINK([
  120. #include <stdio.h>
  121. #include <cln/cln.h>
  122. ], [ return 0; ],
  123. [ echo "*** The test program compiled, but did not run. This usually means"
  124. echo "*** that the run-time linker is not finding CLN or finding the wrong"
  125. echo "*** version of CLN. If it is not finding CLN, you'll need to set your"
  126. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  127. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  128. echo "*** is required on your system"
  129. echo "***"
  130. echo "*** If you have an old version installed, it is best to remove it, although"
  131. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  132. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  133. echo "*** exact error that occured. This usually means CLN was incorrectly installed"
  134. echo "*** or that you have moved CLN since it was installed. In the latter case, you"
  135. echo "*** may want to edit the cln-config script: $CLN_CONFIG" ])
  136. CPPFLAGS="$ac_save_CPPFLAGS"
  137. LIBS="$ac_save_LIBS"
  138. fi
  139. fi
  140. LIBCLN_CPPFLAGS=""
  141. LIBCLN_LIBS=""
  142. ifelse([$3], , :, [$3])
  143. fi
  144. AC_SUBST(LIBCLN_CPPFLAGS)
  145. AC_SUBST(LIBCLN_LIBS)
  146. rm -f conf.clntest
  147. ])