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