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