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.

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