Use quick key generation.
[libgcrypt.git] / configure.ac
1 # Configure.ac script for Libgcrypt
2 # Copyright (C) 1998, 1999, 2000, 2001, 2002
3 #               2003, 2004, 2006 Free Software Foundation, Inc.
4 #
5 # This file is part of Libgcrypt.
6 #
7 # Libgcrypt is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Lesser general Public License as
9 # published by the Free Software Foundation; either version 2.1 of
10 # the License, or (at your option) any later version.
11 #
12 # Libgcrypt is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 #
21 # (Process this file with autoconf to produce a configure script.)
22 AC_REVISION($Revision$)
23 AC_PREREQ(2.59)
24 min_automake_version="1.9.3"
25
26 # Version number: Remember to change it immediately *after* a release
27 # but remove a "-cvs" prefix right *before* a release and append it
28 # soon later.
29
30 AC_INIT(libgcrypt, 1.3.0-cvs, bug-libgcrypt@gnupg.org)
31
32 # LT Version numbers, remember to change them just *before* a release.
33 #   (Interfaces removed:    CURRENT++, AGE=0, REVISION=0)
34 #   (Interfaces added:      CURRENT++, AGE++, REVISION=0)
35 #   (No interfaces changed:                   REVISION++)
36 LIBGCRYPT_LT_CURRENT=12
37 LIBGCRYPT_LT_AGE=1
38 LIBGCRYPT_LT_REVISION=1
39
40 # If the API is changed in an incompatible way: increment the next counter.
41 LIBGCRYPT_CONFIG_API_VERSION=1
42
43 NEED_GPG_ERROR_VERSION=1.0
44
45
46 PACKAGE=$PACKAGE_NAME
47 VERSION=$PACKAGE_VERSION
48
49 AC_CONFIG_SRCDIR([src/gcrypt.h])
50 AC_CANONICAL_TARGET()
51 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
52 AM_CONFIG_HEADER(config.h)
53 AM_MAINTAINER_MODE
54
55 AH_TOP([
56 /* need this, because some autoconf tests rely on this (e.g. stpcpy)
57  * and it should be used for new programs  */
58 #define _GNU_SOURCE  1
59 ])
60
61 AH_BOTTOM([
62 #define _GCRYPT_IN_LIBGCRYPT 1
63 ])
64
65 AH_VERBATIM([_REENTRANT],
66 [/* To allow the use of Libgcrypt in multithreaded programs we have to use
67     special features from the library. */
68 #ifndef _REENTRANT
69 # define _REENTRANT 1
70 #endif
71 ])
72
73
74 AC_SUBST(LIBGCRYPT_LT_CURRENT)
75 AC_SUBST(LIBGCRYPT_LT_AGE)
76 AC_SUBST(LIBGCRYPT_LT_REVISION)
77 AC_SUBST(PACKAGE)
78 AC_SUBST(VERSION)
79 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
80 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
81
82
83 ######################
84 ##  Basic checks.  ### (we need some results later on (e.g. $GCC)
85 ######################
86
87 AC_PROG_MAKE_SET
88 missing_dir=`cd $ac_aux_dir && pwd`
89 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
90 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
91 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
92 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
93 # AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
94 AC_PROG_CC
95 AC_PROG_CPP
96 AM_PROG_AS
97 AC_ISC_POSIX
98 AC_PROG_INSTALL
99 AC_PROG_AWK
100
101 AM_PROG_LIBTOOL
102
103
104 ##########################
105 ## General definitions. ##
106 ##########################
107
108 # Used by libgcrypt-config
109 LIBGCRYPT_CONFIG_LIBS="-lgcrypt"
110 LIBGCRYPT_CONFIG_CFLAGS=""
111
112 # Definitions for symmetric ciphers.
113 available_ciphers="arcfour blowfish cast5 des aes twofish serpent rfc2268"
114 enabled_ciphers=""
115
116 # Definitions for public-key ciphers.
117 available_pubkey_ciphers="dsa elgamal rsa"
118 enabled_pubkey_ciphers=""
119
120 # Definitions for message digests.
121 available_digests="crc md4 md5 rmd160 sha1 sha256"
122 available_digests_64="sha512 tiger whirlpool"
123 enabled_digests=""
124
125 # Definitions for random modules.
126 available_random_modules="linux egd unix"
127 auto_random_modules="$available_random_modules"
128
129 # Supported thread backends.
130 LIBGCRYPT_THREAD_MODULES=""
131
132 # Other definitions.
133 print_egd_notice=no
134
135 # Setup some stuff depending on host/target.
136 case "${target}" in
137     *-*-mingw32*)
138       available_random_modules="w32"
139       ac_cv_have_dev_random=no
140       AC_DEFINE(USE_ONLY_8DOT3,1,
141                 [set this to limit filenames to the 8.3 format])
142       AC_DEFINE(HAVE_DRIVE_LETTERS,1,
143                 [defined if we must run on a stupid file system])
144       AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
145                 [defined if we run on some of the PCDOS like systems 
146                  (DOS, Windoze. OS/2) with special properties like
147                   no file modes])
148       ;;
149
150     i?86-emx-os2 | i?86-*-os2*emx)
151         # OS/2 with the EMX environment
152         ac_cv_have_dev_random=no
153         AC_DEFINE(HAVE_DRIVE_LETTERS)
154         AC_DEFINE(HAVE_DOSISH_SYSTEM)
155         ;;
156
157     i?86-*-msdosdjgpp*)
158         # DOS with the DJGPP environment
159         ac_cv_have_dev_random=no
160         AC_DEFINE(HAVE_DRIVE_LETTERS)
161         AC_DEFINE(HAVE_DOSISH_SYSTEM)
162         ;;
163
164     *-*-freebsd*)
165        # FreeBSD
166        CPPFLAGS="$CPPFLAGS -I/usr/local/include"
167        LDFLAGS="$LDFLAGS -L/usr/local/lib"
168        ;;
169
170     *-*-hpux*)
171         if test -z "$GCC" ; then
172             CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
173         fi
174         ;;
175     *-dec-osf4*)
176         if test -z "$GCC" ; then
177             # Suppress all warnings
178             # to get rid of the unsigned/signed char mismatch warnings.
179             CFLAGS="$CFLAGS -w"
180         fi
181         ;;
182     m68k-atari-mint)
183         ;;
184     *)
185       ;;
186 esac
187
188 # A printable OS Name is sometime useful.
189 case "${target}" in
190     *-*-mingw32*)
191         PRINTABLE_OS_NAME="MingW32"
192         ;;
193
194     i?86-emx-os2 | i?86-*-os2*emx )
195         PRINTABLE_OS_NAME="OS/2"
196         ;;
197
198     i?86-*-msdosdjgpp*)
199         PRINTABLE_OS_NAME="MSDOS/DJGPP"
200         ;;
201
202     *-linux*)
203         PRINTABLE_OS_NAME="GNU/Linux"
204         ;;
205
206     *)
207         PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
208         ;;
209 esac
210
211
212 case "${target}" in
213     *-openbsd*)
214         # FIXME: Are these the best flags for OpenBSD?
215         NAME_OF_DEV_RANDOM="/dev/srandom"
216         NAME_OF_DEV_URANDOM="/dev/urandom"
217 #       DYNLINK_MOD_CFLAGS="-shared -rdynamic $CFLAGS_PIC -Wl,-Bshareable -Wl,-x"
218         ;;
219
220     *-solaris* | *-irix* | *-dec-osf* | *-netbsd* )
221         NAME_OF_DEV_RANDOM="/dev/random"
222         NAME_OF_DEV_URANDOM="/dev/random"
223 #       DYNLINK_MOD_CFLAGS="-shared $CFLAGS_PIC"
224         ;;
225
226     *)
227         NAME_OF_DEV_RANDOM="/dev/random"
228         NAME_OF_DEV_URANDOM="/dev/urandom"
229         # -shared is a gcc-ism.  Find pic flags from GNUPG_CHECK_PIC.
230 #        if test -n "$GCC" ; then
231 #           DYNLINK_MOD_CFLAGS="-shared $CFLAGS_PIC"                            
232 #        else
233 #           DYNLINK_MOD_CFLAGS="$CFLAGS_PIC"
234 #        fi
235         ;;
236 esac
237
238
239 AC_C_BIGENDIAN
240
241 AC_CHECK_SIZEOF(unsigned short, 2)
242 AC_CHECK_SIZEOF(unsigned int, 4)
243 AC_CHECK_SIZEOF(unsigned long, 4)
244 AC_CHECK_SIZEOF(unsigned long long, 0)
245
246 if test "$ac_cv_sizeof_unsigned_short" = "0" \
247    || test "$ac_cv_sizeof_unsigned_int" = "0" \
248    || test "$ac_cv_sizeof_unsigned_long" = "0"; then
249     AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
250 fi
251
252 # Do we have any 64-bit data types?
253 if test "$ac_cv_sizeof_unsigned_int" != "8" \
254    && test "$ac_cv_sizeof_unsigned_long" != "8" \
255    && test "$ac_cv_sizeof_unsigned_long_long" != "8" \
256    && test "$ac_cv_sizeof_uint64_t" != "8"; then
257     AC_MSG_WARN([No 64-bit types.  Disabling TIGER/192, SHA-384, and SHA-512])
258 else
259   available_digests="$available_digests $available_digests_64"
260 fi
261
262 # If not specified otherwise, all available algorithms will be
263 # included.
264 default_ciphers="$available_ciphers"
265 default_pubkey_ciphers="$available_pubkey_ciphers"
266 default_digests="$available_digests"
267
268 ############################
269 ## Command line switches. ##
270 ############################
271
272 # Implementation of the --enable-ciphers switch.
273 AC_ARG_ENABLE(ciphers,
274               AC_HELP_STRING([--enable-ciphers=ciphers],
275                              [select the symmetric ciphers to include]),
276               [enabled_ciphers=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`],
277               [enabled_ciphers=""])
278 if test "x$enabled_ciphers" = "x" \
279    -o "$enabled_ciphers" = "yes"  \
280    -o "$enabled_ciphers" = "no"; then
281    enabled_ciphers=$default_ciphers
282 fi
283 AC_MSG_CHECKING([which symmetric ciphers to include])
284 for cipher in $enabled_ciphers; do
285     LIST_MEMBER($cipher, $available_ciphers)
286     if test "$found" = "0"; then
287        AC_MSG_ERROR([unsupported cipher specified])
288     fi
289 done
290 AC_MSG_RESULT([$enabled_ciphers])
291
292 # Implementation of the --enable-pubkey-ciphers switch.
293 AC_ARG_ENABLE(pubkey-ciphers,
294               AC_HELP_STRING([--enable-pubkey-ciphers=ciphers],
295                              [select the public-key ciphers to include]),
296               [enabled_pubkey_ciphers=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`],
297               [enabled_pubkey_ciphers=""])
298 if test "x$enabled_pubkey_ciphers" = "x" \
299    -o "$enabled_pubkey_ciphers" = "yes"  \
300    -o "$enabled_pubkey_ciphers" = "no"; then
301    enabled_pubkey_ciphers=$default_pubkey_ciphers
302 fi
303 AC_MSG_CHECKING([which public-key ciphers to include])
304 for cipher in $enabled_pubkey_ciphers; do
305     LIST_MEMBER($cipher, $available_pubkey_ciphers)
306     if test "$found" = "0"; then
307        AC_MSG_ERROR([unsupported public-key cipher specified])
308     fi
309 done
310 AC_MSG_RESULT([$enabled_pubkey_ciphers])
311
312 # Implementation of the --enable-digests switch.
313 AC_ARG_ENABLE(digests,
314               AC_HELP_STRING([--enable-digests=digests],
315                              [select the message digests to include]),
316               [enabled_digests=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`],
317               [enabled_digests=""])
318 if test "x$enabled_digests" = "x" \
319    -o "$enabled_digests" = "yes"  \
320    -o "$enabled_digests" = "no"; then
321    enabled_digests=$default_digests
322 fi
323 AC_MSG_CHECKING([which message digests to include])
324 for digest in $enabled_digests; do
325     LIST_MEMBER($digest, $available_digests)
326     if test "$found" = "0"; then
327        AC_MSG_ERROR([unsupported message digest specified])
328     fi
329 done
330 AC_MSG_RESULT([$enabled_digests])
331
332 # Implementation of the --enable-random switch.
333 AC_ARG_ENABLE(random,
334               AC_HELP_STRING([--enable-random=name],
335                              [select which random number generator to use]),
336               [random=`echo $enableval | tr '[A-Z]' '[a-z]'`],
337               [])
338 if test "x$random" = "x" -o "$random" = "yes" -o "$random" = "no"; then
339     random=default
340 fi
341 AC_MSG_CHECKING([which random module to use])
342 if test "$random" != "default" -a "$random" != "auto"; then
343     LIST_MEMBER($random, $available_random_modules)
344     if test "$found" = "0"; then
345        AC_MSG_ERROR([unsupported random module specified])
346     fi
347 fi
348 AC_MSG_RESULT($random)
349
350 # Implementation of the --disable-dev-random switch.
351 AC_MSG_CHECKING([whether use of /dev/random is requested])
352 AC_ARG_ENABLE(dev-random,
353 [  --disable-dev-random    disable the use of dev random],
354     try_dev_random=$enableval, try_dev_random=yes)
355 AC_MSG_RESULT($try_dev_random)
356
357 # Implementation of the --with-egd-socket switch.
358 AC_ARG_WITH(egd-socket,
359     [  --with-egd-socket=NAME  Use NAME for the EGD socket)],
360             egd_socket_name="$withval", egd_socket_name="" )
361 AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, "$egd_socket_name",
362                    [Define if you don't want the default EGD socket name.
363                     For details see cipher/rndegd.c])
364
365 # Implementation of --disable-asm.
366 AC_MSG_CHECKING([whether assembler modules are requested])
367 AC_ARG_ENABLE([asm],
368               AC_HELP_STRING([--disable-asm],
369                              [Disable assembler modules]),
370               [try_asm_modules=$enableval],
371               [try_asm_modules=yes])
372 AC_MSG_RESULT($try_asm_modules)
373
374 # Implementation of the --enable-m-guard switch.
375 AC_MSG_CHECKING([whether memory guard is requested])
376 AC_ARG_ENABLE(m-guard,
377     [  --enable-m-guard        enable memory guard facility],
378     use_m_guard=$enableval, use_m_guard=no)
379     AC_MSG_RESULT($use_m_guard)
380 if test "$use_m_guard" = yes ; then
381     AC_DEFINE(M_GUARD,1,[Define to use the (obsolete) malloc guarding feature])
382 fi
383
384 # Implementation of the --with-capabilities switch.
385 # Check whether we want to use Linux capabilities
386 AC_MSG_CHECKING([whether use of capabilities is requested])
387 AC_ARG_WITH(capabilities,
388     [  --with-capabilities     use linux capabilities [default=no]],
389 [use_capabilities="$withval"],[use_capabilities=no])
390 AC_MSG_RESULT($use_capabilities)
391
392
393
394 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
395                    [A human readable text with the name of the OS])
396
397 # For some systems we know that we have ld_version scripts.  
398 # Use it then as default.
399 have_ld_version_script=no
400 case "${host}" in
401     *-*-linux*)
402         have_ld_version_script=yes
403         ;;
404     *-*-gnu*)
405         have_ld_version_script=yes
406         ;;
407 esac
408 AC_ARG_ENABLE([ld-version-script],
409               AC_HELP_STRING([--enable-ld-version-script],
410                              [enable/disable use of linker version script.
411                               (default is system dependent)]),
412               [have_ld_version_script=$enableval],
413               [ : ] )
414 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
415
416 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM",
417                    [defined to the name of the strong random device])
418 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM",
419                    [defined to the name of the weaker random device])
420
421 ###############################
422 #### Checks for libraries. ####
423 ###############################
424
425 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION")
426 if test "x$GPG_ERROR_LIBS" = "x"; then
427   AC_MSG_ERROR([libgpg-error is needed.
428                 See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .])
429 fi
430
431 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GCRYPT,
432           [The default error source for libgcrypt.])
433
434 # Solaris needs -lsocket and -lnsl. Unisys system includes
435 # gethostbyname in libsocket but needs libnsl for socket.
436 AC_SEARCH_LIBS(setsockopt, [socket], ,
437         [AC_SEARCH_LIBS(setsockopt, [socket], , , [-lnsl])])
438 AC_SEARCH_LIBS(setsockopt, [nsl])
439
440 ##################################
441 #### Checks for header files. ####
442 ##################################
443
444 AC_HEADER_STDC
445 AC_CHECK_HEADERS(unistd.h sys/select.h)
446
447 ##########################################
448 #### Checks for typedefs, structures, ####
449 ####  and compiler characteristics.   ####
450 ##########################################
451
452 AC_C_CONST
453 AC_C_INLINE
454 AC_TYPE_SIZE_T
455 AC_TYPE_SIGNAL
456 AC_DECL_SYS_SIGLIST
457
458 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
459 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
460 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
461 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
462 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
463
464 AC_CHECK_TYPE(socklen_t,,
465               [AC_DEFINE_UNQUOTED([socklen_t],
466                                   [int],
467                                   [Define to `int' if unavailable.])],
468               [
469 #include <sys/types.h>
470 #include <sys/socket.h>
471               ])
472
473 TYPE_SOCKLEN_T
474
475 #######################################
476 #### Checks for library functions. ####
477 #######################################
478
479 AC_FUNC_VPRINTF
480 # We have replacements for these in src/missing-string.c
481 AC_CHECK_FUNCS(stpcpy strcasecmp)
482 # We have replacements for these in src/g10lib.h
483 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
484 # Other checks
485 AC_CHECK_FUNCS(strerror rand mmap getpagesize waitpid wait4)
486 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime)
487 AC_CHECK_FUNCS(fcntl ftruncate)
488
489 GNUPG_CHECK_MLOCK
490
491 # Check whether we can use Linux capabilities as requested.
492 if test "$use_capabilities" = "yes" ; then
493 use_capabilities=no
494 AC_CHECK_HEADERS(sys/capability.h)
495 if test "$ac_cv_header_sys_capability_h" = "yes" ; then
496   AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
497   if test "$ac_cv_lib_cap_cap_init" = "yes"; then
498      AC_DEFINE(USE_CAPABILITIES,1,
499                [define if capabilities should be used])
500      LIBS="$LIBS -lcap"
501      use_capabilities=yes
502   fi
503 fi
504 if test "$use_capabilities" = "no" ; then
505     AC_MSG_WARN([[
506 ***
507 *** The use of capabilities on this system is not possible.
508 *** You need a recent Linux kernel and some patches:
509 ***   fcaps-2.2.9-990610.patch      (kernel patch for 2.2.9)
510 ***   fcap-module-990613.tar.gz     (kernel module)
511 ***   libcap-1.92.tar.gz            (user mode library and utilities)
512 *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
513 *** set (filesystems menu). Be warned: This code is *really* ALPHA.
514 ***]])
515 fi
516 fi
517
518 # Check whether a random device is available.
519 if test "$try_dev_random" = yes ; then
520     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
521     [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
522       ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
523     if test "$ac_cv_have_dev_random" = yes; then
524         AC_DEFINE(HAVE_DEV_RANDOM,1,
525                  [defined if the system supports a random device] )
526     fi
527 else
528     AC_MSG_CHECKING(for random device)
529     ac_cv_have_dev_random=no
530     AC_MSG_RESULT(has been disabled)
531 fi
532
533 # Figure out the random modules for this configuration.
534 if test "$random" = "default"; then
535
536     # Select default value.
537     if test "$ac_cv_have_dev_random" = yes; then
538         # Try Linuxish random device.
539         random_modules="linux"
540     else
541         case "${target}" in
542         *-*-mingw32*|*-*-cygwin*)
543           # Windows random device.
544           random_modules="w32"
545           ;;
546         *)
547           # Build everything, allow to select at runtime.
548           random_modules="$auto_random_modules"
549           ;;
550         esac    
551     fi
552 else
553     if test "$random" = "auto"; then
554         # Build everything, allow to select at runtime.
555         random_modules="$auto_random_modules"
556     else
557         random_modules="$random"
558     fi
559 fi
560
561
562 #
563 # Setup assembler stuff.
564 #
565 GNUPG_SYS_SYMBOL_UNDERSCORE()
566 AC_MSG_CHECKING(for mpi assembler functions)
567 if test -f $srcdir/mpi/config.links ; then
568     . $srcdir/mpi/config.links
569     AC_CONFIG_LINKS("$mpi_ln_list")
570     ac_cv_mpi_mod_list="$mpi_mod_list"
571     ac_cv_mpi_sflags="$mpi_sflags"
572     ac_cv_mpi_config_done="yes"
573     AC_MSG_RESULT(done)
574 else
575     AC_MSG_RESULT(failed)
576     AC_MSG_ERROR([mpi/config.links missing!])
577 fi
578 MPI_MOD_LIST_LO=""
579 MPI_MOD_LIST_O=""
580 if test "$ac_cv_mpi_mod_list" != ""; then
581   for i in $ac_cv_mpi_mod_list; do
582       MPI_MOD_LIST_LO="$MPI_MOD_LIST_LO $i.lo"
583       MPI_MOD_LIST_O="$MPI_MOD_LIST_O $i.o"
584   done
585 fi
586 AC_SUBST(MPI_MOD_LIST_LO)
587 AC_SUBST(MPI_MOD_LIST_O)
588 MPI_SFLAGS="$ac_cv_mpi_sflags"
589 AC_SUBST(MPI_SFLAGS)
590
591 # Allow users to append something to the version string without
592 # flagging it as development version.  The user version part is
593 # considered everything after a dash.
594 changequote(,)#
595 tmp_pat='[a-zA-Z]'
596 changequote([,])#
597 if echo "$VERSION" | sed 's/-.*//' | grep "$tmp_pat" >/dev/null ; then
598     AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
599               [Defined if this is not a regular release])
600 fi
601
602 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
603
604 # We don't check for GNU make anymore - automake should not have the
605 # old flaws anymore.
606 #GNUPG_CHECK_GNUMAKE
607
608 AC_ARG_ENABLE(gcc-warnings,
609               AC_HELP_STRING([--enable-gcc-warnings],
610                              [enable more verbose gcc warnings]),
611               [more_gcc_warnings="$enableval"],
612               [more_gcc_warnings="no"])
613
614 if test "$GCC" = yes; then
615     if test "$USE_MAINTAINER_MODE" = "yes" ||
616        test "$more_gcc_warnings" = "yes"; then
617         CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
618         if test "$more_gcc_warnings" = "yes"; then
619             CFLAGS="$CFLAGS -W -Wpointer-arith -Wbad-function-cast"
620             CFLAGS="$CFLAGS -Wwrite-strings -Wunreachable-code"
621             CFLAGS="$CFLAGS -Wno-sign-compare"
622         fi
623     else
624         CFLAGS="$CFLAGS -Wall"
625     fi
626 fi
627
628 #
629 # Make the version number in src/gcrypt.h the same as the one here.
630 # (this is easier than to have a *.in file just for one substitution)
631 #
632 GNUPG_FIX_HDR_VERSION([src/gcrypt.h], GCRYPT_VERSION)
633
634 AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION)
635 AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
636 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
637 AC_SUBST(LIBGCRYPT_THREAD_MODULES)
638
639 AC_CONFIG_COMMANDS([gcrypt-conf],[[
640 chmod +x src/libgcrypt-config
641 ]],[[
642 prefix=$prefix
643 exec_prefix=$exec_prefix
644 libdir=$libdir
645 datadir=$datadir
646 DATADIRNAME=$DATADIRNAME
647 ]])
648
649 #####################
650 #### Conclusion. ####
651 #####################
652
653 # Define conditional sources and config.h symbols depending on the
654 # selected ciphers, pubkey-ciphers, digests and random modules.
655
656 LIST_MEMBER(arcfour, $enabled_ciphers)
657 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
658 AC_DEFINE_UNQUOTED(USE_ARCFOUR, $found,
659                                  [Defined if this module should be included])
660
661 LIST_MEMBER(blowfish, $enabled_ciphers)
662 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
663 AC_DEFINE_UNQUOTED(USE_BLOWFISH, $found,
664                                   [Defined if this module should be included])
665
666 LIST_MEMBER(cast5, $enabled_ciphers)
667 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
668 AC_DEFINE_UNQUOTED(USE_CAST5, $found,
669                                [Defined if this module should be included])
670
671 LIST_MEMBER(des, $enabled_ciphers)
672 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
673 AC_DEFINE_UNQUOTED(USE_DES, $found,
674                              [Defined if this module should be included])
675
676 LIST_MEMBER(aes, $enabled_ciphers)
677 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
678 AC_DEFINE_UNQUOTED(USE_AES, $found,
679                              [Defined if this module should be included])
680
681 LIST_MEMBER(twofish, $enabled_ciphers)
682 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
683 AC_DEFINE_UNQUOTED(USE_TWOFISH, $found,
684                                  [Defined if this module should be included])
685
686 LIST_MEMBER(serpent, $enabled_ciphers)
687 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
688 AC_DEFINE_UNQUOTED(USE_SERPENT, $found,
689                                  [Defined if this module should be included])
690
691 LIST_MEMBER(rfc2268, $enabled_ciphers)
692 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo"
693 AC_DEFINE_UNQUOTED(USE_RFC2268, $found,
694                                  [Defined if this module should be included])
695
696 LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
697 test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
698 AC_DEFINE_UNQUOTED(USE_DSA, $found,
699                              [Defined if this module should be included])
700
701 LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
702 test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
703 AC_DEFINE_UNQUOTED(USE_RSA, $found,
704                             [Defined if this module should be included])
705
706 LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
707 test "$found" = "1" \ 
708      && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
709 AC_DEFINE_UNQUOTED(USE_ELGAMAL, $found,
710                                 [Defined if this module should be included])
711
712 LIST_MEMBER(crc, $enabled_digests)
713 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
714 AC_DEFINE_UNQUOTED(USE_CRC, $found,
715                             [Defined if this module should be included])
716
717 LIST_MEMBER(md4, $enabled_digests)
718 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
719 AC_DEFINE_UNQUOTED(USE_MD4, $found,
720                              [Defined if this module should be included])
721
722 LIST_MEMBER(md5, $enabled_digests)
723 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
724 AC_DEFINE_UNQUOTED(USE_MD5, $found,
725                              [Defined if this module should be included])
726
727 LIST_MEMBER(sha256, $enabled_digests)
728 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
729 AC_DEFINE_UNQUOTED(USE_SHA256, $found,
730                                 [Defined if this module should be included])
731
732 LIST_MEMBER(sha512, $enabled_digests)
733 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
734 AC_DEFINE_UNQUOTED(USE_SHA512, $found,
735                                 [Defined if this module should be included])
736
737 LIST_MEMBER(tiger, $enabled_digests)
738 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
739 AC_DEFINE_UNQUOTED(USE_TIGER, $found,
740                                [Defined if this module should be included])
741
742 LIST_MEMBER(whirlpool, $enabled_digests)
743 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
744 AC_DEFINE_UNQUOTED(USE_WHIRLPOOL, $found,
745                                [Defined if this module should be included])
746
747 # rmd160 and sha1 should be included always.
748 GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo sha1.lo"
749 AC_DEFINE_UNQUOTED(USE_RMD160, 1, [Defined if this module should be included])
750 AC_DEFINE_UNQUOTED(USE_SHA1, 1,   [Defined if this module should be included])
751
752 LIST_MEMBER(linux, $random_modules)
753 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo"
754 AC_DEFINE_UNQUOTED(USE_RNDLINUX, $found,
755                    [Defined if the /dev/random based RNG should be used.])
756
757
758 LIST_MEMBER(unix, $random_modules)
759 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
760 AC_DEFINE_UNQUOTED(USE_RNDUNIX, $found,
761                   [Defined if the default Unix RNG should be used.])
762 if test "$found" = "1"; then
763    print_egd_notice=yes
764 fi
765
766 LIST_MEMBER(egd, $random_modules)
767 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
768 AC_DEFINE_UNQUOTED(USE_RNDEGD, $found,
769                   [Defined if the EGD based RNG should be used.])
770
771 LIST_MEMBER(w32, $random_modules)
772 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
773 AC_DEFINE_UNQUOTED(USE_RNDW32, $found,
774                   [Defined if the Windows specific RNG should be used.])
775
776 AC_SUBST([GCRYPT_CIPHERS])
777 AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
778 AC_SUBST([GCRYPT_DIGESTS])
779 AC_SUBST([GCRYPT_RANDOM])
780
781 AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
782 AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
783 AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
784
785 AC_CONFIG_FILES([
786 Makefile
787 mpi/Makefile
788 cipher/Makefile
789 doc/Makefile
790 src/Makefile
791 src/libgcrypt-config
792 tests/Makefile
793 w32-dll/Makefile
794 ])
795 AC_OUTPUT
796
797 # Give some feedback
798 echo
799
800 if test "$print_egd_notice" = "yes"; then
801 cat <<G10EOF
802   
803    The performance of the Unix random gatherer module (rndunix) is not
804    very good and it does not keep the entropy pool over multiple
805    invocations of GnuPG.  The suggested way to overcome this problem is
806    to use the
807   
808                  Entropy Gathering Daemon (EGD)
809   
810    which provides a entropy source for the whole system.  It is written
811    in Perl and available at the GnuPG FTP servers.  To enable EGD you
812    should rerun configure with the option "--enable-static-rnd=egd".
813    For more information consult the GnuPG webpages:
814   
815              http://www.gnupg.org/download.html#egd
816
817 G10EOF
818 fi
819
820 warn=""
821 for file in "random_modules"; do
822   case "$file" in rndunix | rndw32) warn="$warn $file";; esac
823 done
824 if test -n "$warn"; then
825   echo "Please note that you are building a version of Libgcrypt with"
826   echo "  $warn"
827   echo "included.  These parts are licensed under the GPL and thus the"
828   echo "use of this library has to comply with the conditions of the GPL."
829 fi
830
831 # Give some feedback
832 echo   "                Configured for: $PRINTABLE_OS_NAME ($target)"
833 echo