gpgme.m4 6.0 KB

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