configure.ac 12 KB

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