configure.ac 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. # configure.ac: Configure script for Scute.
  2. # Copyright (C) 2006 g10 Code GmbH
  3. #
  4. # This file is part of Scute.
  5. #
  6. # Scute is free software; you can redistribute it and/or modify it
  7. # under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # Scute is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. # General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Scute; if not, write to the Free Software Foundation,
  18. # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. #
  20. # In addition, as a special exception, g10 Code GmbH gives permission
  21. # to link this library: with the Mozilla Foundation's code for
  22. # Mozilla (or with modified versions of it that use the same license
  23. # as the "Mozilla" code), and distribute the linked executables. You
  24. # must obey the GNU General Public License in all respects for all of
  25. # the code used other than "Mozilla". If you modify this file, you
  26. # may extend this exception to your version of the file, but you are
  27. # not obligated to do so. If you do not wish to do so, delete this
  28. # exception statement from your version.
  29. # Process this file with autoconf to produce a configure script.
  30. AC_PREREQ(2.59)
  31. min_automake_version="1.9.3"
  32. # Version number: Remember to change it immediately *after* a release.
  33. # Make sure to run "svn up" before a "make dist".
  34. # See below for the LT versions.
  35. #
  36. # The CVS version is usually the next intended release version with
  37. # the string "-cvs" appended. The reason for this is that tests for a
  38. # specific feature can already be done under the assumption that the
  39. # CVS version is the most recent one in a branch. To disable the CVS
  40. # version for the real release, just comment out the my_iscvs macro.
  41. # Note, that we are now using Subversion instead of CVS and append the
  42. # SVN revision number to the "cvs" suffix. To make this most useful
  43. # for snapshot releases please do an "svn up" right before recreating
  44. # the configure script, so that a proper revision number for all files
  45. # is available when running a "make distcheck".
  46. m4_define(my_version, [1.0.0])
  47. m4_define(my_iscvs, yes)
  48. AC_INIT([scute], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit(
  49. [$Revision: 1179 $],[Ra-z $:])]),
  50. [marcus@g10code.com])
  51. # LT Version numbers, remember to change them just *before* a release.
  52. # (Code changed: REVISION++)
  53. # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
  54. # (Interfaces added: AGE++)
  55. # (Interfaces removed/changed: AGE=0)
  56. #
  57. LIBSCUTE_LT_CURRENT=0
  58. LIBSCUTE_LT_AGE=0
  59. LIBSCUTE_LT_REVISION=0
  60. # Version numbers reported by the PKCS #11 module to its users.
  61. VERSION_MAJOR=1
  62. VERSION_MINOR=0
  63. NEED_GPG_ERROR_VERSION=0.7
  64. NEED_LIBASSUAN_VERSION=0.6.10
  65. NEED_GPGSM_VERSION=1.9.6
  66. # Some status variables to give feedback at the end of a configure run.
  67. have_gpg_error=no
  68. have_libassuan=no
  69. PACKAGE=$PACKAGE_NAME
  70. VERSION=$PACKAGE_VERSION
  71. AC_CONFIG_SRCDIR([src/cryptoki.h])
  72. AC_CONFIG_HEADER([config.h])
  73. dnl FIXME: Enable this with autoconf 2.59.
  74. dnl AC_CONFIG_MACRO_DIR(m4)
  75. AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
  76. AM_MAINTAINER_MODE
  77. AC_CANONICAL_HOST
  78. # Enable GNU extensions on systems that have them.
  79. AC_GNU_SOURCE
  80. AH_VERBATIM([_REENTRANT],
  81. [/* To allow the use of scute in multithreaded programs we have to use
  82. special features from the library. */
  83. #ifndef _REENTRANT
  84. # define _REENTRANT 1
  85. #endif])
  86. # Checks for programs.
  87. AC_PROG_CC
  88. AC_ARG_ENABLE(optimization,
  89. AC_HELP_STRING([--disable-optimization],
  90. [disable compiler optimization]),
  91. [if test $enableval = no ; then
  92. CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
  93. fi])
  94. AC_SUBST(LIBSCUTE_LT_CURRENT)
  95. AC_SUBST(LIBSCUTE_LT_AGE)
  96. AC_SUBST(LIBSCUTE_LT_REVISION)
  97. AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
  98. [Min. needed GPGSM version.])
  99. AC_SUBST(PACKAGE)
  100. AC_SUBST(VERSION)
  101. AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
  102. AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
  103. AC_DEFINE_UNQUOTED(VERSION_MAJOR, $VERSION_MAJOR, [Major version number])
  104. AC_DEFINE_UNQUOTED(VERSION_MINOR, $VERSION_MINOR, [Minor version number])
  105. # Don't default to build static libs.
  106. AC_DISABLE_STATIC
  107. AC_LIBTOOL_WIN32_DLL
  108. AC_LIBTOOL_RC
  109. AC_PROG_LIBTOOL
  110. # For now we hardcode the use of version scripts. It would be better
  111. # to write a test for this or even implement this within libtool.
  112. have_ld_version_script=no
  113. case "${host}" in
  114. *-*-linux*)
  115. have_ld_version_script=yes
  116. ;;
  117. *-*-gnu*)
  118. have_ld_version_script=yes
  119. ;;
  120. esac
  121. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  122. # Checks for libraries.
  123. # The error code library. Error codes are sent over the IPC layer and
  124. # have to be interpreted.
  125. AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
  126. have_gpg_error=yes, have_gpg_error=no)
  127. # The IPC library.
  128. AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_VERSION",
  129. have_libassuan=yes, have_libassuan=no)
  130. # GPGSM
  131. GPGSM_DEFAULT=no
  132. NO_OVERRIDE=no
  133. AC_ARG_WITH(gpgsm,
  134. AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
  135. GPGSM=$withval, NO_OVERRIDE=yes)
  136. if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
  137. GPGSM=
  138. NO_OVERRIDE=yes
  139. if test "$cross_compiling" != "yes"; then
  140. AC_PATH_PROG(GPGSM, gpgsm)
  141. fi
  142. if test -z "$GPGSM"; then
  143. GPGSM="$GPGSM_DEFAULT"
  144. fi
  145. fi
  146. if test "$GPGSM" = no; then
  147. if test "$NO_OVERRIDE" = "yes"; then
  148. if test "$cross_compiling" != "yes"; then
  149. AC_MSG_WARN([
  150. ***
  151. *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
  152. ***])
  153. else
  154. AC_MSG_ERROR([
  155. ***
  156. *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
  157. ***])
  158. fi
  159. fi
  160. else
  161. AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
  162. AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
  163. fi
  164. AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
  165. dnl Check for GPGSM version requirement.
  166. GPGSM_VERSION=unknown
  167. ok=maybe
  168. if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
  169. ok=no
  170. else
  171. if test "$cross_compiling" = "yes"; then
  172. AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
  173. ok=no
  174. else
  175. if test ! -x "$GPGSM"; then
  176. AC_MSG_WARN([GPGSM not executable, version check disabled])
  177. ok=no
  178. fi
  179. fi
  180. fi
  181. if test "$ok" = "maybe"; then
  182. AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
  183. req_major=`echo $NEED_GPGSM_VERSION | \
  184. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  185. req_minor=`echo $NEED_GPGSM_VERSION | \
  186. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  187. req_micro=`echo $NEED_GPGSM_VERSION | \
  188. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  189. gpgsm_version=`$GPGSM --version | grep ^gpgsm`
  190. major=`echo $gpgsm_version | \
  191. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  192. minor=`echo $gpgsm_version | \
  193. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  194. micro=`echo $gpgsm_version | \
  195. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  196. GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
  197. if test "$major" -gt "$req_major"; then
  198. ok=yes
  199. else
  200. if test "$major" -eq "$req_major"; then
  201. if test "$minor" -gt "$req_minor"; then
  202. ok=yes
  203. else
  204. if test "$minor" -eq "$req_minor"; then
  205. if test "$micro" -ge "$req_micro"; then
  206. ok=yes
  207. fi
  208. fi
  209. fi
  210. fi
  211. fi
  212. if test "$ok" = "yes"; then
  213. AC_MSG_RESULT(yes)
  214. else
  215. AC_MSG_RESULT(no)
  216. AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
  217. fi
  218. fi
  219. gpgsm_ok="$ok"
  220. # Checks for header files.
  221. AC_HEADER_STDC
  222. AC_CHECK_HEADERS([stdlib.h string.h])
  223. # Checks for typedefs, structures, and compiler characteristics.
  224. AC_HEADER_STDBOOL
  225. AC_C_INLINE
  226. # Checks for library functions.
  227. AC_FUNC_REALLOC
  228. # Test if tests can be run
  229. ok=yes
  230. AM_CONDITIONAL(RUN_TESTS, test "$ok" = "yes")
  231. # Print errors here so that they are visible all
  232. # together and the user can acquire them all together.
  233. die=no
  234. if test "$have_gpg_error" = "no"; then
  235. die=yes
  236. AC_MSG_NOTICE([[
  237. ***
  238. *** You need libgpg-error to build this program.
  239. ** This library is for example available at
  240. *** ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
  241. *** (at least version $NEED_GPG_ERROR_VERSION is required.)
  242. ***]])
  243. fi
  244. if test "$have_libassuan" = "no"; then
  245. die=yes
  246. AC_MSG_NOTICE([[
  247. ***
  248. *** You need libassuan to build this program.
  249. *** This library is for example available at
  250. *** ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
  251. *** (at least version $NEED_LIBASSUAN_VERSION is required).
  252. ***]])
  253. fi
  254. if test "$die" = "yes"; then
  255. AC_MSG_ERROR([[
  256. ***
  257. *** Required libraries not found. Please consult the above messages
  258. *** and install them before running configure again.
  259. ***]])
  260. fi
  261. AC_CONFIG_FILES([Makefile
  262. src/Makefile
  263. tests/Makefile
  264. doc/manual/Makefile
  265. doc/Makefile])
  266. AC_OUTPUT