configure.ac 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. # configure.ac: Configure script for Scute.
  2. # Copyright (C) 2006, 2007, 2008, 2009, 2010 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 this program; if not, see <http://www.gnu.org/licenses/>.
  18. #
  19. # In addition, as a special exception, g10 Code GmbH gives permission
  20. # to link this library: with the Mozilla Foundation's code for
  21. # Mozilla (or with modified versions of it that use the same license
  22. # as the "Mozilla" code), and distribute the linked executables. You
  23. # must obey the GNU General Public License in all respects for all of
  24. # the code used other than "Mozilla". If you modify this file, you
  25. # may extend this exception to your version of the file, but you are
  26. # not obligated to do so. If you do not wish to do so, delete this
  27. # exception statement from your version.
  28. # Process this file with autoconf to produce a configure script.
  29. AC_PREREQ(2.59)
  30. min_automake_version="1.9.3"
  31. # Version number: Remember to change it immediately *after* a release.
  32. # Make sure to run "svn up" before a "make dist".
  33. # See below for the LT versions.
  34. #
  35. # The SVN version is usually the next intended release version with
  36. # the string "-svnNNNN" appended. The reason for this is that tests
  37. # for a specific feature can already be done under the assumption that
  38. # the SVN version is the most recent one in a branch.
  39. #
  40. # To disable the SVN version for the real release, set the my_issvn
  41. # macro to "no". To make this most useful for snapshot releases
  42. # please do an "svn up" right before recreating the configure script,
  43. # so that a proper revision number for all files is available when
  44. # running a "make distcheck".
  45. m4_define([my_version], [1.4.0])
  46. m4_define([my_issvn], [no])
  47. m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \
  48. || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))
  49. AC_INIT([scute],
  50. [my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision])],
  51. [bug-scute@gnupg.org])
  52. # LT Version numbers, remember to change them just *before* a release.
  53. # (Code changed: REVISION++)
  54. # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
  55. # (Interfaces added: AGE++)
  56. # (Interfaces removed/changed: AGE=0)
  57. #
  58. LIBSCUTE_LT_CURRENT=0
  59. LIBSCUTE_LT_AGE=0
  60. LIBSCUTE_LT_REVISION=2
  61. # Version numbers reported by the PKCS #11 module to its users.
  62. VERSION_MAJOR=1
  63. VERSION_MINOR=0
  64. NEED_GPG_ERROR_VERSION=1.4
  65. NEED_LIBASSUAN_VERSION=2.0.0
  66. NEED_GPGSM_VERSION=1.9.6
  67. # Some status variables to give feedback at the end of a configure run.
  68. have_gpg_error=no
  69. have_libassuan=no
  70. BUILD_REVISION=svn_revision
  71. PACKAGE=$PACKAGE_NAME
  72. VERSION=$PACKAGE_VERSION
  73. AC_CONFIG_SRCDIR([src/cryptoki.h])
  74. AC_CONFIG_HEADER([config.h])
  75. AC_CONFIG_MACRO_DIR(m4)
  76. AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
  77. AM_MAINTAINER_MODE
  78. AC_CANONICAL_HOST
  79. # Autobuilder support.
  80. AB_INIT
  81. # Enable GNU extensions on systems that have them.
  82. AC_GNU_SOURCE
  83. AH_VERBATIM([_REENTRANT],
  84. [/* To allow the use of scute in multithreaded programs we have to use
  85. special features from the library. */
  86. #ifndef _REENTRANT
  87. # define _REENTRANT 1
  88. #endif])
  89. # Checks for programs.
  90. AC_PROG_CC
  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. # FIXME: Caution: Evil hack ahead. Libtool does not support linking a
  110. # static library to a shared library. But for libassuan, we need this.
  111. # Instead adding a lot of junk to Makefile.am to get this, we just override
  112. # all safety checks here. We are driving without seat belts now!
  113. # http://lists.cairographics.org/archives/cairo/2009-April/016962.html
  114. lt_cv_deplibs_check_method=pass_all
  115. LT_PREREQ([2.2.6])
  116. LT_INIT([win32-dll disable-static])
  117. LT_LANG([Windows Resource])
  118. # For now we hardcode the use of version scripts. It would be better
  119. # to write a test for this or even implement this within libtool.
  120. have_ld_version_script=no
  121. case "${host}" in
  122. *-*-linux*)
  123. have_ld_version_script=yes
  124. ;;
  125. *-*-gnu*)
  126. have_ld_version_script=yes
  127. ;;
  128. esac
  129. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  130. GPGSM_DEFAULT=no
  131. GPG_AGENT_DEFAULT=no
  132. have_w32_system=no
  133. case "${host}" in
  134. *-mingw32*)
  135. # special stuff for Windoze NT
  136. GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
  137. GPG_AGENT_DEFAULT='c:\\gnupg\\gpg-agent.exe'
  138. have_w32_system=yes
  139. ;;
  140. *)
  141. ;;
  142. esac
  143. if test "$have_w32_system" = yes; then
  144. AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
  145. fi
  146. AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
  147. # Generate values for the DLL version info
  148. if test "$have_w32_system" = yes; then
  149. BUILD_TIMESTAMP=`date --iso-8601=minutes`
  150. changequote(,)dnl
  151. BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
  152. changequote([,])dnl
  153. BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
  154. fi
  155. AC_SUBST(BUILD_REVISION)
  156. AC_SUBST(BUILD_TIMESTAMP)
  157. AC_SUBST(BUILD_FILEVERSION)
  158. # Checks for libraries.
  159. AC_CHECK_FUNCS([ttyname localtime_r timegm stpcpy])
  160. # Run the checks needed for estream-printf.c
  161. estream_PRINTF_INIT
  162. # The error code library. Error codes are sent over the IPC layer and
  163. # have to be interpreted.
  164. AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
  165. have_gpg_error=yes, have_gpg_error=no)
  166. # The IPC library.
  167. AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_VERSION",
  168. have_libassuan=yes, have_libassuan=no)
  169. # GPGSM
  170. NO_OVERRIDE=no
  171. AC_ARG_WITH(gpgsm,
  172. AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
  173. GPGSM=$withval, NO_OVERRIDE=yes)
  174. if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
  175. GPGSM=
  176. NO_OVERRIDE=yes
  177. if test "$cross_compiling" != "yes"; then
  178. AC_PATH_PROG(GPGSM, gpgsm)
  179. fi
  180. if test -z "$GPGSM"; then
  181. GPGSM="$GPGSM_DEFAULT"
  182. fi
  183. fi
  184. if test "$GPGSM" = no; then
  185. if test "$NO_OVERRIDE" = "yes"; then
  186. if test "$cross_compiling" != "yes"; then
  187. AC_MSG_WARN([
  188. ***
  189. *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
  190. ***])
  191. else
  192. AC_MSG_ERROR([
  193. ***
  194. *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
  195. ***])
  196. fi
  197. fi
  198. else
  199. AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
  200. AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
  201. fi
  202. AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
  203. dnl Check for GPGSM version requirement.
  204. GPGSM_VERSION=unknown
  205. ok=maybe
  206. if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
  207. ok=no
  208. else
  209. if test "$cross_compiling" = "yes"; then
  210. AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
  211. ok=no
  212. else
  213. if test ! -x "$GPGSM"; then
  214. AC_MSG_WARN([GPGSM not executable, version check disabled])
  215. ok=no
  216. fi
  217. fi
  218. fi
  219. if test "$ok" = "maybe"; then
  220. AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
  221. req_major=`echo $NEED_GPGSM_VERSION | \
  222. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  223. req_minor=`echo $NEED_GPGSM_VERSION | \
  224. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  225. req_micro=`echo $NEED_GPGSM_VERSION | \
  226. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  227. gpgsm_version=`$GPGSM --version | grep ^gpgsm`
  228. major=`echo $gpgsm_version | \
  229. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  230. minor=`echo $gpgsm_version | \
  231. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  232. micro=`echo $gpgsm_version | \
  233. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  234. GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
  235. if test "$major" -gt "$req_major"; then
  236. ok=yes
  237. else
  238. if test "$major" -eq "$req_major"; then
  239. if test "$minor" -gt "$req_minor"; then
  240. ok=yes
  241. else
  242. if test "$minor" -eq "$req_minor"; then
  243. if test "$micro" -ge "$req_micro"; then
  244. ok=yes
  245. fi
  246. fi
  247. fi
  248. fi
  249. fi
  250. if test "$ok" = "yes"; then
  251. AC_MSG_RESULT(yes)
  252. else
  253. AC_MSG_RESULT(no)
  254. AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
  255. fi
  256. fi
  257. gpgsm_ok="$ok"
  258. # GPG_AGENT
  259. NO_OVERRIDE=no
  260. AC_ARG_WITH(gpg-agent,
  261. AC_HELP_STRING([--with-gpg-agent=PATH], [use GPG Agent binary at PATH]),
  262. GPG_AGENT=$withval, NO_OVERRIDE=yes)
  263. if test "$NO_OVERRIDE" = "yes" || test "$GPG_AGENT" = "yes"; then
  264. GPG_AGENT=
  265. NO_OVERRIDE=yes
  266. if test "$cross_compiling" != "yes"; then
  267. AC_PATH_PROG(GPG_AGENT, gpg-agent)
  268. fi
  269. if test -z "$GPG_AGENT"; then
  270. GPG_AGENT="$GPG_AGENT_DEFAULT"
  271. fi
  272. fi
  273. if test "$GPG_AGENT" = no; then
  274. if test "$NO_OVERRIDE" = "yes"; then
  275. if test "$cross_compiling" != "yes"; then
  276. AC_MSG_WARN([
  277. ***
  278. *** Could not find GPG Agent, install GPG Agent or use --with-gpg-agent=PATH to enable it
  279. ***])
  280. else
  281. AC_MSG_ERROR([
  282. ***
  283. *** Can not determine path to GPG Agent when cross-compiling, use --with-gpg-agent=PATH
  284. ***])
  285. fi
  286. fi
  287. else
  288. AC_DEFINE_UNQUOTED(GPG_AGENT_PATH, "$GPG_AGENT", [Path to the GPG_AGENT binary.])
  289. AC_DEFINE(ENABLE_GPG_AGENT,1, [Whether GPG Agent support is enabled])
  290. fi
  291. AM_CONDITIONAL(HAVE_GPG_AGENT, test "$GPG_AGENT" != "no")
  292. # Checks for header files.
  293. AC_HEADER_STDC
  294. AC_CHECK_HEADERS([stdlib.h string.h])
  295. # Checks for typedefs, structures, and compiler characteristics.
  296. AC_HEADER_STDBOOL
  297. AC_C_INLINE
  298. # Checks for library functions.
  299. # Check for programs needed for the manual.
  300. AC_CHECK_PROG(CONVERT, convert, convert)
  301. AC_CHECK_PROG(EPSTOPDF, epstopdf, epstopdf)
  302. # Test if tests can be run
  303. ok=yes
  304. AM_CONDITIONAL(RUN_TESTS, test "$ok" = "yes")
  305. AH_BOTTOM([
  306. /* Prefix all estream functions. */
  307. #define _ESTREAM_EXT_SYM_PREFIX _scute_
  308. ])
  309. # Print errors here so that they are visible all
  310. # together and the user can acquire them all together.
  311. die=no
  312. if test "$have_gpg_error" = "no"; then
  313. die=yes
  314. AC_MSG_NOTICE([[
  315. ***
  316. *** You need libgpg-error to build this program.
  317. ** This library is for example available at
  318. *** ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
  319. *** (at least version $NEED_GPG_ERROR_VERSION is required.)
  320. ***]])
  321. fi
  322. if test "$have_libassuan" = "no"; then
  323. die=yes
  324. AC_MSG_NOTICE([[
  325. ***
  326. *** You need libassuan to build this program.
  327. *** This library is for example available at
  328. *** ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
  329. *** (at least version $NEED_LIBASSUAN_VERSION is required).
  330. ***]])
  331. fi
  332. if test "$die" = "yes"; then
  333. AC_MSG_ERROR([[
  334. ***
  335. *** Required libraries not found. Please consult the above messages
  336. *** and install them before running configure again.
  337. ***]])
  338. fi
  339. AC_CONFIG_FILES([Makefile
  340. m4/Makefile
  341. src/Makefile
  342. tests/Makefile
  343. doc/manual/Makefile
  344. doc/Makefile
  345. src/versioninfo.rc])
  346. AC_OUTPUT