configure.ac 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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.5.0])
  46. m4_define([my_issvn], [yes])
  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_AUX_DIR([build-aux])
  74. AC_CONFIG_SRCDIR([src/cryptoki.h])
  75. AC_CONFIG_HEADER([config.h])
  76. AC_CONFIG_MACRO_DIR(m4)
  77. AM_INIT_AUTOMAKE
  78. AM_MAINTAINER_MODE
  79. AC_CANONICAL_HOST
  80. # Autobuilder support.
  81. AB_INIT
  82. # Enable GNU extensions on systems that have them.
  83. AC_GNU_SOURCE
  84. AH_VERBATIM([_REENTRANT],
  85. [/* To allow the use of scute in multithreaded programs we have to use
  86. special features from the library. */
  87. #ifndef _REENTRANT
  88. # define _REENTRANT 1
  89. #endif])
  90. # Checks for programs.
  91. AC_PROG_CC
  92. AC_ARG_ENABLE(optimization,
  93. AC_HELP_STRING([--disable-optimization],
  94. [disable compiler optimization]),
  95. [if test $enableval = no ; then
  96. CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
  97. fi])
  98. AC_SUBST(LIBSCUTE_LT_CURRENT)
  99. AC_SUBST(LIBSCUTE_LT_AGE)
  100. AC_SUBST(LIBSCUTE_LT_REVISION)
  101. AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
  102. [Min. needed GPGSM version.])
  103. AC_SUBST(PACKAGE)
  104. AC_SUBST(VERSION)
  105. AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
  106. AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
  107. AC_DEFINE_UNQUOTED(VERSION_MAJOR, $VERSION_MAJOR, [Major version number])
  108. AC_DEFINE_UNQUOTED(VERSION_MINOR, $VERSION_MINOR, [Minor version number])
  109. # Don't default to build static libs.
  110. # FIXME: Caution: Evil hack ahead. Libtool does not support linking a
  111. # static library to a shared library. But for libassuan, we need this.
  112. # Instead adding a lot of junk to Makefile.am to get this, we just override
  113. # all safety checks here. We are driving without seat belts now!
  114. # http://lists.cairographics.org/archives/cairo/2009-April/016962.html
  115. lt_cv_deplibs_check_method=pass_all
  116. LT_PREREQ([2.2.6])
  117. LT_INIT([win32-dll disable-static])
  118. LT_LANG([Windows Resource])
  119. # For now we hardcode the use of version scripts. It would be better
  120. # to write a test for this or even implement this within libtool.
  121. have_ld_version_script=no
  122. case "${host}" in
  123. *-*-linux*)
  124. have_ld_version_script=yes
  125. ;;
  126. *-*-gnu*)
  127. have_ld_version_script=yes
  128. ;;
  129. esac
  130. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  131. GPGSM_DEFAULT=no
  132. GPG_AGENT_DEFAULT=no
  133. have_w32_system=no
  134. case "${host}" in
  135. *-mingw32*)
  136. # special stuff for Windoze NT
  137. GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
  138. GPG_AGENT_DEFAULT='c:\\gnupg\\gpg-agent.exe'
  139. have_w32_system=yes
  140. ;;
  141. *)
  142. ;;
  143. esac
  144. if test "$have_w32_system" = yes; then
  145. AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
  146. fi
  147. AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
  148. # Generate values for the DLL version info
  149. if test "$have_w32_system" = yes; then
  150. BUILD_TIMESTAMP=`date --iso-8601=minutes`
  151. changequote(,)dnl
  152. BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
  153. changequote([,])dnl
  154. BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
  155. fi
  156. AC_SUBST(BUILD_REVISION)
  157. AC_SUBST(BUILD_TIMESTAMP)
  158. AC_SUBST(BUILD_FILEVERSION)
  159. # Checks for libraries.
  160. AC_CHECK_FUNCS([ttyname localtime_r timegm stpcpy])
  161. # Run the checks needed for estream-printf.c
  162. estream_PRINTF_INIT
  163. # The error code library. Error codes are sent over the IPC layer and
  164. # have to be interpreted.
  165. AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
  166. have_gpg_error=yes, have_gpg_error=no)
  167. # The IPC library.
  168. AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_VERSION",
  169. have_libassuan=yes, have_libassuan=no)
  170. # GPGSM
  171. NO_OVERRIDE=no
  172. AC_ARG_WITH(gpgsm,
  173. AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
  174. GPGSM=$withval, NO_OVERRIDE=yes)
  175. if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
  176. GPGSM=
  177. NO_OVERRIDE=yes
  178. if test "$cross_compiling" != "yes"; then
  179. AC_PATH_PROG(GPGSM, gpgsm)
  180. fi
  181. if test -z "$GPGSM"; then
  182. GPGSM="$GPGSM_DEFAULT"
  183. fi
  184. fi
  185. if test "$GPGSM" = no; then
  186. if test "$NO_OVERRIDE" = "yes"; then
  187. if test "$cross_compiling" != "yes"; then
  188. AC_MSG_WARN([
  189. ***
  190. *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
  191. ***])
  192. else
  193. AC_MSG_ERROR([
  194. ***
  195. *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
  196. ***])
  197. fi
  198. fi
  199. else
  200. AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
  201. AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
  202. fi
  203. AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
  204. dnl Check for GPGSM version requirement.
  205. GPGSM_VERSION=unknown
  206. ok=maybe
  207. if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
  208. ok=no
  209. else
  210. if test "$cross_compiling" = "yes"; then
  211. AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
  212. ok=no
  213. else
  214. if test ! -x "$GPGSM"; then
  215. AC_MSG_WARN([GPGSM not executable, version check disabled])
  216. ok=no
  217. fi
  218. fi
  219. fi
  220. if test "$ok" = "maybe"; then
  221. AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
  222. req_major=`echo $NEED_GPGSM_VERSION | \
  223. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  224. req_minor=`echo $NEED_GPGSM_VERSION | \
  225. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  226. req_micro=`echo $NEED_GPGSM_VERSION | \
  227. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  228. gpgsm_version=`$GPGSM --version | grep ^gpgsm`
  229. major=`echo $gpgsm_version | \
  230. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  231. minor=`echo $gpgsm_version | \
  232. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  233. micro=`echo $gpgsm_version | \
  234. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  235. GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
  236. if test "$major" -gt "$req_major"; then
  237. ok=yes
  238. else
  239. if test "$major" -eq "$req_major"; then
  240. if test "$minor" -gt "$req_minor"; then
  241. ok=yes
  242. else
  243. if test "$minor" -eq "$req_minor"; then
  244. if test "$micro" -ge "$req_micro"; then
  245. ok=yes
  246. fi
  247. fi
  248. fi
  249. fi
  250. fi
  251. if test "$ok" = "yes"; then
  252. AC_MSG_RESULT(yes)
  253. else
  254. AC_MSG_RESULT(no)
  255. AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
  256. fi
  257. fi
  258. gpgsm_ok="$ok"
  259. # GPG_AGENT
  260. NO_OVERRIDE=no
  261. AC_ARG_WITH(gpg-agent,
  262. AC_HELP_STRING([--with-gpg-agent=PATH], [use GPG Agent binary at PATH]),
  263. GPG_AGENT=$withval, NO_OVERRIDE=yes)
  264. if test "$NO_OVERRIDE" = "yes" || test "$GPG_AGENT" = "yes"; then
  265. GPG_AGENT=
  266. NO_OVERRIDE=yes
  267. if test "$cross_compiling" != "yes"; then
  268. AC_PATH_PROG(GPG_AGENT, gpg-agent)
  269. fi
  270. if test -z "$GPG_AGENT"; then
  271. GPG_AGENT="$GPG_AGENT_DEFAULT"
  272. fi
  273. fi
  274. if test "$GPG_AGENT" = no; then
  275. if test "$NO_OVERRIDE" = "yes"; then
  276. if test "$cross_compiling" != "yes"; then
  277. AC_MSG_WARN([
  278. ***
  279. *** Could not find GPG Agent, install GPG Agent or use --with-gpg-agent=PATH to enable it
  280. ***])
  281. else
  282. AC_MSG_ERROR([
  283. ***
  284. *** Can not determine path to GPG Agent when cross-compiling, use --with-gpg-agent=PATH
  285. ***])
  286. fi
  287. fi
  288. else
  289. AC_DEFINE_UNQUOTED(GPG_AGENT_PATH, "$GPG_AGENT", [Path to the GPG_AGENT binary.])
  290. AC_DEFINE(ENABLE_GPG_AGENT,1, [Whether GPG Agent support is enabled])
  291. fi
  292. AM_CONDITIONAL(HAVE_GPG_AGENT, test "$GPG_AGENT" != "no")
  293. # Checks for header files.
  294. AC_HEADER_STDC
  295. AC_CHECK_HEADERS([stdlib.h string.h])
  296. # Checks for typedefs, structures, and compiler characteristics.
  297. AC_HEADER_STDBOOL
  298. AC_C_INLINE
  299. # Checks for library functions.
  300. # Check for programs needed for the manual.
  301. AC_CHECK_PROG(CONVERT, convert, convert)
  302. AC_CHECK_PROG(EPSTOPDF, epstopdf, epstopdf)
  303. # Test if tests can be run
  304. ok=yes
  305. AM_CONDITIONAL(RUN_TESTS, test "$ok" = "yes")
  306. AH_BOTTOM([
  307. /* Prefix all estream functions. */
  308. #define _ESTREAM_EXT_SYM_PREFIX _scute_
  309. ])
  310. # Print errors here so that they are visible all
  311. # together and the user can acquire them all together.
  312. die=no
  313. if test "$have_gpg_error" = "no"; then
  314. die=yes
  315. AC_MSG_NOTICE([[
  316. ***
  317. *** You need libgpg-error to build this program.
  318. ** This library is for example available at
  319. *** ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
  320. *** (at least version $NEED_GPG_ERROR_VERSION is required.)
  321. ***]])
  322. fi
  323. if test "$have_libassuan" = "no"; then
  324. die=yes
  325. AC_MSG_NOTICE([[
  326. ***
  327. *** You need libassuan to build this program.
  328. *** This library is for example available at
  329. *** ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
  330. *** (at least version $NEED_LIBASSUAN_VERSION is required).
  331. ***]])
  332. fi
  333. if test "$die" = "yes"; then
  334. AC_MSG_ERROR([[
  335. ***
  336. *** Required libraries not found. Please consult the above messages
  337. *** and install them before running configure again.
  338. ***]])
  339. fi
  340. AC_CONFIG_FILES([Makefile
  341. m4/Makefile
  342. src/Makefile
  343. tests/Makefile
  344. doc/manual/Makefile
  345. doc/Makefile
  346. src/versioninfo.rc])
  347. AC_OUTPUT