configure.ac 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. # configure.ac: Configure script for Scute.
  2. # Copyright (C) 2006, 2007, 2008 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.2.0])
  47. m4_define(my_issvn, no)
  48. m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \
  49. || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))
  50. AC_INIT([scute],
  51. [my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision])],
  52. [marcus@g10code.com])
  53. # LT Version numbers, remember to change them just *before* a release.
  54. # (Code changed: REVISION++)
  55. # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
  56. # (Interfaces added: AGE++)
  57. # (Interfaces removed/changed: AGE=0)
  58. #
  59. LIBSCUTE_LT_CURRENT=0
  60. LIBSCUTE_LT_AGE=0
  61. LIBSCUTE_LT_REVISION=1
  62. # Version numbers reported by the PKCS #11 module to its users.
  63. VERSION_MAJOR=1
  64. VERSION_MINOR=0
  65. NEED_GPG_ERROR_VERSION=1.4
  66. NEED_LIBASSUAN_VERSION=0.6.10
  67. NEED_GPGSM_VERSION=1.9.6
  68. # Some status variables to give feedback at the end of a configure run.
  69. have_gpg_error=no
  70. have_libassuan=no
  71. BUILD_REVISION=svn_revision
  72. PACKAGE=$PACKAGE_NAME
  73. VERSION=$PACKAGE_VERSION
  74. AC_CONFIG_SRCDIR([src/cryptoki.h])
  75. AC_CONFIG_HEADER([config.h])
  76. dnl FIXME: Enable this with autoconf 2.59.
  77. dnl AC_CONFIG_MACRO_DIR(m4)
  78. AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
  79. AM_MAINTAINER_MODE
  80. AC_CANONICAL_HOST
  81. # Autobuilder support.
  82. AB_INIT
  83. # Enable GNU extensions on systems that have them.
  84. AC_GNU_SOURCE
  85. AH_VERBATIM([_REENTRANT],
  86. [/* To allow the use of scute in multithreaded programs we have to use
  87. special features from the library. */
  88. #ifndef _REENTRANT
  89. # define _REENTRANT 1
  90. #endif])
  91. # Checks for programs.
  92. AC_PROG_CC
  93. AC_ARG_ENABLE(optimization,
  94. AC_HELP_STRING([--disable-optimization],
  95. [disable compiler optimization]),
  96. [if test $enableval = no ; then
  97. CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
  98. fi])
  99. AC_SUBST(LIBSCUTE_LT_CURRENT)
  100. AC_SUBST(LIBSCUTE_LT_AGE)
  101. AC_SUBST(LIBSCUTE_LT_REVISION)
  102. AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
  103. [Min. needed GPGSM version.])
  104. AC_SUBST(PACKAGE)
  105. AC_SUBST(VERSION)
  106. AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
  107. AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
  108. AC_DEFINE_UNQUOTED(VERSION_MAJOR, $VERSION_MAJOR, [Major version number])
  109. AC_DEFINE_UNQUOTED(VERSION_MINOR, $VERSION_MINOR, [Minor version number])
  110. # Don't default to build static libs.
  111. AC_DISABLE_STATIC
  112. AC_LIBTOOL_WIN32_DLL
  113. AC_LIBTOOL_RC
  114. AC_PROG_LIBTOOL
  115. # For now we hardcode the use of version scripts. It would be better
  116. # to write a test for this or even implement this within libtool.
  117. have_ld_version_script=no
  118. case "${host}" in
  119. *-*-linux*)
  120. have_ld_version_script=yes
  121. ;;
  122. *-*-gnu*)
  123. have_ld_version_script=yes
  124. ;;
  125. esac
  126. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  127. GPGSM_DEFAULT=no
  128. GPG_AGENT_DEFAULT=no
  129. have_w32_system=no
  130. case "${host}" in
  131. *-mingw32*)
  132. # special stuff for Windoze NT
  133. GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
  134. GPG_AGENT_DEFAULT='c:\\gnupg\\gpg-agent.exe'
  135. have_w32_system=yes
  136. ;;
  137. *)
  138. ;;
  139. esac
  140. if test "$have_w32_system" = yes; then
  141. AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
  142. fi
  143. AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
  144. # Generate values for the DLL version info
  145. if test "$have_w32_system" = yes; then
  146. BUILD_TIMESTAMP=`date --iso-8601=minutes`
  147. changequote(,)dnl
  148. BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
  149. changequote([,])dnl
  150. BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
  151. fi
  152. AC_SUBST(BUILD_REVISION)
  153. AC_SUBST(BUILD_TIMESTAMP)
  154. AC_SUBST(BUILD_FILEVERSION)
  155. # Checks for libraries.
  156. AC_CHECK_FUNCS([ttyname localtime_r timegm])
  157. AC_REPLACE_FUNCS([vasprintf stpcpy])
  158. # The error code library. Error codes are sent over the IPC layer and
  159. # have to be interpreted.
  160. AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
  161. have_gpg_error=yes, have_gpg_error=no)
  162. # The IPC library.
  163. AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_VERSION",
  164. have_libassuan=yes, have_libassuan=no)
  165. # GPGSM
  166. NO_OVERRIDE=no
  167. AC_ARG_WITH(gpgsm,
  168. AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
  169. GPGSM=$withval, NO_OVERRIDE=yes)
  170. if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
  171. GPGSM=
  172. NO_OVERRIDE=yes
  173. if test "$cross_compiling" != "yes"; then
  174. AC_PATH_PROG(GPGSM, gpgsm)
  175. fi
  176. if test -z "$GPGSM"; then
  177. GPGSM="$GPGSM_DEFAULT"
  178. fi
  179. fi
  180. if test "$GPGSM" = no; then
  181. if test "$NO_OVERRIDE" = "yes"; then
  182. if test "$cross_compiling" != "yes"; then
  183. AC_MSG_WARN([
  184. ***
  185. *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
  186. ***])
  187. else
  188. AC_MSG_ERROR([
  189. ***
  190. *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
  191. ***])
  192. fi
  193. fi
  194. else
  195. AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
  196. AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
  197. fi
  198. AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
  199. dnl Check for GPGSM version requirement.
  200. GPGSM_VERSION=unknown
  201. ok=maybe
  202. if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
  203. ok=no
  204. else
  205. if test "$cross_compiling" = "yes"; then
  206. AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
  207. ok=no
  208. else
  209. if test ! -x "$GPGSM"; then
  210. AC_MSG_WARN([GPGSM not executable, version check disabled])
  211. ok=no
  212. fi
  213. fi
  214. fi
  215. if test "$ok" = "maybe"; then
  216. AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
  217. req_major=`echo $NEED_GPGSM_VERSION | \
  218. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  219. req_minor=`echo $NEED_GPGSM_VERSION | \
  220. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  221. req_micro=`echo $NEED_GPGSM_VERSION | \
  222. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  223. gpgsm_version=`$GPGSM --version | grep ^gpgsm`
  224. major=`echo $gpgsm_version | \
  225. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  226. minor=`echo $gpgsm_version | \
  227. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  228. micro=`echo $gpgsm_version | \
  229. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  230. GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
  231. if test "$major" -gt "$req_major"; then
  232. ok=yes
  233. else
  234. if test "$major" -eq "$req_major"; then
  235. if test "$minor" -gt "$req_minor"; then
  236. ok=yes
  237. else
  238. if test "$minor" -eq "$req_minor"; then
  239. if test "$micro" -ge "$req_micro"; then
  240. ok=yes
  241. fi
  242. fi
  243. fi
  244. fi
  245. fi
  246. if test "$ok" = "yes"; then
  247. AC_MSG_RESULT(yes)
  248. else
  249. AC_MSG_RESULT(no)
  250. AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
  251. fi
  252. fi
  253. gpgsm_ok="$ok"
  254. # GPG_AGENT
  255. NO_OVERRIDE=no
  256. AC_ARG_WITH(gpg-agent,
  257. AC_HELP_STRING([--with-gpg-agent=PATH], [use GPG Agent binary at PATH]),
  258. GPG_AGENT=$withval, NO_OVERRIDE=yes)
  259. if test "$NO_OVERRIDE" = "yes" || test "$GPG_AGENT" = "yes"; then
  260. GPG_AGENT=
  261. NO_OVERRIDE=yes
  262. if test "$cross_compiling" != "yes"; then
  263. AC_PATH_PROG(GPG_AGENT, gpg-agent)
  264. fi
  265. if test -z "$GPG_AGENT"; then
  266. GPG_AGENT="$GPG_AGENT_DEFAULT"
  267. fi
  268. fi
  269. if test "$GPG_AGENT" = no; then
  270. if test "$NO_OVERRIDE" = "yes"; then
  271. if test "$cross_compiling" != "yes"; then
  272. AC_MSG_WARN([
  273. ***
  274. *** Could not find GPG Agent, install GPG Agent or use --with-gpg-agent=PATH to enable it
  275. ***])
  276. else
  277. AC_MSG_ERROR([
  278. ***
  279. *** Can not determine path to GPG Agent when cross-compiling, use --with-gpg-agent=PATH
  280. ***])
  281. fi
  282. fi
  283. else
  284. AC_DEFINE_UNQUOTED(GPG_AGENT_PATH, "$GPG_AGENT", [Path to the GPG_AGENT binary.])
  285. AC_DEFINE(ENABLE_GPG_AGENT,1, [Whether GPG Agent support is enabled])
  286. fi
  287. AM_CONDITIONAL(HAVE_GPG_AGENT, test "$GPG_AGENT" != "no")
  288. # Checks for header files.
  289. AC_HEADER_STDC
  290. AC_CHECK_HEADERS([stdlib.h string.h])
  291. # Checks for typedefs, structures, and compiler characteristics.
  292. AC_HEADER_STDBOOL
  293. AC_C_INLINE
  294. # Checks for library functions.
  295. AC_FUNC_REALLOC
  296. # Check for programs needed for the manual.
  297. AC_CHECK_PROG(CONVERT, convert, convert)
  298. AC_CHECK_PROG(EPSTOPDF, epstopdf, epstopdf)
  299. # Test if tests can be run
  300. ok=yes
  301. AM_CONDITIONAL(RUN_TESTS, test "$ok" = "yes")
  302. # Print errors here so that they are visible all
  303. # together and the user can acquire them all together.
  304. die=no
  305. if test "$have_gpg_error" = "no"; then
  306. die=yes
  307. AC_MSG_NOTICE([[
  308. ***
  309. *** You need libgpg-error to build this program.
  310. ** This library is for example available at
  311. *** ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
  312. *** (at least version $NEED_GPG_ERROR_VERSION is required.)
  313. ***]])
  314. fi
  315. if test "$have_libassuan" = "no"; then
  316. die=yes
  317. AC_MSG_NOTICE([[
  318. ***
  319. *** You need libassuan to build this program.
  320. *** This library is for example available at
  321. *** ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
  322. *** (at least version $NEED_LIBASSUAN_VERSION is required).
  323. ***]])
  324. fi
  325. if test "$die" = "yes"; then
  326. AC_MSG_ERROR([[
  327. ***
  328. *** Required libraries not found. Please consult the above messages
  329. *** and install them before running configure again.
  330. ***]])
  331. fi
  332. AC_CONFIG_FILES([Makefile
  333. src/Makefile
  334. tests/Makefile
  335. doc/manual/Makefile
  336. doc/Makefile
  337. src/versioninfo.rc])
  338. AC_OUTPUT