gpgme.m4 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. # gpgme.m4 - autoconf macro to detect GPGME.
  2. # Copyright (C) 2002, 2003, 2004 g10 Code GmbH
  3. #
  4. # This file is free software; as a special exception the author gives
  5. # unlimited permission to copy and/or distribute it, with or without
  6. # modifications, as long as this notice is preserved.
  7. #
  8. # This file is distributed in the hope that it will be useful, but
  9. # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
  10. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. AC_DEFUN([_AM_PATH_GPGME_CONFIG],
  12. [ AC_ARG_WITH(gpgme-prefix,
  13. AC_HELP_STRING([--with-gpgme-prefix=PFX],
  14. [prefix where GPGME is installed (optional)]),
  15. gpgme_config_prefix="$withval", gpgme_config_prefix="")
  16. if test "x$gpgme_config_prefix" != x ; then
  17. GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config"
  18. fi
  19. AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
  20. if test "$GPGME_CONFIG" != "no" ; then
  21. gpgme_version=`$GPGME_CONFIG --version`
  22. fi
  23. gpgme_version_major=`echo $gpgme_version | \
  24. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  25. gpgme_version_minor=`echo $gpgme_version | \
  26. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  27. gpgme_version_micro=`echo $gpgme_version | \
  28. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  29. ])
  30. dnl AM_PATH_GPGME([MINIMUM-VERSION,
  31. dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
  32. dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS.
  33. dnl
  34. AC_DEFUN([AM_PATH_GPGME],
  35. [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
  36. tmp=ifelse([$1], ,1:0.4.2,$1)
  37. if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
  38. req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
  39. min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
  40. else
  41. req_gpgme_api=0
  42. min_gpgme_version="$tmp"
  43. fi
  44. AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
  45. ok=no
  46. if test "$GPGME_CONFIG" != "no" ; then
  47. req_major=`echo $min_gpgme_version | \
  48. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  49. req_minor=`echo $min_gpgme_version | \
  50. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  51. req_micro=`echo $min_gpgme_version | \
  52. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  53. if test "$gpgme_version_major" -gt "$req_major"; then
  54. ok=yes
  55. else
  56. if test "$gpgme_version_major" -eq "$req_major"; then
  57. if test "$gpgme_version_minor" -gt "$req_minor"; then
  58. ok=yes
  59. else
  60. if test "$gpgme_version_minor" -eq "$req_minor"; then
  61. if test "$gpgme_version_micro" -ge "$req_micro"; then
  62. ok=yes
  63. fi
  64. fi
  65. fi
  66. fi
  67. fi
  68. fi
  69. if test $ok = yes; then
  70. # If we have a recent GPGME, we should also check that the
  71. # API is compatible.
  72. if test "$req_gpgme_api" -gt 0 ; then
  73. tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
  74. if test "$tmp" -gt 0 ; then
  75. if test "$req_gpgme_api" -ne "$tmp" ; then
  76. ok=no
  77. fi
  78. fi
  79. fi
  80. fi
  81. if test $ok = yes; then
  82. GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
  83. GPGME_LIBS=`$GPGME_CONFIG --libs`
  84. AC_MSG_RESULT(yes)
  85. ifelse([$2], , :, [$2])
  86. else
  87. GPGME_CFLAGS=""
  88. GPGME_LIBS=""
  89. AC_MSG_RESULT(no)
  90. ifelse([$3], , :, [$3])
  91. fi
  92. AC_SUBST(GPGME_CFLAGS)
  93. AC_SUBST(GPGME_LIBS)
  94. ])
  95. dnl AM_PATH_GPGME_PTH([MINIMUM-VERSION,
  96. dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
  97. dnl Test for libgpgme and define GPGME_PTH_CFLAGS and GPGME_PTH_LIBS.
  98. dnl
  99. AC_DEFUN([AM_PATH_GPGME_PTH],
  100. [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
  101. tmp=ifelse([$1], ,1:0.4.2,$1)
  102. if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
  103. req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
  104. min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
  105. else
  106. req_gpgme_api=0
  107. min_gpgme_version="$tmp"
  108. fi
  109. AC_MSG_CHECKING(for GPGME Pth - version >= $min_gpgme_version)
  110. ok=no
  111. if test "$GPGME_CONFIG" != "no" ; then
  112. if `$GPGME_CONFIG --thread=pth 2> /dev/null` ; then
  113. req_major=`echo $min_gpgme_version | \
  114. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  115. req_minor=`echo $min_gpgme_version | \
  116. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  117. req_micro=`echo $min_gpgme_version | \
  118. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  119. if test "$gpgme_version_major" -gt "$req_major"; then
  120. ok=yes
  121. else
  122. if test "$gpgme_version_major" -eq "$req_major"; then
  123. if test "$gpgme_version_minor" -gt "$req_minor"; then
  124. ok=yes
  125. else
  126. if test "$gpgme_version_minor" -eq "$req_minor"; then
  127. if test "$gpgme_version_micro" -ge "$req_micro"; then
  128. ok=yes
  129. fi
  130. fi
  131. fi
  132. fi
  133. fi
  134. fi
  135. fi
  136. if test $ok = yes; then
  137. # If we have a recent GPGME, we should also check that the
  138. # API is compatible.
  139. if test "$req_gpgme_api" -gt 0 ; then
  140. tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
  141. if test "$tmp" -gt 0 ; then
  142. if test "$req_gpgme_api" -ne "$tmp" ; then
  143. ok=no
  144. fi
  145. fi
  146. fi
  147. fi
  148. if test $ok = yes; then
  149. GPGME_PTH_CFLAGS=`$GPGME_CONFIG --thread=pth --cflags`
  150. GPGME_PTH_LIBS=`$GPGME_CONFIG --thread=pth --libs`
  151. AC_MSG_RESULT(yes)
  152. ifelse([$2], , :, [$2])
  153. else
  154. GPGME_PTH_CFLAGS=""
  155. GPGME_PTH_LIBS=""
  156. AC_MSG_RESULT(no)
  157. ifelse([$3], , :, [$3])
  158. fi
  159. AC_SUBST(GPGME_PTH_CFLAGS)
  160. AC_SUBST(GPGME_PTH_LIBS)
  161. ])
  162. dnl AM_PATH_GPGME_PTHREAD([MINIMUM-VERSION,
  163. dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
  164. dnl Test for libgpgme and define GPGME_PTHREAD_CFLAGS
  165. dnl and GPGME_PTHREAD_LIBS.
  166. dnl
  167. AC_DEFUN([AM_PATH_GPGME_PTHREAD],
  168. [ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
  169. tmp=ifelse([$1], ,1:0.4.2,$1)
  170. if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
  171. req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
  172. min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
  173. else
  174. req_gpgme_api=0
  175. min_gpgme_version="$tmp"
  176. fi
  177. AC_MSG_CHECKING(for GPGME pthread - version >= $min_gpgme_version)
  178. ok=no
  179. if test "$GPGME_CONFIG" != "no" ; then
  180. if `$GPGME_CONFIG --thread=pthread 2> /dev/null` ; then
  181. req_major=`echo $min_gpgme_version | \
  182. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  183. req_minor=`echo $min_gpgme_version | \
  184. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  185. req_micro=`echo $min_gpgme_version | \
  186. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  187. if test "$gpgme_version_major" -gt "$req_major"; then
  188. ok=yes
  189. else
  190. if test "$gpgme_version_major" -eq "$req_major"; then
  191. if test "$gpgme_version_minor" -gt "$req_minor"; then
  192. ok=yes
  193. else
  194. if test "$gpgme_version_minor" -eq "$req_minor"; then
  195. if test "$gpgme_version_micro" -ge "$req_micro"; then
  196. ok=yes
  197. fi
  198. fi
  199. fi
  200. fi
  201. fi
  202. fi
  203. fi
  204. if test $ok = yes; then
  205. # If we have a recent GPGME, we should also check that the
  206. # API is compatible.
  207. if test "$req_gpgme_api" -gt 0 ; then
  208. tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
  209. if test "$tmp" -gt 0 ; then
  210. if test "$req_gpgme_api" -ne "$tmp" ; then
  211. ok=no
  212. fi
  213. fi
  214. fi
  215. fi
  216. if test $ok = yes; then
  217. GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --thread=pthread --cflags`
  218. GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --thread=pthread --libs`
  219. AC_MSG_RESULT(yes)
  220. ifelse([$2], , :, [$2])
  221. else
  222. GPGME_PTHREAD_CFLAGS=""
  223. GPGME_PTHREAD_LIBS=""
  224. AC_MSG_RESULT(no)
  225. ifelse([$3], , :, [$3])
  226. fi
  227. AC_SUBST(GPGME_PTHREAD_CFLAGS)
  228. AC_SUBST(GPGME_PTHREAD_LIBS)
  229. ])