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