Various cleanups
[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 AC_ARG_ENABLE(gcc-warnings,
628               AC_HELP_STRING([--enable-gcc-warnings],
629                              [enable more verbose gcc warnings]),
630               [more_gcc_warnings="$enableval"],
631               [more_gcc_warnings="no"])
632
633 if test "$GCC" = yes; then
634     if test "$USE_MAINTAINER_MODE" = "yes" ||
635        test "$more_gcc_warnings" = "yes"; then
636         CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
637         if test "$more_gcc_warnings" = "yes"; then
638             CFLAGS="$CFLAGS -W -Wpointer-arith -Wbad-function-cast"
639             CFLAGS="$CFLAGS -Wwrite-strings -Wunreachable-code"
640             CFLAGS="$CFLAGS -Wno-sign-compare"
641         fi
642     else
643         CFLAGS="$CFLAGS -Wall"
644     fi
645 fi
646
647 #
648 # Make the version number in src/gcrypt.h the same as the one here.
649 # (this is easier than to have a *.in file just for one substitution)
650 #
651 GNUPG_FIX_HDR_VERSION([src/gcrypt.h], GCRYPT_VERSION)
652
653 AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
654 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
655 AC_SUBST(LIBGCRYPT_CONFIG_LIBS_PTHREAD)
656 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS_PTHREAD)
657 AC_SUBST(LIBGCRYPT_CONFIG_LIBS_PTH)
658 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS_PTH)
659 AC_SUBST(LIBGCRYPT_THREAD_MODULES)
660
661 AC_CONFIG_COMMANDS([gcrypt-conf],[[
662 chmod +x src/libgcrypt-config
663 ]],[[
664 prefix=$prefix
665 exec_prefix=$exec_prefix
666 libdir=$libdir
667 datadir=$datadir
668 DATADIRNAME=$DATADIRNAME
669 ]])
670
671 #####################
672 #### Conclusion. ####
673 #####################
674
675 # Define conditional sources and config.h symbols depending on the
676 # selected ciphers, pubkey-ciphers, digests and random modules.
677
678 LIST_MEMBER(arcfour, $enabled_ciphers)
679 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
680 AC_DEFINE_UNQUOTED(USE_ARCFOUR, $found,
681                                  [Defined if this module should be included])
682
683 LIST_MEMBER(blowfish, $enabled_ciphers)
684 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
685 AC_DEFINE_UNQUOTED(USE_BLOWFISH, $found,
686                                   [Defined if this module should be included])
687
688 LIST_MEMBER(cast5, $enabled_ciphers)
689 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
690 AC_DEFINE_UNQUOTED(USE_CAST5, $found,
691                                [Defined if this module should be included])
692
693 LIST_MEMBER(des, $enabled_ciphers)
694 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
695 AC_DEFINE_UNQUOTED(USE_DES, $found,
696                              [Defined if this module should be included])
697
698 LIST_MEMBER(aes, $enabled_ciphers)
699 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
700 AC_DEFINE_UNQUOTED(USE_AES, $found,
701                              [Defined if this module should be included])
702
703 LIST_MEMBER(twofish, $enabled_ciphers)
704 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
705 AC_DEFINE_UNQUOTED(USE_TWOFISH, $found,
706                                  [Defined if this module should be included])
707
708 LIST_MEMBER(serpent, $enabled_ciphers)
709 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
710 AC_DEFINE_UNQUOTED(USE_SERPENT, $found,
711                                  [Defined if this module should be included])
712
713 LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
714 test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
715 AC_DEFINE_UNQUOTED(USE_DSA, $found,
716                              [Defined if this module should be included])
717
718 LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
719 test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
720 AC_DEFINE_UNQUOTED(USE_RSA, $found,
721                             [Defined if this module should be included])
722
723 LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
724 test "$found" = "1" \ 
725      && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
726 AC_DEFINE_UNQUOTED(USE_ELGAMAL, $found,
727                                 [Defined if this module should be included])
728
729 LIST_MEMBER(crc, $enabled_digests)
730 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
731 AC_DEFINE_UNQUOTED(USE_CRC, $found,
732                             [Defined if this module should be included])
733
734 LIST_MEMBER(md4, $enabled_digests)
735 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
736 AC_DEFINE_UNQUOTED(USE_MD4, $found,
737                              [Defined if this module should be included])
738
739 LIST_MEMBER(md5, $enabled_digests)
740 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
741 AC_DEFINE_UNQUOTED(USE_MD5, $found,
742                              [Defined if this module should be included])
743
744 LIST_MEMBER(sha1, $enabled_digests)
745 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1.lo"
746 AC_DEFINE_UNQUOTED(USE_SHA1, $found,
747                              [Defined if this module should be included])
748
749 LIST_MEMBER(sha256, $enabled_digests)
750 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
751 AC_DEFINE_UNQUOTED(USE_SHA256, $found,
752                                 [Defined if this module should be included])
753
754 LIST_MEMBER(sha512, $enabled_digests)
755 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
756 AC_DEFINE_UNQUOTED(USE_SHA512, $found,
757                                 [Defined if this module should be included])
758
759 LIST_MEMBER(tiger, $enabled_digests)
760 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
761 AC_DEFINE_UNQUOTED(USE_TIGER, $found,
762                                [Defined if this module should be included])
763
764 # rmd160 should be included always.
765 GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo"
766 AM_CONDITIONAL(USE_RMD160, true)
767 AC_DEFINE_UNQUOTED(USE_RMD160, 1, [Defined if this module should be included])
768
769 LIST_MEMBER(linux, $random_modules)
770 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo"
771 AC_DEFINE_UNQUOTED(USE_RNDLINUX, $found,
772                    [Defined if the /dev/random based RNG should be used.])
773
774
775 LIST_MEMBER(unix, $random_modules)
776 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
777 AC_DEFINE_UNQUOTED(USE_RNDUNIX, $found,
778                   [Defined if the default Unix RNG should be used.])
779 if test "$found" = "1"; then
780    print_egd_notice=yes
781 fi
782
783 LIST_MEMBER(egd, $random_modules)
784 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
785 AC_DEFINE_UNQUOTED(USE_RNDEGD, $found,
786                   [Defined if the EGD based RNG should be used.])
787
788 LIST_MEMBER(w32, $random_modules)
789 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
790 AC_DEFINE_UNQUOTED(USE_RNDW32, $found,
791                   [Defined if the Windows specific RNG should be used.])
792
793 AC_SUBST([GCRYPT_CIPHERS])
794 AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
795 AC_SUBST([GCRYPT_DIGESTS])
796 AC_SUBST([GCRYPT_RANDOM])
797
798 AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
799 AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
800 AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
801
802 AC_CONFIG_FILES([
803 Makefile
804 mpi/Makefile
805 cipher/Makefile
806 doc/Makefile
807 src/Makefile
808 src/libgcrypt-config
809 tests/Makefile
810 w32-dll/Makefile
811 ])
812 AC_OUTPUT
813
814 # Give some feedback
815 echo
816
817 if test "$print_egd_notice" = "yes"; then
818 cat <<G10EOF
819   
820    The performance of the Unix random gatherer module (rndunix) is not
821    very good and it does not keep the entropy pool over multiple
822    invocations of GnuPG.  The suggested way to overcome this problem is
823    to use the
824   
825                  Entropy Gathering Daemon (EGD)
826   
827    which provides a entropy source for the whole system.  It is written
828    in Perl and available at the GnuPG FTP servers.  To enable EGD you
829    should rerun configure with the option "--enable-static-rnd=egd".
830    For more information consult the GnuPG webpages:
831   
832              http://www.gnupg.org/download.html#egd
833
834 G10EOF
835 fi
836
837 warn=""
838 for file in "random_modules"; do
839   case "$file" in rndunix | rndw32) warn="$warn $file";; esac
840 done
841 if test -n "$warn"; then
842   echo "Please note that you are building a version of Libgcrypt with"
843   echo "  $warn"
844   echo "included.  These parts are licensed under the GPL and thus the"
845   echo "use of this library has to comply with the conditions of the GPL."
846 fi
847
848 # Give some feedback
849 echo   "                Configured for: $PRINTABLE_OS_NAME ($target)"
850 echo
851
852