2
0

libgnutls.m4 6.8 KB

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