configure.ac 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ(2.59)
  4. min_automake_version="1.9.3"
  5. # Version number: Remember to change it immediately *after* a release.
  6. # Make sure to run "svn up" before a "make dist".
  7. # See below for the LT versions.
  8. #
  9. # The CVS version is usually the next intended release version with
  10. # the string "-cvs" appended. The reason for this is that tests for a
  11. # specific feature can already be done under the assumption that the
  12. # CVS version is the most recent one in a branch. To disable the CVS
  13. # version for the real release, just comment out the my_iscvs macro.
  14. # Note, that we are now using Subversion instead of CVS and append the
  15. # SVN revision number to the "cvs" suffix. To make this most useful
  16. # for snapshot releases please do an "svn up" right before recreating
  17. # the configure script, so that a proper revision number for all files
  18. # is available when running a "make distcheck".
  19. m4_define(my_version, [0.0.0])
  20. m4_define(my_iscvs, yes)
  21. AC_INIT([scute], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit(
  22. [$Revision: 1179 $],[Ra-z $:])]),
  23. [marcus@g10code.com])
  24. # LT Version numbers, remember to change them just *before* a release.
  25. # (Code changed: REVISION++)
  26. # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
  27. # (Interfaces added: AGE++)
  28. # (Interfaces removed/changed: AGE=0)
  29. #
  30. LIBSCUTE_LT_CURRENT=0
  31. LIBSCUTE_LT_AGE=0
  32. LIBSCUTE_LT_REVISION=0
  33. NEED_GPG_ERROR_VERSION=0.7
  34. NEED_LIBASSUAN_VERSION=0.6.10
  35. NEED_GPGSM_VERSION=1.9.6
  36. # Some status variables to give feedback at the end of a configure run.
  37. have_gpg_error=no
  38. have_libassuan=no
  39. AC_CONFIG_SRCDIR([src/cryptoki.h])
  40. AC_CONFIG_HEADER([config.h])
  41. dnl FIXME: Enable this with autoconf 2.59.
  42. dnl AC_CONFIG_MACRO_DIR(m4)
  43. AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
  44. AM_MAINTAINER_MODE
  45. AC_CANONICAL_HOST
  46. # Enable GNU extensions on systems that have them.
  47. AC_GNU_SOURCE
  48. AH_VERBATIM([_REENTRANT],
  49. [/* To allow the use of scute in multithreaded programs we have to use
  50. special features from the library. */
  51. #ifndef _REENTRANT
  52. # define _REENTRANT 1
  53. #endif])
  54. # Checks for programs.
  55. AC_PROG_CC
  56. # FIXME: We should support setting the CFLAGS by the user. But
  57. # -std=gnu99 is required.
  58. CFLAGS="-std=gnu99 -Wall -Wno-pointer-sign -g -O3"
  59. AC_SUBST(LIBSCUTE_LT_CURRENT)
  60. AC_SUBST(LIBSCUTE_LT_AGE)
  61. AC_SUBST(LIBSCUTE_LT_REVISION)
  62. AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
  63. [Min. needed GPGSM version.])
  64. AC_SUBST(PACKAGE)
  65. AC_SUBST(VERSION)
  66. AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
  67. AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
  68. # Don't default to build static libs.
  69. AC_DISABLE_STATIC
  70. AC_LIBTOOL_WIN32_DLL
  71. AC_LIBTOOL_RC
  72. AC_PROG_LIBTOOL
  73. # For now we hardcode the use of version scripts. It would be better
  74. # to write a test for this or even implement this within libtool.
  75. have_ld_version_script=no
  76. case "${host}" in
  77. *-*-linux*)
  78. have_ld_version_script=yes
  79. ;;
  80. *-*-gnu*)
  81. have_ld_version_script=yes
  82. ;;
  83. esac
  84. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  85. # Checks for libraries.
  86. # The error code library. Error codes are sent over the IPC layer and
  87. # have to be interpreted.
  88. AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
  89. have_gpg_error=yes, have_gpg_error=no)
  90. # The IPC library.
  91. AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_VERSION",
  92. have_libassuan=yes, have_libassuan=no)
  93. # GPGSM
  94. GPGSM_DEFAULT=no
  95. NO_OVERRIDE=no
  96. AC_ARG_WITH(gpgsm,
  97. AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
  98. GPGSM=$withval, NO_OVERRIDE=yes)
  99. if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
  100. GPGSM=
  101. NO_OVERRIDE=yes
  102. if test "$cross_compiling" != "yes"; then
  103. AC_PATH_PROG(GPGSM, gpgsm)
  104. fi
  105. if test -z "$GPGSM"; then
  106. GPGSM="$GPGSM_DEFAULT"
  107. fi
  108. fi
  109. if test "$GPGSM" = no; then
  110. if test "$NO_OVERRIDE" = "yes"; then
  111. if test "$cross_compiling" != "yes"; then
  112. AC_MSG_WARN([
  113. ***
  114. *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
  115. ***])
  116. else
  117. AC_MSG_ERROR([
  118. ***
  119. *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
  120. ***])
  121. fi
  122. fi
  123. else
  124. AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
  125. AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
  126. fi
  127. AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
  128. dnl Check for GPGSM version requirement.
  129. GPGSM_VERSION=unknown
  130. ok=maybe
  131. if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
  132. ok=no
  133. else
  134. if test "$cross_compiling" = "yes"; then
  135. AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
  136. ok=no
  137. else
  138. if test ! -x "$GPGSM"; then
  139. AC_MSG_WARN([GPGSM not executable, version check disabled])
  140. ok=no
  141. fi
  142. fi
  143. fi
  144. if test "$ok" = "maybe"; then
  145. AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
  146. req_major=`echo $NEED_GPGSM_VERSION | \
  147. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  148. req_minor=`echo $NEED_GPGSM_VERSION | \
  149. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  150. req_micro=`echo $NEED_GPGSM_VERSION | \
  151. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  152. gpgsm_version=`$GPGSM --version | grep ^gpgsm`
  153. major=`echo $gpgsm_version | \
  154. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  155. minor=`echo $gpgsm_version | \
  156. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  157. micro=`echo $gpgsm_version | \
  158. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  159. GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
  160. if test "$major" -gt "$req_major"; then
  161. ok=yes
  162. else
  163. if test "$major" -eq "$req_major"; then
  164. if test "$minor" -gt "$req_minor"; then
  165. ok=yes
  166. else
  167. if test "$minor" -eq "$req_minor"; then
  168. if test "$micro" -ge "$req_micro"; then
  169. ok=yes
  170. fi
  171. fi
  172. fi
  173. fi
  174. fi
  175. if test "$ok" = "yes"; then
  176. AC_MSG_RESULT(yes)
  177. else
  178. AC_MSG_RESULT(no)
  179. AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
  180. fi
  181. fi
  182. gpgsm_ok="$ok"
  183. # Checks for header files.
  184. AC_HEADER_STDC
  185. AC_CHECK_HEADERS([stdlib.h string.h])
  186. # Checks for typedefs, structures, and compiler characteristics.
  187. AC_HEADER_STDBOOL
  188. AC_C_INLINE
  189. # Checks for library functions.
  190. AC_FUNC_REALLOC
  191. # Test if tests can be run
  192. ok=yes
  193. AM_CONDITIONAL(RUN_TESTS, test "$ok" = "yes")
  194. # Print errors here so that they are visible all
  195. # together and the user can acquire them all together.
  196. die=no
  197. if test "$have_gpg_error" = "no"; then
  198. die=yes
  199. AC_MSG_NOTICE([[
  200. ***
  201. *** You need libgpg-error to build this program.
  202. ** This library is for example available at
  203. *** ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
  204. *** (at least version $NEED_GPG_ERROR_VERSION is required.)
  205. ***]])
  206. fi
  207. if test "$have_libassuan" = "no"; then
  208. die=yes
  209. AC_MSG_NOTICE([[
  210. ***
  211. *** You need libassuan to build this program.
  212. *** This library is for example available at
  213. *** ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
  214. *** (at least version $NEED_LIBASSUAN_VERSION is required).
  215. ***]])
  216. fi
  217. if test "$die" = "yes"; then
  218. AC_MSG_ERROR([[
  219. ***
  220. *** Required libraries not found. Please consult the above messages
  221. *** and install them before running configure again.
  222. ***]])
  223. fi
  224. AC_CONFIG_FILES([Makefile
  225. include/Makefile
  226. src/Makefile
  227. tests/Makefile])
  228. AC_OUTPUT