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.

159 lines
7.9 KiB

  1. # Configure paths for the CLN library
  2. # Richard Kreckel 12/4/2000
  3. # borrowed 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_CLN([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  10. dnl Test for installed CLN library, and define CLN_CPPFLAGS and CLN_LIBS
  11. dnl
  12. AC_DEFUN(AC_PATH_CLN,
  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. cln_min_version=ifelse([$1], ,1.1.0,$1)
  36. AC_MSG_CHECKING(for CLN - version >= $cln_min_version)
  37. if test "$CLN_CONFIG" = "no" ; then
  38. AC_MSG_RESULT(no)
  39. echo "*** The cln-config script installed by CLN could not be found"
  40. echo "*** If CLN was installed in PREFIX, make sure PREFIX/bin is in"
  41. echo "*** your path, or set the CLN_CONFIG environment variable to the"
  42. echo "*** full path to cln-config."
  43. ifelse([$3], , :, [$3])
  44. else
  45. dnl Parse required version and the result of cln-config.
  46. cln_min_major_version=`echo $cln_min_version | \
  47. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  48. cln_min_minor_version=`echo $cln_min_version | \
  49. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  50. cln_min_micro_version=`echo $cln_min_version | \
  51. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  52. CLN_CPPFLAGS=`$CLN_CONFIG $cln_config_args --cppflags`
  53. CLN_LIBS=`$CLN_CONFIG $cln_config_args --libs`
  54. cln_config_major_version=`$CLN_CONFIG $cln_config_args --version | \
  55. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  56. cln_config_minor_version=`$CLN_CONFIG $cln_config_args --version | \
  57. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  58. cln_config_micro_version=`$CLN_CONFIG $cln_config_args --version | \
  59. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  60. dnl Check if the installed CLN is sufficiently new according to cln-config.
  61. if test \( $cln_config_major_version -lt $cln_min_major_version \) -o \
  62. \( $cln_config_major_version -eq $cln_min_major_version -a $cln_config_minor_version -lt $cln_min_minor_version \) -o \
  63. \( $cln_config_major_version -eq $cln_min_major_version -a $cln_config_minor_version -eq $cln_min_minor_version -a $cln_config_micro_version -lt $cln_min_micro_version \); then
  64. echo -e "\n*** 'cln-config --version' returned $cln_config_major_version.$cln_config_minor_version.$cln_config_micro_version, but the minimum version"
  65. echo "*** of CLN required is $cln_min_major_version.$cln_min_minor_version.$cln_min_micro_version. If cln-config is correct, then it is"
  66. echo "*** best to upgrade to the required version."
  67. echo "*** If cln-config was wrong, set the environment variable CLN_CONFIG"
  68. echo "*** to point to the correct copy of cln-config, and remove the file"
  69. echo "*** config.cache before re-running configure."
  70. ifelse([$3], , :, [$3])
  71. else
  72. dnl The versions match so far. Now do a sanity check: Does the result of cln-config
  73. dnl match the version of the headers and the version built into the library, too?
  74. no_cln=""
  75. if test "x$enable_clntest" = "xyes" ; then
  76. ac_save_CPPFLAGS="$CPPFLAGS"
  77. ac_save_LIBS="$LIBS"
  78. CPPFLAGS="$CPPFLAGS $CLN_CPPFLAGS"
  79. LIBS="$LIBS $CLN_LIBS"
  80. rm -f conf.clntest
  81. AC_TRY_RUN([
  82. #include <stdio.h>
  83. #include <string.h>
  84. #include <cln/version.h>
  85. /* we do not #include <stdlib.h> because autoconf in C++ mode inserts a
  86. prototype for exit() that conflicts with the one in stdlib.h */
  87. extern "C" int system(const char *);
  88. int main(void)
  89. {
  90. int major, minor, micro;
  91. char *tmp_version;
  92. system("touch conf.clntest");
  93. if ((CL_VERSION_MAJOR != $cln_config_major_version) ||
  94. (CL_VERSION_MINOR != $cln_config_minor_version) ||
  95. (CL_VERSION_PATCHLEVEL != $cln_config_micro_version)) {
  96. 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);
  97. printf("*** corresponds to %d.%d.%d. This mismatch suggests your installation of CLN\n", CL_VERSION_MAJOR, CL_VERSION_MINOR, CL_VERSION_PATCHLEVEL);
  98. printf("*** is corrupted or you have specified some wrong -I compiler flags.\n");
  99. printf("*** Please inquire and consider reinstalling CLN.\n");
  100. return 1;
  101. }
  102. if ((cln::version_major != $cln_config_major_version) ||
  103. (cln::version_minor != $cln_config_minor_version) ||
  104. (cln::version_patchlevel != $cln_config_micro_version)) {
  105. printf("\n*** 'cln-config --version' returned %d.%d.%d, but the library I found\n", $cln_config_major_version, $cln_config_minor_version, $cln_config_micro_version);
  106. printf("*** corresponds to %d.%d.%d. This mismatch suggests your installation of CLN\n", cln::version_major, cln::version_minor, cln::version_patchlevel);
  107. printf("*** is corrupted or you have specified some wrong -L compiler flags.\n");
  108. printf("*** Please inquire and consider reinstalling CLN.\n");
  109. return 1;
  110. }
  111. return 0;
  112. }
  113. ],, no_cln=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  114. CPPFLAGS="$ac_save_CPPFLAGS"
  115. LIBS="$ac_save_LIBS"
  116. fi
  117. if test "x$no_cln" = x ; then
  118. AC_MSG_RESULT([yes, `$CLN_CONFIG $cln_config_args --version`])
  119. ifelse([$2], , :, [$2])
  120. else
  121. AC_MSG_RESULT(no)
  122. if test ! -f conf.clntest ; then
  123. echo "*** Could not run CLN test program, checking why..."
  124. CPPFLAGS="$CFLAGS $CLN_CPPFLAGS"
  125. LIBS="$LIBS $CLN_LIBS"
  126. AC_TRY_LINK([
  127. #include <stdio.h>
  128. #include <cln/version.h>
  129. ], [ return 0; ],
  130. [ echo "*** The test program compiled, but did not run. This usually means"
  131. echo "*** that the run-time linker is not finding CLN or finding the wrong"
  132. echo "*** version of CLN. If it is not finding CLN, you'll need to set your"
  133. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  134. echo "*** to the installed location. Also, make sure you have run ldconfig if that"
  135. echo "*** is required on your system."],
  136. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  137. echo "*** exact error that occured. This usually means CLN was incorrectly installed"
  138. echo "*** or that you have moved CLN since it was installed. In the latter case, you"
  139. echo "*** may want to edit the cln-config script: $CLN_CONFIG." ])
  140. CPPFLAGS="$ac_save_CPPFLAGS"
  141. LIBS="$ac_save_LIBS"
  142. fi
  143. CLN_CPPFLAGS=""
  144. CLN_LIBS=""
  145. ifelse([$3], , :, [$3])
  146. fi
  147. fi
  148. fi
  149. AC_SUBST(CLN_CPPFLAGS)
  150. AC_SUBST(CLN_LIBS)
  151. rm -f conf.clntest
  152. ])