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