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 if test ".$gl_cv_socklen_t_equiv" = "."; then
525   FALLBACK_SOCKLEN_T="/* typedef socklen_t socklen_t; */"
526 else
527   FALLBACK_SOCKLEN_T="typedef ${gl_cv_socklen_t_equiv} socklen_t;"
528 fi
529 AC_SUBST(FALLBACK_SOCKLEN_T)
530
531
532 #######################################
533 #### Checks for library functions. ####
534 #######################################
535
536 AC_FUNC_VPRINTF
537 # We have replacements for these in src/missing-string.c
538 AC_CHECK_FUNCS(stpcpy strcasecmp)
539 # We have replacements for these in src/g10lib.h
540 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
541 # Other checks
542 AC_CHECK_FUNCS(strerror rand mmap getpagesize waitpid wait4)
543 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime)
544 AC_CHECK_FUNCS(fcntl ftruncate)
545
546 GNUPG_CHECK_MLOCK
547
548 # Check whether we can use Linux capabilities as requested.
549 if test "$use_capabilities" = "yes" ; then
550 use_capabilities=no
551 AC_CHECK_HEADERS(sys/capability.h)
552 if test "$ac_cv_header_sys_capability_h" = "yes" ; then
553   AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
554   if test "$ac_cv_lib_cap_cap_init" = "yes"; then
555      AC_DEFINE(USE_CAPABILITIES,1,
556                [define if capabilities should be used])
557      LIBS="$LIBS -lcap"
558      use_capabilities=yes
559   fi
560 fi
561 if test "$use_capabilities" = "no" ; then
562     AC_MSG_WARN([[
563 ***
564 *** The use of capabilities on this system is not possible.
565 *** You need a recent Linux kernel and some patches:
566 ***   fcaps-2.2.9-990610.patch      (kernel patch for 2.2.9)
567 ***   fcap-module-990613.tar.gz     (kernel module)
568 ***   libcap-1.92.tar.gz            (user mode library and utilities)
569 *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
570 *** set (filesystems menu). Be warned: This code is *really* ALPHA.
571 ***]])
572 fi
573 fi
574
575 # Check whether a random device is available.
576 if test "$try_dev_random" = yes ; then
577     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
578     [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
579       ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
580     if test "$ac_cv_have_dev_random" = yes; then
581         AC_DEFINE(HAVE_DEV_RANDOM,1,
582                  [defined if the system supports a random device] )
583     fi
584 else
585     AC_MSG_CHECKING(for random device)
586     ac_cv_have_dev_random=no
587     AC_MSG_RESULT(has been disabled)
588 fi
589
590 # Figure out the random modules for this configuration.
591 if test "$random" = "default"; then
592
593     # Select default value.
594     if test "$ac_cv_have_dev_random" = yes; then
595         # Try Linuxish random device.
596         random_modules="linux"
597     else
598         case "${target}" in
599         *-*-mingw32*|*-*-cygwin*)
600           # Windows random device.
601           random_modules="w32"
602           ;;
603         *)
604           # Build everything, allow to select at runtime.
605           random_modules="$auto_random_modules"
606           ;;
607         esac    
608     fi
609 else
610     if test "$random" = "auto"; then
611         # Build everything, allow to select at runtime.
612         random_modules="$auto_random_modules"
613     else
614         random_modules="$random"
615     fi
616 fi
617
618
619 #
620 # Setup assembler stuff.
621 #
622 GNUPG_SYS_SYMBOL_UNDERSCORE()
623 AC_MSG_CHECKING(for mpi assembler functions)
624 if test -f $srcdir/mpi/config.links ; then
625     . $srcdir/mpi/config.links
626     AC_CONFIG_LINKS("$mpi_ln_list")
627     ac_cv_mpi_mod_list="$mpi_mod_list"
628     ac_cv_mpi_sflags="$mpi_sflags"
629     ac_cv_mpi_config_done="yes"
630     AC_MSG_RESULT(done)
631 else
632     AC_MSG_RESULT(failed)
633     AC_MSG_ERROR([mpi/config.links missing!])
634 fi
635 MPI_MOD_LIST_LO=""
636 MPI_MOD_LIST_O=""
637 if test "$ac_cv_mpi_mod_list" != ""; then
638   for i in $ac_cv_mpi_mod_list; do
639       MPI_MOD_LIST_LO="$MPI_MOD_LIST_LO $i.lo"
640       MPI_MOD_LIST_O="$MPI_MOD_LIST_O $i.o"
641   done
642 fi
643 AC_SUBST(MPI_MOD_LIST_LO)
644 AC_SUBST(MPI_MOD_LIST_O)
645 MPI_SFLAGS="$ac_cv_mpi_sflags"
646 AC_SUBST(MPI_SFLAGS)
647
648 # Allow users to append something to the version string without
649 # flagging it as development version.  The user version part is
650 # considered everything after a dash.
651 changequote(,)#
652 tmp_pat='[a-zA-Z]'
653 changequote([,])#
654 if echo "$VERSION" | sed 's/-.*//' | grep "$tmp_pat" >/dev/null ; then
655     AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
656               [Defined if this is not a regular release])
657 fi
658
659 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
660
661
662 # This is handy for debugging so the compiler doesn't rearrange
663 # things and eliminate variables.
664 AC_ARG_ENABLE(optimization,
665        AC_HELP_STRING([--disable-optimization],
666                       [disable compiler optimization]),
667                       [if test $enableval = no ; then
668                          CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
669                        fi])
670
671 AC_ARG_ENABLE(gcc-warnings,
672               AC_HELP_STRING([--enable-gcc-warnings],
673                              [enable more verbose gcc warnings]),
674               [more_gcc_warnings="$enableval"],
675               [more_gcc_warnings="no"])
676
677 if test "$GCC" = yes; then
678     if test "$USE_MAINTAINER_MODE" = "yes" ||
679        test "$more_gcc_warnings" = "yes"; then
680         CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
681         if test "$more_gcc_warnings" = "yes"; then
682             CFLAGS="$CFLAGS -W -Wpointer-arith -Wbad-function-cast"
683             CFLAGS="$CFLAGS -Wwrite-strings -Wunreachable-code"
684             CFLAGS="$CFLAGS -Wno-sign-compare"
685         fi
686     else
687         CFLAGS="$CFLAGS -Wall"
688     fi
689
690     # Non exec stack hack.  Fixme: Write a test to check whether as
691     # can cope with it and use the enable-noexecstack option only to
692     # disable it in case it is required on some platforms.
693     if test "$noexecstack_support" = yes; then
694         NOEXECSTACK_FLAGS="-Wa,--noexecstack"
695     fi
696 fi
697 AC_SUBST(NOEXECSTACK_FLAGS)
698
699 AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION)
700 AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
701 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
702 AC_SUBST(LIBGCRYPT_THREAD_MODULES)
703
704 AC_CONFIG_COMMANDS([gcrypt-conf],[[
705 chmod +x src/libgcrypt-config
706 ]],[[
707 prefix=$prefix
708 exec_prefix=$exec_prefix
709 libdir=$libdir
710 datadir=$datadir
711 DATADIRNAME=$DATADIRNAME
712 ]])
713
714 #####################
715 #### Conclusion. ####
716 #####################
717
718 # Define conditional sources and config.h symbols depending on the
719 # selected ciphers, pubkey-ciphers, digests and random modules.
720
721 LIST_MEMBER(arcfour, $enabled_ciphers)
722 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
723 AC_DEFINE_UNQUOTED(USE_ARCFOUR, $found,
724                                  [Defined if this module should be included])
725
726 LIST_MEMBER(blowfish, $enabled_ciphers)
727 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
728 AC_DEFINE_UNQUOTED(USE_BLOWFISH, $found,
729                                   [Defined if this module should be included])
730
731 LIST_MEMBER(cast5, $enabled_ciphers)
732 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
733 AC_DEFINE_UNQUOTED(USE_CAST5, $found,
734                                [Defined if this module should be included])
735
736 LIST_MEMBER(des, $enabled_ciphers)
737 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
738 AC_DEFINE_UNQUOTED(USE_DES, $found,
739                              [Defined if this module should be included])
740
741 LIST_MEMBER(aes, $enabled_ciphers)
742 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
743 AC_DEFINE_UNQUOTED(USE_AES, $found,
744                              [Defined if this module should be included])
745
746 LIST_MEMBER(twofish, $enabled_ciphers)
747 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
748 AC_DEFINE_UNQUOTED(USE_TWOFISH, $found,
749                                  [Defined if this module should be included])
750
751 LIST_MEMBER(serpent, $enabled_ciphers)
752 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
753 AC_DEFINE_UNQUOTED(USE_SERPENT, $found,
754                                  [Defined if this module should be included])
755
756 LIST_MEMBER(rfc2268, $enabled_ciphers)
757 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo"
758 AC_DEFINE_UNQUOTED(USE_RFC2268, $found,
759                                  [Defined if this module should be included])
760
761 LIST_MEMBER(seed, $enabled_ciphers)
762 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS seed.lo"
763 AC_DEFINE_UNQUOTED(USE_SEED, $found,
764                              [Defined if this module should be included])
765
766 LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
767 test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
768 AC_DEFINE_UNQUOTED(USE_DSA, $found,
769                              [Defined if this module should be included])
770
771 LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
772 test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
773 AC_DEFINE_UNQUOTED(USE_RSA, $found,
774                             [Defined if this module should be included])
775
776 LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
777 test "$found" = "1" \ 
778      && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
779 AC_DEFINE_UNQUOTED(USE_ELGAMAL, $found,
780                                 [Defined if this module should be included])
781
782 LIST_MEMBER(crc, $enabled_digests)
783 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
784 AC_DEFINE_UNQUOTED(USE_CRC, $found,
785                             [Defined if this module should be included])
786
787 LIST_MEMBER(md4, $enabled_digests)
788 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
789 AC_DEFINE_UNQUOTED(USE_MD4, $found,
790                              [Defined if this module should be included])
791
792 LIST_MEMBER(md5, $enabled_digests)
793 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
794 AC_DEFINE_UNQUOTED(USE_MD5, $found,
795                              [Defined if this module should be included])
796
797 LIST_MEMBER(sha256, $enabled_digests)
798 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
799 AC_DEFINE_UNQUOTED(USE_SHA256, $found,
800                                 [Defined if this module should be included])
801
802 LIST_MEMBER(sha512, $enabled_digests)
803 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
804 AC_DEFINE_UNQUOTED(USE_SHA512, $found,
805                                 [Defined if this module should be included])
806
807 LIST_MEMBER(tiger, $enabled_digests)
808 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
809 AC_DEFINE_UNQUOTED(USE_TIGER, $found,
810                                [Defined if this module should be included])
811
812 LIST_MEMBER(whirlpool, $enabled_digests)
813 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
814 AC_DEFINE_UNQUOTED(USE_WHIRLPOOL, $found,
815                                [Defined if this module should be included])
816
817 # rmd160 and sha1 should be included always.
818 GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo sha1.lo"
819 AC_DEFINE_UNQUOTED(USE_RMD160, 1, [Defined if this module should be included])
820 AC_DEFINE_UNQUOTED(USE_SHA1, 1,   [Defined if this module should be included])
821
822 LIST_MEMBER(linux, $random_modules)
823 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo"
824 AC_DEFINE_UNQUOTED(USE_RNDLINUX, $found,
825                    [Defined if the /dev/random based RNG should be used.])
826
827
828 LIST_MEMBER(unix, $random_modules)
829 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
830 AC_DEFINE_UNQUOTED(USE_RNDUNIX, $found,
831                   [Defined if the default Unix RNG should be used.])
832 if test "$found" = "1"; then
833    print_egd_notice=yes
834 fi
835
836 LIST_MEMBER(egd, $random_modules)
837 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
838 AC_DEFINE_UNQUOTED(USE_RNDEGD, $found,
839                   [Defined if the EGD based RNG should be used.])
840
841 LIST_MEMBER(w32, $random_modules)
842 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
843 AC_DEFINE_UNQUOTED(USE_RNDW32, $found,
844                   [Defined if the Windows specific RNG should be used.])
845
846 AC_SUBST([GCRYPT_CIPHERS])
847 AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
848 AC_SUBST([GCRYPT_DIGESTS])
849 AC_SUBST([GCRYPT_RANDOM])
850
851 AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
852 AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
853 AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
854
855
856 AC_CONFIG_FILES([
857 Makefile
858 mpi/Makefile
859 cipher/Makefile
860 doc/Makefile
861 src/Makefile
862 src/gcrypt.h
863 src/libgcrypt-config
864 tests/Makefile
865 w32-dll/Makefile
866 ])
867 AC_OUTPUT
868
869 # Give some feedback
870 echo
871
872 if test "$print_egd_notice" = "yes"; then
873 cat <<G10EOF
874   
875    The performance of the Unix random gatherer module (rndunix) is not
876    very good and it does not keep the entropy pool over multiple
877    invocations of GnuPG.  The suggested way to overcome this problem is
878    to use the
879   
880                  Entropy Gathering Daemon (EGD)
881   
882    which provides a entropy source for the whole system.  It is written
883    in Perl and available at the GnuPG FTP servers.  To enable EGD you
884    should rerun configure with the option "--enable-static-rnd=egd".
885    For more information consult the GnuPG webpages:
886   
887              http://www.gnupg.org/download.html#egd
888
889 G10EOF
890 fi
891
892 warn=""
893 for file in "random_modules"; do
894   case "$file" in rndunix | rndw32) warn="$warn $file";; esac
895 done
896 if test -n "$warn"; then
897   echo "Please note that you are building a version of Libgcrypt with"
898   echo "  $warn"
899   echo "included.  These parts are licensed under the GPL and thus the"
900   echo "use of this library has to comply with the conditions of the GPL."
901 fi
902
903 # Give some feedback
904 echo   "                Configured for: $PRINTABLE_OS_NAME ($target)"
905 echo