configure.ac 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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. #
  97. # Setup gcc specific options
  98. #
  99. AC_MSG_NOTICE([checking for cc features])
  100. if test "$GCC" = yes; then
  101. mycflags=
  102. mycflags_save=$CFLAGS
  103. # Check whether gcc does not emit a diagnositc for unknow -Wno-*
  104. # options. This is the case for gcc >= 4.6
  105. AC_MSG_CHECKING([if gcc ignores unknown -Wno-* options])
  106. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  107. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6 )
  108. #kickerror
  109. #endif]],[])],[_gcc_silent_wno=yes],[_gcc_silent_wno=no])
  110. AC_MSG_RESULT($_gcc_silent_wno)
  111. # Note that it is okay to use CFLAGS here because these are just
  112. # warning options and the user should have a chance of overriding
  113. # them.
  114. if test "$USE_MAINTAINER_MODE" = "yes"; then
  115. mycflags="$mycflags -O3 -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
  116. mycflags="$mycflags -Wformat -Wno-format-y2k -Wformat-security"
  117. if test x"$_gcc_silent_wno" = xyes ; then
  118. _gcc_wopt=yes
  119. else
  120. AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
  121. CFLAGS="-Wno-missing-field-initializers"
  122. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
  123. [_gcc_wopt=yes],[_gcc_wopt=no])
  124. AC_MSG_RESULT($_gcc_wopt)
  125. fi
  126. if test x"$_gcc_wopt" = xyes ; then
  127. mycflags="$mycflags -W -Wno-sign-compare"
  128. mycflags="$mycflags -Wno-missing-field-initializers"
  129. fi
  130. AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement])
  131. CFLAGS="-Wdeclaration-after-statement"
  132. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
  133. AC_MSG_RESULT($_gcc_wopt)
  134. if test x"$_gcc_wopt" = xyes ; then
  135. mycflags="$mycflags -Wdeclaration-after-statement"
  136. fi
  137. else
  138. mycflags="$mycflags -Wall"
  139. fi
  140. if test x"$_gcc_silent_wno" = xyes ; then
  141. _gcc_psign=yes
  142. else
  143. AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
  144. CFLAGS="-Wno-pointer-sign"
  145. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
  146. [_gcc_psign=yes],[_gcc_psign=no])
  147. AC_MSG_RESULT($_gcc_psign)
  148. fi
  149. if test x"$_gcc_psign" = xyes ; then
  150. mycflags="$mycflags -Wno-pointer-sign"
  151. fi
  152. AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
  153. CFLAGS="-Wpointer-arith"
  154. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_psign=yes,_gcc_psign=no)
  155. AC_MSG_RESULT($_gcc_psign)
  156. if test x"$_gcc_psign" = xyes ; then
  157. mycflags="$mycflags -Wpointer-arith"
  158. fi
  159. CFLAGS="$mycflags $mycflags_save"
  160. fi
  161. AC_ARG_ENABLE(optimization,
  162. AC_HELP_STRING([--disable-optimization],
  163. [disable compiler optimization]),
  164. [if test $enableval = no ; then
  165. CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
  166. fi])
  167. AC_SUBST(LIBSCUTE_LT_CURRENT)
  168. AC_SUBST(LIBSCUTE_LT_AGE)
  169. AC_SUBST(LIBSCUTE_LT_REVISION)
  170. AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
  171. [Min. needed GPGSM version.])
  172. AC_SUBST(PACKAGE)
  173. AC_SUBST(VERSION)
  174. AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
  175. AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
  176. AC_DEFINE_UNQUOTED(VERSION_MAJOR, $VERSION_MAJOR, [Major version number])
  177. AC_DEFINE_UNQUOTED(VERSION_MINOR, $VERSION_MINOR, [Minor version number])
  178. # Don't default to build static libs.
  179. # FIXME: Caution: Evil hack ahead. Libtool does not support linking a
  180. # static library to a shared library. But for libassuan, we need this.
  181. # Instead adding a lot of junk to Makefile.am to get this, we just override
  182. # all safety checks here. We are driving without seat belts now!
  183. # http://lists.cairographics.org/archives/cairo/2009-April/016962.html
  184. lt_cv_deplibs_check_method=pass_all
  185. LT_PREREQ([2.2.6])
  186. LT_INIT([win32-dll disable-static])
  187. LT_LANG([Windows Resource])
  188. # For now we hardcode the use of version scripts. It would be better
  189. # to write a test for this or even implement this within libtool.
  190. have_ld_version_script=no
  191. case "${host}" in
  192. *-*-linux*)
  193. have_ld_version_script=yes
  194. ;;
  195. *-*-gnu*)
  196. have_ld_version_script=yes
  197. ;;
  198. esac
  199. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  200. GPGSM_DEFAULT=no
  201. GPG_AGENT_DEFAULT=no
  202. have_w32_system=no
  203. case "${host}" in
  204. *-mingw32*)
  205. # special stuff for Windoze NT
  206. GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
  207. GPG_AGENT_DEFAULT='c:\\gnupg\\gpg-agent.exe'
  208. have_w32_system=yes
  209. ;;
  210. *)
  211. ;;
  212. esac
  213. if test "$have_w32_system" = yes; then
  214. AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
  215. fi
  216. AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
  217. # Generate values for the DLL version info
  218. if test "$have_w32_system" = yes; then
  219. BUILD_TIMESTAMP=`date --iso-8601=minutes`
  220. changequote(,)dnl
  221. BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
  222. changequote([,])dnl
  223. BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
  224. fi
  225. AC_SUBST(BUILD_REVISION)
  226. AC_SUBST(BUILD_TIMESTAMP)
  227. AC_SUBST(BUILD_FILEVERSION)
  228. # Checks for libraries.
  229. AC_CHECK_FUNCS([ttyname localtime_r timegm stpcpy])
  230. # Run the checks needed for estream-printf.c
  231. estream_PRINTF_INIT
  232. # The error code library. Error codes are sent over the IPC layer and
  233. # have to be interpreted.
  234. AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
  235. have_gpg_error=yes, have_gpg_error=no)
  236. # The IPC library.
  237. AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_VERSION",
  238. have_libassuan=yes, have_libassuan=no)
  239. # GPGSM
  240. NO_OVERRIDE=no
  241. AC_ARG_WITH(gpgsm,
  242. AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
  243. GPGSM=$withval, NO_OVERRIDE=yes)
  244. if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
  245. GPGSM=
  246. NO_OVERRIDE=yes
  247. if test "$cross_compiling" != "yes"; then
  248. AC_PATH_PROG(GPGSM, gpgsm)
  249. fi
  250. if test -z "$GPGSM"; then
  251. GPGSM="$GPGSM_DEFAULT"
  252. fi
  253. fi
  254. if test "$GPGSM" = no; then
  255. if test "$NO_OVERRIDE" = "yes"; then
  256. if test "$cross_compiling" != "yes"; then
  257. AC_MSG_WARN([
  258. ***
  259. *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
  260. ***])
  261. else
  262. AC_MSG_ERROR([
  263. ***
  264. *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
  265. ***])
  266. fi
  267. fi
  268. else
  269. AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
  270. AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
  271. fi
  272. AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
  273. dnl Check for GPGSM version requirement.
  274. GPGSM_VERSION=unknown
  275. ok=maybe
  276. if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
  277. ok=no
  278. else
  279. if test "$cross_compiling" = "yes"; then
  280. AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
  281. ok=no
  282. else
  283. if test ! -x "$GPGSM"; then
  284. AC_MSG_WARN([GPGSM not executable, version check disabled])
  285. ok=no
  286. fi
  287. fi
  288. fi
  289. if test "$ok" = "maybe"; then
  290. AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
  291. req_major=`echo $NEED_GPGSM_VERSION | \
  292. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  293. req_minor=`echo $NEED_GPGSM_VERSION | \
  294. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  295. req_micro=`echo $NEED_GPGSM_VERSION | \
  296. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  297. gpgsm_version=`$GPGSM --version | grep ^gpgsm`
  298. major=`echo $gpgsm_version | \
  299. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  300. minor=`echo $gpgsm_version | \
  301. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  302. micro=`echo $gpgsm_version | \
  303. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  304. GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
  305. if test "$major" -gt "$req_major"; then
  306. ok=yes
  307. else
  308. if test "$major" -eq "$req_major"; then
  309. if test "$minor" -gt "$req_minor"; then
  310. ok=yes
  311. else
  312. if test "$minor" -eq "$req_minor"; then
  313. if test "$micro" -ge "$req_micro"; then
  314. ok=yes
  315. fi
  316. fi
  317. fi
  318. fi
  319. fi
  320. if test "$ok" = "yes"; then
  321. AC_MSG_RESULT(yes)
  322. else
  323. AC_MSG_RESULT(no)
  324. AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
  325. fi
  326. fi
  327. gpgsm_ok="$ok"
  328. # GPG_AGENT
  329. NO_OVERRIDE=no
  330. AC_ARG_WITH(gpg-agent,
  331. AC_HELP_STRING([--with-gpg-agent=PATH], [use GPG Agent binary at PATH]),
  332. GPG_AGENT=$withval, NO_OVERRIDE=yes)
  333. if test "$NO_OVERRIDE" = "yes" || test "$GPG_AGENT" = "yes"; then
  334. GPG_AGENT=
  335. NO_OVERRIDE=yes
  336. if test "$cross_compiling" != "yes"; then
  337. AC_PATH_PROG(GPG_AGENT, gpg-agent)
  338. fi
  339. if test -z "$GPG_AGENT"; then
  340. GPG_AGENT="$GPG_AGENT_DEFAULT"
  341. fi
  342. fi
  343. if test "$GPG_AGENT" = no; then
  344. if test "$NO_OVERRIDE" = "yes"; then
  345. if test "$cross_compiling" != "yes"; then
  346. AC_MSG_WARN([
  347. ***
  348. *** Could not find GPG Agent, install GPG Agent or use --with-gpg-agent=PATH to enable it
  349. ***])
  350. else
  351. AC_MSG_ERROR([
  352. ***
  353. *** Can not determine path to GPG Agent when cross-compiling, use --with-gpg-agent=PATH
  354. ***])
  355. fi
  356. fi
  357. else
  358. AC_DEFINE_UNQUOTED(GPG_AGENT_PATH, "$GPG_AGENT", [Path to the GPG_AGENT binary.])
  359. AC_DEFINE(ENABLE_GPG_AGENT,1, [Whether GPG Agent support is enabled])
  360. fi
  361. AM_CONDITIONAL(HAVE_GPG_AGENT, test "$GPG_AGENT" != "no")
  362. # Checks for header files.
  363. AC_HEADER_STDC
  364. AC_CHECK_HEADERS([stdlib.h string.h])
  365. # Checks for typedefs, structures, and compiler characteristics.
  366. AC_HEADER_STDBOOL
  367. AC_C_INLINE
  368. # Checks for library functions.
  369. # Check for programs needed for the manual.
  370. AC_CHECK_PROG(CONVERT, convert, convert)
  371. AC_CHECK_PROG(EPSTOPDF, epstopdf, epstopdf)
  372. # Test if tests can be run
  373. ok=yes
  374. AM_CONDITIONAL(RUN_TESTS, test "$ok" = "yes")
  375. AH_BOTTOM([
  376. /* Prefix all estream functions. */
  377. #define _ESTREAM_EXT_SYM_PREFIX _scute_
  378. ])
  379. # Print errors here so that they are visible all
  380. # together and the user can acquire them all together.
  381. die=no
  382. if test "$have_gpg_error" = "no"; then
  383. die=yes
  384. AC_MSG_NOTICE([[
  385. ***
  386. *** You need libgpg-error to build this program.
  387. ** This library is for example available at
  388. *** ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
  389. *** (at least version $NEED_GPG_ERROR_VERSION is required.)
  390. ***]])
  391. fi
  392. if test "$have_libassuan" = "no"; then
  393. die=yes
  394. AC_MSG_NOTICE([[
  395. ***
  396. *** You need libassuan to build this program.
  397. *** This library is for example available at
  398. *** ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
  399. *** (at least version $NEED_LIBASSUAN_VERSION is required).
  400. ***]])
  401. fi
  402. if test "$die" = "yes"; then
  403. AC_MSG_ERROR([[
  404. ***
  405. *** Required libraries not found. Please consult the above messages
  406. *** and install them before running configure again.
  407. ***]])
  408. fi
  409. AC_CONFIG_FILES([Makefile
  410. m4/Makefile
  411. src/Makefile
  412. tests/Makefile
  413. doc/manual/Makefile
  414. doc/Makefile
  415. src/versioninfo.rc])
  416. AC_OUTPUT