configure.ac 15 KB

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