configure.ac 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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 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.3.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=1
  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=0.6.10
  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. AC_DEFINE_UNQUOTED(_ASSUAN_ONLY_GPG_ERRORS, 1, [Disable backward compatibility])
  109. # Don't default to build static libs.
  110. AC_DISABLE_STATIC
  111. AC_LIBTOOL_WIN32_DLL
  112. AC_LIBTOOL_RC
  113. AC_PROG_LIBTOOL
  114. # For now we hardcode the use of version scripts. It would be better
  115. # to write a test for this or even implement this within libtool.
  116. have_ld_version_script=no
  117. case "${host}" in
  118. *-*-linux*)
  119. have_ld_version_script=yes
  120. ;;
  121. *-*-gnu*)
  122. have_ld_version_script=yes
  123. ;;
  124. esac
  125. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  126. GPGSM_DEFAULT=no
  127. GPG_AGENT_DEFAULT=no
  128. have_w32_system=no
  129. case "${host}" in
  130. *-mingw32*)
  131. # special stuff for Windoze NT
  132. GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
  133. GPG_AGENT_DEFAULT='c:\\gnupg\\gpg-agent.exe'
  134. have_w32_system=yes
  135. ;;
  136. *)
  137. ;;
  138. esac
  139. if test "$have_w32_system" = yes; then
  140. AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
  141. fi
  142. AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
  143. # Generate values for the DLL version info
  144. if test "$have_w32_system" = yes; then
  145. BUILD_TIMESTAMP=`date --iso-8601=minutes`
  146. changequote(,)dnl
  147. BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
  148. changequote([,])dnl
  149. BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
  150. fi
  151. AC_SUBST(BUILD_REVISION)
  152. AC_SUBST(BUILD_TIMESTAMP)
  153. AC_SUBST(BUILD_FILEVERSION)
  154. # Checks for libraries.
  155. AC_CHECK_FUNCS([ttyname localtime_r timegm])
  156. AC_REPLACE_FUNCS([vasprintf stpcpy])
  157. # The error code library. Error codes are sent over the IPC layer and
  158. # have to be interpreted.
  159. AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
  160. have_gpg_error=yes, have_gpg_error=no)
  161. # The IPC library.
  162. AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_VERSION",
  163. have_libassuan=yes, have_libassuan=no)
  164. # GPGSM
  165. NO_OVERRIDE=no
  166. AC_ARG_WITH(gpgsm,
  167. AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
  168. GPGSM=$withval, NO_OVERRIDE=yes)
  169. if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
  170. GPGSM=
  171. NO_OVERRIDE=yes
  172. if test "$cross_compiling" != "yes"; then
  173. AC_PATH_PROG(GPGSM, gpgsm)
  174. fi
  175. if test -z "$GPGSM"; then
  176. GPGSM="$GPGSM_DEFAULT"
  177. fi
  178. fi
  179. if test "$GPGSM" = no; then
  180. if test "$NO_OVERRIDE" = "yes"; then
  181. if test "$cross_compiling" != "yes"; then
  182. AC_MSG_WARN([
  183. ***
  184. *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
  185. ***])
  186. else
  187. AC_MSG_ERROR([
  188. ***
  189. *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
  190. ***])
  191. fi
  192. fi
  193. else
  194. AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
  195. AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
  196. fi
  197. AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
  198. dnl Check for GPGSM version requirement.
  199. GPGSM_VERSION=unknown
  200. ok=maybe
  201. if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
  202. ok=no
  203. else
  204. if test "$cross_compiling" = "yes"; then
  205. AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
  206. ok=no
  207. else
  208. if test ! -x "$GPGSM"; then
  209. AC_MSG_WARN([GPGSM not executable, version check disabled])
  210. ok=no
  211. fi
  212. fi
  213. fi
  214. if test "$ok" = "maybe"; then
  215. AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
  216. req_major=`echo $NEED_GPGSM_VERSION | \
  217. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  218. req_minor=`echo $NEED_GPGSM_VERSION | \
  219. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  220. req_micro=`echo $NEED_GPGSM_VERSION | \
  221. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  222. gpgsm_version=`$GPGSM --version | grep ^gpgsm`
  223. major=`echo $gpgsm_version | \
  224. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  225. minor=`echo $gpgsm_version | \
  226. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  227. micro=`echo $gpgsm_version | \
  228. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  229. GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
  230. if test "$major" -gt "$req_major"; then
  231. ok=yes
  232. else
  233. if test "$major" -eq "$req_major"; then
  234. if test "$minor" -gt "$req_minor"; then
  235. ok=yes
  236. else
  237. if test "$minor" -eq "$req_minor"; then
  238. if test "$micro" -ge "$req_micro"; then
  239. ok=yes
  240. fi
  241. fi
  242. fi
  243. fi
  244. fi
  245. if test "$ok" = "yes"; then
  246. AC_MSG_RESULT(yes)
  247. else
  248. AC_MSG_RESULT(no)
  249. AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
  250. fi
  251. fi
  252. gpgsm_ok="$ok"
  253. # GPG_AGENT
  254. NO_OVERRIDE=no
  255. AC_ARG_WITH(gpg-agent,
  256. AC_HELP_STRING([--with-gpg-agent=PATH], [use GPG Agent binary at PATH]),
  257. GPG_AGENT=$withval, NO_OVERRIDE=yes)
  258. if test "$NO_OVERRIDE" = "yes" || test "$GPG_AGENT" = "yes"; then
  259. GPG_AGENT=
  260. NO_OVERRIDE=yes
  261. if test "$cross_compiling" != "yes"; then
  262. AC_PATH_PROG(GPG_AGENT, gpg-agent)
  263. fi
  264. if test -z "$GPG_AGENT"; then
  265. GPG_AGENT="$GPG_AGENT_DEFAULT"
  266. fi
  267. fi
  268. if test "$GPG_AGENT" = no; then
  269. if test "$NO_OVERRIDE" = "yes"; then
  270. if test "$cross_compiling" != "yes"; then
  271. AC_MSG_WARN([
  272. ***
  273. *** Could not find GPG Agent, install GPG Agent or use --with-gpg-agent=PATH to enable it
  274. ***])
  275. else
  276. AC_MSG_ERROR([
  277. ***
  278. *** Can not determine path to GPG Agent when cross-compiling, use --with-gpg-agent=PATH
  279. ***])
  280. fi
  281. fi
  282. else
  283. AC_DEFINE_UNQUOTED(GPG_AGENT_PATH, "$GPG_AGENT", [Path to the GPG_AGENT binary.])
  284. AC_DEFINE(ENABLE_GPG_AGENT,1, [Whether GPG Agent support is enabled])
  285. fi
  286. AM_CONDITIONAL(HAVE_GPG_AGENT, test "$GPG_AGENT" != "no")
  287. # Checks for header files.
  288. AC_HEADER_STDC
  289. AC_CHECK_HEADERS([stdlib.h string.h])
  290. # Checks for typedefs, structures, and compiler characteristics.
  291. AC_HEADER_STDBOOL
  292. AC_C_INLINE
  293. # Checks for library functions.
  294. AC_FUNC_REALLOC
  295. # Check for programs needed for the manual.
  296. AC_CHECK_PROG(CONVERT, convert, convert)
  297. AC_CHECK_PROG(EPSTOPDF, epstopdf, epstopdf)
  298. # Test if tests can be run
  299. ok=yes
  300. AM_CONDITIONAL(RUN_TESTS, test "$ok" = "yes")
  301. # Print errors here so that they are visible all
  302. # together and the user can acquire them all together.
  303. die=no
  304. if test "$have_gpg_error" = "no"; then
  305. die=yes
  306. AC_MSG_NOTICE([[
  307. ***
  308. *** You need libgpg-error to build this program.
  309. ** This library is for example available at
  310. *** ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
  311. *** (at least version $NEED_GPG_ERROR_VERSION is required.)
  312. ***]])
  313. fi
  314. if test "$have_libassuan" = "no"; then
  315. die=yes
  316. AC_MSG_NOTICE([[
  317. ***
  318. *** You need libassuan to build this program.
  319. *** This library is for example available at
  320. *** ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
  321. *** (at least version $NEED_LIBASSUAN_VERSION is required).
  322. ***]])
  323. fi
  324. if test "$die" = "yes"; then
  325. AC_MSG_ERROR([[
  326. ***
  327. *** Required libraries not found. Please consult the above messages
  328. *** and install them before running configure again.
  329. ***]])
  330. fi
  331. AC_CONFIG_FILES([Makefile
  332. src/Makefile
  333. tests/Makefile
  334. doc/manual/Makefile
  335. doc/Makefile
  336. src/versioninfo.rc])
  337. AC_OUTPUT