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