configure.ac 8.0 KB

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