libprelude.m4 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. dnl Autoconf macros for libprelude
  2. dnl $id$
  3. # Modified for LIBPRELUDE -- Yoann Vandoorselaere
  4. # Modified for LIBGNUTLS -- nmav
  5. # Configure paths for LIBGCRYPT
  6. # Shamelessly stolen from the one of XDELTA by Owen Taylor
  7. # Werner Koch 99-12-09
  8. dnl AM_PATH_LIBPRELUDE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
  9. dnl Test for libprelude, and define LIBPRELUDE_PREFIX, LIBPRELUDE_CFLAGS, LIBPRELUDE_PTHREAD_CFLAGS,
  10. dnl LIBPRELUDE_LDFLAGS, and LIBPRELUDE_LIBS
  11. dnl
  12. AC_DEFUN([AM_PATH_LIBPRELUDE],
  13. [dnl
  14. dnl Get the cflags and libraries from the libprelude-config script
  15. dnl
  16. AC_ARG_WITH(libprelude-prefix, [AS_HELP_STRING([--with-libprelude-prefix=PFX],
  17. [Prefix where libprelude is installed (optional)])],
  18. libprelude_config_prefix="$withval", libprelude_config_prefix="")
  19. if test x$libprelude_config_prefix != x ; then
  20. if test x${LIBPRELUDE_CONFIG+set} != xset ; then
  21. LIBPRELUDE_CONFIG=$libprelude_config_prefix/bin/libprelude-config
  22. fi
  23. fi
  24. AC_PATH_PROG(LIBPRELUDE_CONFIG, libprelude-config, no)
  25. min_libprelude_version=ifelse([$1], ,0.1.0,$1)
  26. AC_MSG_CHECKING(for libprelude - version >= $min_libprelude_version)
  27. no_libprelude=""
  28. if test "$LIBPRELUDE_CONFIG" = "no" ; then
  29. no_libprelude=yes
  30. else
  31. LIBPRELUDE_CFLAGS=`$LIBPRELUDE_CONFIG $libprelude_config_args --cflags`
  32. LIBPRELUDE_PTHREAD_CFLAGS=`$LIBPRELUDE_CONFIG $libprelude_config_args --pthread-cflags`
  33. LIBPRELUDE_LDFLAGS=`$LIBPRELUDE_CONFIG $libprelude_config_args --ldflags`
  34. LIBPRELUDE_LIBS=`$LIBPRELUDE_CONFIG $libprelude_config_args --libs`
  35. LIBPRELUDE_PREFIX=`$LIBPRELUDE_CONFIG $libprelude_config_args --prefix`
  36. LIBPRELUDE_CONFIG_PREFIX=`$LIBPRELUDE_CONFIG $libprelude_config_args --config-prefix`
  37. libprelude_config_version=`$LIBPRELUDE_CONFIG $libprelude_config_args --version`
  38. ac_save_CFLAGS="$CFLAGS"
  39. ac_save_LDFLAGS="$LDFLAGS"
  40. ac_save_LIBS="$LIBS"
  41. CFLAGS="$CFLAGS $LIBPRELUDE_CFLAGS"
  42. LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS"
  43. LIBS="$LIBS $LIBPRELUDE_LIBS"
  44. dnl
  45. dnl Now check if the installed libprelude is sufficiently new. Also sanity
  46. dnl checks the results of libprelude-config to some extent
  47. dnl
  48. rm -f conf.libpreludetest
  49. AC_RUN_IFELSE([
  50. AC_LANG_SOURCE([[
  51. #include <stdio.h>
  52. #include <stdlib.h>
  53. #include <string.h>
  54. #include <libprelude/prelude.h>
  55. int
  56. main ()
  57. {
  58. system ("touch conf.libpreludetest");
  59. if( strcmp( prelude_check_version(NULL), "$libprelude_config_version" ) )
  60. {
  61. printf("\n*** 'libprelude-config --version' returned %s, but LIBPRELUDE (%s)\n",
  62. "$libprelude_config_version", prelude_check_version(NULL) );
  63. printf("*** was found! If libprelude-config was correct, then it is best\n");
  64. printf("*** to remove the old version of LIBPRELUDE. You may also be able to fix the error\n");
  65. printf("*** by modifying your LD_LIBRARY_PATH environment variable, or by editing\n");
  66. printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
  67. printf("*** required on your system.\n");
  68. printf("*** If libprelude-config was wrong, set the environment variable LIBPRELUDE_CONFIG\n");
  69. printf("*** to point to the correct copy of libprelude-config, and remove the file config.cache\n");
  70. printf("*** before re-running configure\n");
  71. }
  72. else if ( strcmp(prelude_check_version(NULL), LIBPRELUDE_VERSION ) )
  73. {
  74. printf("\n*** LIBPRELUDE header file (version %s) does not match\n", LIBPRELUDE_VERSION);
  75. printf("*** library (version %s)\n", prelude_check_version(NULL) );
  76. }
  77. else
  78. {
  79. if ( prelude_check_version( "$min_libprelude_version" ) )
  80. {
  81. return 0;
  82. }
  83. else
  84. {
  85. printf("no\n*** An old version of LIBPRELUDE (%s) was found.\n",
  86. prelude_check_version(NULL) );
  87. printf("*** You need a version of LIBPRELUDE newer than %s. The latest version of\n",
  88. "$min_libprelude_version" );
  89. printf("*** LIBPRELUDE is always available from http://www.prelude-ids.org/download/releases.\n");
  90. printf("*** \n");
  91. printf("*** If you have already installed a sufficiently new version, this error\n");
  92. printf("*** probably means that the wrong copy of the libprelude-config shell script is\n");
  93. printf("*** being found. The easiest way to fix this is to remove the old version\n");
  94. printf("*** of LIBPRELUDE, but you can also set the LIBPRELUDE_CONFIG environment to point to the\n");
  95. printf("*** correct copy of libprelude-config. (In this case, you will have to\n");
  96. printf("*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf\n");
  97. printf("*** so that the correct libraries are found at run-time))\n");
  98. }
  99. }
  100. return 1;
  101. }
  102. ]])],[],[no_libprelude=yes],[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  103. CFLAGS="$ac_save_CFLAGS"
  104. LIBS="$ac_save_LIBS"
  105. LDFLAGS="$ac_save_LDFLAGS"
  106. fi
  107. if test "x$no_libprelude" = x ; then
  108. AC_MSG_RESULT(yes)
  109. ifelse([$2], , :, [$2])
  110. else
  111. if test -f conf.libpreludetest ; then
  112. :
  113. else
  114. AC_MSG_RESULT(no)
  115. fi
  116. if test "$LIBPRELUDE_CONFIG" = "no" ; then
  117. if test x$libprelude_config_prefix != x ; then
  118. echo "*** The libprelude-config script installed by LIBPRELUDE could not be found"
  119. echo "*** If LIBPRELUDE was installed in PREFIX, make sure PREFIX/bin is in"
  120. echo "*** your path, or set the LIBPRELUDE_CONFIG environment variable to the"
  121. echo "*** full path to libprelude-config."
  122. fi
  123. else
  124. if test -f conf.libpreludetest ; then
  125. :
  126. else
  127. echo "*** Could not run libprelude test program, checking why..."
  128. CFLAGS="$CFLAGS $LIBPRELUDE_CFLAGS"
  129. LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS"
  130. LIBS="$LIBS $LIBPRELUDE_LIBS"
  131. AC_LINK_IFELSE([
  132. AC_LANG_PROGRAM([[
  133. #include <stdio.h>
  134. #include <stdlib.h>
  135. #include <string.h>
  136. #include <libprelude/prelude.h>
  137. ]],
  138. [[ return !!prelude_check_version(NULL); ]])],
  139. [ echo "*** The test program compiled, but did not run. This usually means"
  140. echo "*** that the run-time linker is not finding LIBPRELUDE or finding the wrong"
  141. echo "*** version of LIBPRELUDE. If it is not finding LIBPRELUDE, you'll need to set your"
  142. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  143. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  144. echo "*** is required on your system"
  145. echo "***"
  146. echo "*** If you have an old version installed, it is best to remove it, although"
  147. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
  148. echo "***" ],
  149. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  150. echo "*** exact error that occurred. This usually means LIBPRELUDE was incorrectly installed"
  151. echo "*** or that you have moved LIBPRELUDE since it was installed. In the latter case, you"
  152. echo "*** may want to edit the libprelude-config script: $LIBPRELUDE_CONFIG" ])
  153. CFLAGS="$ac_save_CFLAGS"
  154. LDFLAGS="$ac_save_LDFLAGS"
  155. LIBS="$ac_save_LIBS"
  156. fi
  157. fi
  158. LIBPRELUDE_CFLAGS=""
  159. LIBPRELUDE_LDFLAGS=""
  160. LIBPRELUDE_LIBS=""
  161. ifelse([$3], , :, [$3])
  162. fi
  163. rm -f conf.libpreludetest
  164. AC_SUBST(LIBPRELUDE_CFLAGS)
  165. AC_SUBST(LIBPRELUDE_PTHREAD_CFLAGS)
  166. AC_SUBST(LIBPRELUDE_LDFLAGS)
  167. AC_SUBST(LIBPRELUDE_LIBS)
  168. AC_SUBST(LIBPRELUDE_PREFIX)
  169. AC_SUBST(LIBPRELUDE_CONFIG_PREFIX)
  170. ])
  171. dnl *-*wedit:notab*-* Please keep this as the last line.