configure.ac 9.2 KB

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