configure.ac 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ(2.59)
  4. min_automake_version="1.9.3"
  5. # Version number: Remember to change it immediately *after* a release.
  6. # Make sure to run "svn up" before a "make dist".
  7. # See below for the LT versions.
  8. #
  9. # The CVS version is usually the next intended release version with
  10. # the string "-cvs" appended. The reason for this is that tests for a
  11. # specific feature can already be done under the assumption that the
  12. # CVS version is the most recent one in a branch. To disable the CVS
  13. # version for the real release, just comment out the my_iscvs macro.
  14. # Note, that we are now using Subversion instead of CVS and append the
  15. # SVN revision number to the "cvs" suffix. To make this most useful
  16. # for snapshot releases please do an "svn up" right before recreating
  17. # the configure script, so that a proper revision number for all files
  18. # is available when running a "make distcheck".
  19. m4_define(my_version, [0.0.0])
  20. m4_define(my_iscvs, yes)
  21. AC_INIT([scute], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit(
  22. [$Revision: 1179 $],[Ra-z $:])]),
  23. [marcus@g10code.com])
  24. # LT Version numbers, remember to change them just *before* a release.
  25. # (Code changed: REVISION++)
  26. # (Interfaces added/removed/changed: CURRENT++, REVISION=0)
  27. # (Interfaces added: AGE++)
  28. # (Interfaces removed/changed: AGE=0)
  29. #
  30. LIBSCUTE_LT_CURRENT=0
  31. LIBSCUTE_LT_AGE=0
  32. LIBSCUTE_LT_REVISION=0
  33. NEED_GPG_ERROR_VERSION=0.7
  34. NEED_LIBASSUAN_VERSION=0.6.10
  35. NEED_GPGSM_VERSION=1.9.6
  36. # Some status variables to give feedback at the end of a configure run.
  37. have_gpg_error=no
  38. have_libassuan=no
  39. AC_CONFIG_SRCDIR([src/cryptoki.h])
  40. AC_CONFIG_HEADER([config.h])
  41. dnl FIXME: Enable this with autoconf 2.59.
  42. dnl AC_CONFIG_MACRO_DIR(m4)
  43. AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
  44. AM_MAINTAINER_MODE
  45. AC_CANONICAL_HOST
  46. # Enable GNU extensions on systems that have them.
  47. AC_GNU_SOURCE
  48. AH_VERBATIM([_REENTRANT],
  49. [/* To allow the use of scute in multithreaded programs we have to use
  50. special features from the library. */
  51. #ifndef _REENTRANT
  52. # define _REENTRANT 1
  53. #endif])
  54. # Checks for programs.
  55. AC_PROG_CC
  56. # FIXME: We should support setting the CFLAGS by the user. But
  57. # -std=gnu99 is required.
  58. CFLAGS="-std=gnu99 -Wall -Wno-pointer-sign -g -O3"
  59. AC_ARG_ENABLE(optimization,
  60. AC_HELP_STRING([--disable-optimization],
  61. [disable compiler optimization]),
  62. [if test $enableval = no ; then
  63. CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
  64. fi])
  65. AC_SUBST(LIBSCUTE_LT_CURRENT)
  66. AC_SUBST(LIBSCUTE_LT_AGE)
  67. AC_SUBST(LIBSCUTE_LT_REVISION)
  68. AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION",
  69. [Min. needed GPGSM version.])
  70. AC_SUBST(PACKAGE)
  71. AC_SUBST(VERSION)
  72. AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
  73. AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
  74. # Don't default to build static libs.
  75. AC_DISABLE_STATIC
  76. AC_LIBTOOL_WIN32_DLL
  77. AC_LIBTOOL_RC
  78. AC_PROG_LIBTOOL
  79. # For now we hardcode the use of version scripts. It would be better
  80. # to write a test for this or even implement this within libtool.
  81. have_ld_version_script=no
  82. case "${host}" in
  83. *-*-linux*)
  84. have_ld_version_script=yes
  85. ;;
  86. *-*-gnu*)
  87. have_ld_version_script=yes
  88. ;;
  89. esac
  90. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  91. # Checks for libraries.
  92. # The error code library. Error codes are sent over the IPC layer and
  93. # have to be interpreted.
  94. AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
  95. have_gpg_error=yes, have_gpg_error=no)
  96. # The IPC library.
  97. AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_VERSION",
  98. have_libassuan=yes, have_libassuan=no)
  99. # GPGSM
  100. GPGSM_DEFAULT=no
  101. NO_OVERRIDE=no
  102. AC_ARG_WITH(gpgsm,
  103. AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
  104. GPGSM=$withval, NO_OVERRIDE=yes)
  105. if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
  106. GPGSM=
  107. NO_OVERRIDE=yes
  108. if test "$cross_compiling" != "yes"; then
  109. AC_PATH_PROG(GPGSM, gpgsm)
  110. fi
  111. if test -z "$GPGSM"; then
  112. GPGSM="$GPGSM_DEFAULT"
  113. fi
  114. fi
  115. if test "$GPGSM" = no; then
  116. if test "$NO_OVERRIDE" = "yes"; then
  117. if test "$cross_compiling" != "yes"; then
  118. AC_MSG_WARN([
  119. ***
  120. *** Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it
  121. ***])
  122. else
  123. AC_MSG_ERROR([
  124. ***
  125. *** Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH
  126. ***])
  127. fi
  128. fi
  129. else
  130. AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.])
  131. AC_DEFINE(ENABLE_GPGSM,1,[Whether GPGSM support is enabled])
  132. fi
  133. AM_CONDITIONAL(HAVE_GPGSM, test "$GPGSM" != "no")
  134. dnl Check for GPGSM version requirement.
  135. GPGSM_VERSION=unknown
  136. ok=maybe
  137. if test -z "$GPGSM" -o "x$GPGSM" = "xno"; then
  138. ok=no
  139. else
  140. if test "$cross_compiling" = "yes"; then
  141. AC_MSG_WARN([GPGSM version can not be checked when cross compiling])
  142. ok=no
  143. else
  144. if test ! -x "$GPGSM"; then
  145. AC_MSG_WARN([GPGSM not executable, version check disabled])
  146. ok=no
  147. fi
  148. fi
  149. fi
  150. if test "$ok" = "maybe"; then
  151. AC_MSG_CHECKING(for GPGSM >= $NEED_GPGSM_VERSION)
  152. req_major=`echo $NEED_GPGSM_VERSION | \
  153. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
  154. req_minor=`echo $NEED_GPGSM_VERSION | \
  155. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
  156. req_micro=`echo $NEED_GPGSM_VERSION | \
  157. sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
  158. gpgsm_version=`$GPGSM --version | grep ^gpgsm`
  159. major=`echo $gpgsm_version | \
  160. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
  161. minor=`echo $gpgsm_version | \
  162. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
  163. micro=`echo $gpgsm_version | \
  164. sed 's/^gpgsm (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
  165. GPGSM_VERSION=`echo $gpgsm_version | sed 's/^gpgsm (GnuPG) //'`
  166. if test "$major" -gt "$req_major"; then
  167. ok=yes
  168. else
  169. if test "$major" -eq "$req_major"; then
  170. if test "$minor" -gt "$req_minor"; then
  171. ok=yes
  172. else
  173. if test "$minor" -eq "$req_minor"; then
  174. if test "$micro" -ge "$req_micro"; then
  175. ok=yes
  176. fi
  177. fi
  178. fi
  179. fi
  180. fi
  181. if test "$ok" = "yes"; then
  182. AC_MSG_RESULT(yes)
  183. else
  184. AC_MSG_RESULT(no)
  185. AC_MSG_WARN([GPGSM must be at least version $NEED_GPGSM_VERSION])
  186. fi
  187. fi
  188. gpgsm_ok="$ok"
  189. # Checks for header files.
  190. AC_HEADER_STDC
  191. AC_CHECK_HEADERS([stdlib.h string.h])
  192. # Checks for typedefs, structures, and compiler characteristics.
  193. AC_HEADER_STDBOOL
  194. AC_C_INLINE
  195. # Checks for library functions.
  196. AC_FUNC_REALLOC
  197. # Test if tests can be run
  198. ok=yes
  199. AM_CONDITIONAL(RUN_TESTS, test "$ok" = "yes")
  200. # Print errors here so that they are visible all
  201. # together and the user can acquire them all together.
  202. die=no
  203. if test "$have_gpg_error" = "no"; then
  204. die=yes
  205. AC_MSG_NOTICE([[
  206. ***
  207. *** You need libgpg-error to build this program.
  208. ** This library is for example available at
  209. *** ftp://ftp.gnupg.org/pub/gcrypt/libgpg-error
  210. *** (at least version $NEED_GPG_ERROR_VERSION is required.)
  211. ***]])
  212. fi
  213. if test "$have_libassuan" = "no"; then
  214. die=yes
  215. AC_MSG_NOTICE([[
  216. ***
  217. *** You need libassuan to build this program.
  218. *** This library is for example available at
  219. *** ftp://ftp.gnupg.org/pub/gcrypt/alpha/libassuan/
  220. *** (at least version $NEED_LIBASSUAN_VERSION is required).
  221. ***]])
  222. fi
  223. if test "$die" = "yes"; then
  224. AC_MSG_ERROR([[
  225. ***
  226. *** Required libraries not found. Please consult the above messages
  227. *** and install them before running configure again.
  228. ***]])
  229. fi
  230. AC_CONFIG_FILES([Makefile
  231. include/Makefile
  232. src/Makefile
  233. tests/Makefile])
  234. AC_OUTPUT