configure.ac 9.1 KB

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