configure.ac 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. # Version numbers reported by the PKCS #11 module to its users.
  34. VERSION_MAJOR=0
  35. VERSION_MINOR=0
  36. NEED_GPG_ERROR_VERSION=0.7
  37. NEED_LIBASSUAN_VERSION=0.6.10
  38. NEED_GPGSM_VERSION=1.9.6
  39. # Some status variables to give feedback at the end of a configure run.
  40. have_gpg_error=no
  41. have_libassuan=no
  42. AC_CONFIG_SRCDIR([src/cryptoki.h])
  43. AC_CONFIG_HEADER([config.h])
  44. dnl FIXME: Enable this with autoconf 2.59.
  45. dnl AC_CONFIG_MACRO_DIR(m4)
  46. AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
  47. AM_MAINTAINER_MODE
  48. AC_CANONICAL_HOST
  49. # Enable GNU extensions on systems that have them.
  50. AC_GNU_SOURCE
  51. AH_VERBATIM([_REENTRANT],
  52. [/* To allow the use of scute in multithreaded programs we have to use
  53. special features from the library. */
  54. #ifndef _REENTRANT
  55. # define _REENTRANT 1
  56. #endif])
  57. # Checks for programs.
  58. AC_PROG_CC
  59. # FIXME: We should support setting the CFLAGS by the user. But
  60. # -std=gnu99 is required.
  61. CFLAGS="-std=gnu99 -Wall -Wno-pointer-sign -g -O3"
  62. AC_ARG_ENABLE(optimization,
  63. AC_HELP_STRING([--disable-optimization],
  64. [disable compiler optimization]),
  65. [if test $enableval = no ; then
  66. CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
  67. fi])
  68. AC_SUBST(LIBSCUTE_LT_CURRENT)
  69. AC_SUBST(LIBSCUTE_LT_AGE)
  70. AC_SUBST(LIBSCUTE_LT_REVISION)
  71. AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
  72. [Min. needed GPGSM version.])
  73. AC_SUBST(PACKAGE)
  74. AC_SUBST(VERSION)
  75. AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
  76. AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
  77. AC_DEFINE_UNQUOTED(VERSION_MAJOR, $VERSION_MAJOR, [Major version number])
  78. AC_DEFINE_UNQUOTED(VERSION_MINOR, $VERSION_MINOR, [Minor version number])
  79. # Don't default to build static libs.
  80. AC_DISABLE_STATIC
  81. AC_LIBTOOL_WIN32_DLL
  82. AC_LIBTOOL_RC
  83. AC_PROG_LIBTOOL
  84. # For now we hardcode the use of version scripts. It would be better
  85. # to write a test for this or even implement this within libtool.
  86. have_ld_version_script=no
  87. case "${host}" in
  88. *-*-linux*)
  89. have_ld_version_script=yes
  90. ;;
  91. *-*-gnu*)
  92. have_ld_version_script=yes
  93. ;;
  94. esac
  95. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  96. # Checks for libraries.
  97. # The error code library. Error codes are sent over the IPC layer and
  98. # have to be interpreted.
  99. AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
  100. have_gpg_error=yes, have_gpg_error=no)
  101. # The IPC library.
  102. AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_VERSION",
  103. have_libassuan=yes, have_libassuan=no)
  104. # GPGSM
  105. GPGSM_DEFAULT=no
  106. NO_OVERRIDE=no
  107. AC_ARG_WITH(gpgsm,
  108. AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
  109. GPGSM=$withval, NO_OVERRIDE=yes)
  110. if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
  111. GPGSM=
  112. NO_OVERRIDE=yes
  113. if test "$cross_compiling" != "yes"; then
  114. AC_PATH_PROG(GPGSM, gpgsm)
  115. fi
  116. if test -z "$GPGSM"; then
  117. GPGSM="$GPGSM_DEFAULT"
  118. fi
  119. fi
  120. if test "$GPGSM" = no; then
  121. if test "$NO_OVERRIDE" = "yes"; then
  122. if test "$cross_compiling" != "yes"; then
  123. AC_MSG_WARN([
  124. ***
  125. *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
  126. ***])
  127. else
  128. AC_MSG_ERROR([
  129. ***
  130. *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
  131. ***])
  132. fi
  133. fi
  134. else
  135. AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
  136. AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
  137. fi
  138. AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
  139. dnl Check for GPGSM version requirement.
  140. GPGSM_VERSION=unknown
  141. ok=maybe
  142. if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
  143. ok=no
  144. else
  145. if test "$cross_compiling" = "yes"; then
  146. AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
  147. ok=no
  148. else
  149. if test ! -x "$GPGSM"; then
  150. AC_MSG_WARN([GPGSM not executable, version check disabled])
  151. ok=no
  152. fi
  153. fi
  154. fi
  155. if test "$ok" = "maybe"; then
  156. AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
  157. req_major=`echo $NEED_GPGSM_VERSION | \
  158. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  159. req_minor=`echo $NEED_GPGSM_VERSION | \
  160. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  161. req_micro=`echo $NEED_GPGSM_VERSION | \
  162. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  163. gpgsm_version=`$GPGSM --version | grep ^gpgsm`
  164. major=`echo $gpgsm_version | \
  165. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  166. minor=`echo $gpgsm_version | \
  167. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  168. micro=`echo $gpgsm_version | \
  169. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  170. GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
  171. if test "$major" -gt "$req_major"; then
  172. ok=yes
  173. else
  174. if test "$major" -eq "$req_major"; then
  175. if test "$minor" -gt "$req_minor"; then
  176. ok=yes
  177. else
  178. if test "$minor" -eq "$req_minor"; then
  179. if test "$micro" -ge "$req_micro"; then
  180. ok=yes
  181. fi
  182. fi
  183. fi
  184. fi
  185. fi
  186. if test "$ok" = "yes"; then
  187. AC_MSG_RESULT(yes)
  188. else
  189. AC_MSG_RESULT(no)
  190. AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
  191. fi
  192. fi
  193. gpgsm_ok="$ok"
  194. # Checks for header files.
  195. AC_HEADER_STDC
  196. AC_CHECK_HEADERS([stdlib.h string.h])
  197. # Checks for typedefs, structures, and compiler characteristics.
  198. AC_HEADER_STDBOOL
  199. AC_C_INLINE
  200. # Checks for library functions.
  201. AC_FUNC_REALLOC
  202. # Test if tests can be run
  203. ok=yes
  204. AM_CONDITIONAL(RUN_TESTS, test "$ok" = "yes")
  205. # Print errors here so that they are visible all
  206. # together and the user can acquire them all together.
  207. die=no
  208. if test "$have_gpg_error" = "no"; then
  209. die=yes
  210. AC_MSG_NOTICE([[
  211. ***
  212. *** You need libgpg-error to build this program.
  213. ** This library is for example available at
  214. *** ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
  215. *** (at least version $NEED_GPG_ERROR_VERSION is required.)
  216. ***]])
  217. fi
  218. if test "$have_libassuan" = "no"; then
  219. die=yes
  220. AC_MSG_NOTICE([[
  221. ***
  222. *** You need libassuan to build this program.
  223. *** This library is for example available at
  224. *** ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
  225. *** (at least version $NEED_LIBASSUAN_VERSION is required).
  226. ***]])
  227. fi
  228. if test "$die" = "yes"; then
  229. AC_MSG_ERROR([[
  230. ***
  231. *** Required libraries not found. Please consult the above messages
  232. *** and install them before running configure again.
  233. ***]])
  234. fi
  235. AC_CONFIG_FILES([Makefile
  236. include/Makefile
  237. src/Makefile
  238. tests/Makefile])
  239. AC_OUTPUT