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