2006-01-08 Moritz Schulte <moritz@g10code.com>
[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.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/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
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 AM_PROG_LIBTOOL
102
103
104 ##########################
105 ## General definitions. ##
106 ##########################
107
108 # Used by libgcrypt-config
109 LIBGCRYPT_CONFIG_LIBS="-lgcrypt"
110 LIBGCRYPT_CONFIG_CFLAGS=""
111
112 # Definitions for symmetric ciphers.
113 available_ciphers="arcfour blowfish cast5 des aes twofish serpent rfc2268"
114 enabled_ciphers=""
115
116 # Definitions for public-key ciphers.
117 available_pubkey_ciphers="dsa elgamal rsa"
118 enabled_pubkey_ciphers=""
119
120 # Definitions for message digests.
121 available_digests="crc md4 md5 rmd160 sha1 sha256"
122 available_digests_64="sha512 tiger whirlpool"
123 enabled_digests=""
124
125 # Definitions for random modules.
126 available_random_modules="linux egd unix"
127 auto_random_modules="$available_random_modules"
128
129 # Supported thread backends.
130 LIBGCRYPT_THREAD_MODULES=""
131
132 # Other definitions.
133 print_egd_notice=no
134
135 # Setup some stuff depending on host/target.
136 case "${target}" in
137     *-*-mingw32*)
138       available_random_modules="w32"
139       ac_cv_have_dev_random=no
140       AC_DEFINE(USE_ONLY_8DOT3,1,
141                 [set this to limit filenames to the 8.3 format])
142       AC_DEFINE(HAVE_DRIVE_LETTERS,1,
143                 [defined if we must run on a stupid file system])
144       AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
145                 [defined if we run on some of the PCDOS like systems 
146                  (DOS, Windoze. OS/2) with special properties like
147                   no file modes])
148       ;;
149
150     i?86-emx-os2 | i?86-*-os2*emx)
151         # OS/2 with the EMX environment
152         ac_cv_have_dev_random=no
153         AC_DEFINE(HAVE_DRIVE_LETTERS)
154         AC_DEFINE(HAVE_DOSISH_SYSTEM)
155         ;;
156
157     i?86-*-msdosdjgpp*)
158         # DOS with the DJGPP environment
159         ac_cv_have_dev_random=no
160         AC_DEFINE(HAVE_DRIVE_LETTERS)
161         AC_DEFINE(HAVE_DOSISH_SYSTEM)
162         ;;
163
164     *-*-freebsd*)
165        # FreeBSD
166        CPPFLAGS="$CPPFLAGS -I/usr/local/include"
167        LDFLAGS="$LDFLAGS -L/usr/local/lib"
168        ;;
169
170     *-*-hpux*)
171         if test -z "$GCC" ; then
172             CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
173         fi
174         ;;
175     *-dec-osf4*)
176         if test -z "$GCC" ; then
177             # Suppress all warnings
178             # to get rid of the unsigned/signed char mismatch warnings.
179             CFLAGS="$CFLAGS -w"
180         fi
181         ;;
182     m68k-atari-mint)
183         ;;
184     *)
185       ;;
186 esac
187
188 # A printable OS Name is sometime useful.
189 case "${target}" in
190     *-*-mingw32*)
191         PRINTABLE_OS_NAME="MingW32"
192         ;;
193
194     i?86-emx-os2 | i?86-*-os2*emx )
195         PRINTABLE_OS_NAME="OS/2"
196         ;;
197
198     i?86-*-msdosdjgpp*)
199         PRINTABLE_OS_NAME="MSDOS/DJGPP"
200         ;;
201
202     *-linux*)
203         PRINTABLE_OS_NAME="GNU/Linux"
204         ;;
205
206     *)
207         PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
208         ;;
209 esac
210
211
212 case "${target}" in
213     *-openbsd*)
214         # FIXME: Are these the best flags for OpenBSD?
215         NAME_OF_DEV_RANDOM="/dev/srandom"
216         NAME_OF_DEV_URANDOM="/dev/urandom"
217 #       DYNLINK_MOD_CFLAGS="-shared -rdynamic $CFLAGS_PIC -Wl,-Bshareable -Wl,-x"
218         ;;
219
220     *-solaris* | *-irix* | *-dec-osf* | *-netbsd* )
221         NAME_OF_DEV_RANDOM="/dev/random"
222         NAME_OF_DEV_URANDOM="/dev/random"
223 #       DYNLINK_MOD_CFLAGS="-shared $CFLAGS_PIC"
224         ;;
225
226     *)
227         NAME_OF_DEV_RANDOM="/dev/random"
228         NAME_OF_DEV_URANDOM="/dev/urandom"
229         # -shared is a gcc-ism.  Find pic flags from GNUPG_CHECK_PIC.
230 #        if test -n "$GCC" ; then
231 #           DYNLINK_MOD_CFLAGS="-shared $CFLAGS_PIC"                            
232 #        else
233 #           DYNLINK_MOD_CFLAGS="$CFLAGS_PIC"
234 #        fi
235         ;;
236 esac
237
238
239 AC_C_BIGENDIAN
240
241 AC_CHECK_SIZEOF(unsigned short, 2)
242 AC_CHECK_SIZEOF(unsigned int, 4)
243 AC_CHECK_SIZEOF(unsigned long, 4)
244 AC_CHECK_SIZEOF(unsigned long long, 0)
245
246 if test "$ac_cv_sizeof_unsigned_short" = "0" \
247    || test "$ac_cv_sizeof_unsigned_int" = "0" \
248    || test "$ac_cv_sizeof_unsigned_long" = "0"; then
249     AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
250 fi
251
252 # Do we have any 64-bit data types?
253 if test "$ac_cv_sizeof_unsigned_int" != "8" \
254    && test "$ac_cv_sizeof_unsigned_long" != "8" \
255    && test "$ac_cv_sizeof_unsigned_long_long" != "8" \
256    && test "$ac_cv_sizeof_uint64_t" != "8"; then
257     AC_MSG_WARN([No 64-bit types.  Disabling TIGER/192, SHA-384, and SHA-512])
258 else
259   available_digests="$available_digests $available_digests_64"
260 fi
261
262 # If not specified otherwise, all available algorithms will be
263 # included.
264 default_ciphers="$available_ciphers"
265 default_pubkey_ciphers="$available_pubkey_ciphers"
266 default_digests="$available_digests"
267
268 ############################
269 ## Command line switches. ##
270 ############################
271
272 # Implementation of the --enable-ciphers switch.
273 AC_ARG_ENABLE(ciphers,
274               AC_HELP_STRING([--enable-ciphers=ciphers],
275                              [select the symmetric ciphers to include]),
276               [enabled_ciphers=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`],
277               [enabled_ciphers=""])
278 if test "x$enabled_ciphers" = "x" \
279    -o "$enabled_ciphers" = "yes"  \
280    -o "$enabled_ciphers" = "no"; then
281    enabled_ciphers=$default_ciphers
282 fi
283 AC_MSG_CHECKING([which symmetric ciphers to include])
284 for cipher in $enabled_ciphers; do
285     LIST_MEMBER($cipher, $available_ciphers)
286     if test "$found" = "0"; then
287        AC_MSG_ERROR([unsupported cipher specified])
288     fi
289 done
290 AC_MSG_RESULT([$enabled_ciphers])
291
292 # Implementation of the --enable-pubkey-ciphers switch.
293 AC_ARG_ENABLE(pubkey-ciphers,
294               AC_HELP_STRING([--enable-pubkey-ciphers=ciphers],
295                              [select the public-key ciphers to include]),
296               [enabled_pubkey_ciphers=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`],
297               [enabled_pubkey_ciphers=""])
298 if test "x$enabled_pubkey_ciphers" = "x" \
299    -o "$enabled_pubkey_ciphers" = "yes"  \
300    -o "$enabled_pubkey_ciphers" = "no"; then
301    enabled_pubkey_ciphers=$default_pubkey_ciphers
302 fi
303 AC_MSG_CHECKING([which public-key ciphers to include])
304 for cipher in $enabled_pubkey_ciphers; do
305     LIST_MEMBER($cipher, $available_pubkey_ciphers)
306     if test "$found" = "0"; then
307        AC_MSG_ERROR([unsupported public-key cipher specified])
308     fi
309 done
310 AC_MSG_RESULT([$enabled_pubkey_ciphers])
311
312 # Implementation of the --enable-digests switch.
313 AC_ARG_ENABLE(digests,
314               AC_HELP_STRING([--enable-digests=digests],
315                              [select the message digests to include]),
316               [enabled_digests=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`],
317               [enabled_digests=""])
318 if test "x$enabled_digests" = "x" \
319    -o "$enabled_digests" = "yes"  \
320    -o "$enabled_digests" = "no"; then
321    enabled_digests=$default_digests
322 fi
323 AC_MSG_CHECKING([which message digests to include])
324 for digest in $enabled_digests; do
325     LIST_MEMBER($digest, $available_digests)
326     if test "$found" = "0"; then
327        AC_MSG_ERROR([unsupported message digest specified])
328     fi
329 done
330 AC_MSG_RESULT([$enabled_digests])
331
332 # Implementation of the --enable-random switch.
333 AC_ARG_ENABLE(random,
334               AC_HELP_STRING([--enable-random=name],
335                              [select which random number generator to use]),
336               [random=`echo $enableval | tr '[A-Z]' '[a-z]'`],
337               [])
338 if test "x$random" = "x" -o "$random" = "yes" -o "$random" = "no"; then
339     random=default
340 fi
341 AC_MSG_CHECKING([which random module to use])
342 if test "$random" != "default" -a "$random" != "auto"; then
343     LIST_MEMBER($random, $available_random_modules)
344     if test "$found" = "0"; then
345        AC_MSG_ERROR([unsupported random module specified])
346     fi
347 fi
348 AC_MSG_RESULT($random)
349
350 # Implementation of the --disable-dev-random switch.
351 AC_MSG_CHECKING([whether use of /dev/random is requested])
352 AC_ARG_ENABLE(dev-random,
353 [  --disable-dev-random    disable the use of dev random],
354     try_dev_random=$enableval, try_dev_random=yes)
355 AC_MSG_RESULT($try_dev_random)
356
357 # Implementation of the --with-egd-socket switch.
358 AC_ARG_WITH(egd-socket,
359     [  --with-egd-socket=NAME  Use NAME for the EGD socket)],
360             egd_socket_name="$withval", egd_socket_name="" )
361 AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, "$egd_socket_name",
362                    [Define if you don't want the default EGD socket name.
363                     For details see cipher/rndegd.c])
364
365 # Implementation of --disable-asm.
366 AC_MSG_CHECKING([whether assembler modules are requested])
367 AC_ARG_ENABLE([asm],
368               AC_HELP_STRING([--disable-asm],
369                              [Disable assembler modules]),
370               [try_asm_modules=$enableval],
371               [try_asm_modules=yes])
372 AC_MSG_RESULT($try_asm_modules)
373
374 # Implementation of the --enable-m-guard switch.
375 AC_MSG_CHECKING([whether memory guard is requested])
376 AC_ARG_ENABLE(m-guard,
377     [  --enable-m-guard        enable memory guard facility],
378     use_m_guard=$enableval, use_m_guard=no)
379     AC_MSG_RESULT($use_m_guard)
380 if test "$use_m_guard" = yes ; then
381     AC_DEFINE(M_GUARD,1,[Define to use the (obsolete) malloc guarding feature])
382 fi
383
384 # Implementation of the --with-capabilities switch.
385 # Check whether we want to use Linux capabilities
386 AC_MSG_CHECKING([whether use of capabilities is requested])
387 AC_ARG_WITH(capabilities,
388     [  --with-capabilities     use linux capabilities [default=no]],
389 [use_capabilities="$withval"],[use_capabilities=no])
390 AC_MSG_RESULT($use_capabilities)
391
392
393
394 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
395                    [A human readable text with the name of the OS])
396
397 # For some systems we know that we have ld_version scripts.  
398 # Use it then as default.
399 have_ld_version_script=no
400 case "${host}" in
401     *-*-linux*)
402         have_ld_version_script=yes
403         ;;
404     *-*-gnu*)
405         have_ld_version_script=yes
406         ;;
407 esac
408 AC_ARG_ENABLE([ld-version-script],
409               AC_HELP_STRING([--enable-ld-version-script],
410                              [enable/disable use of linker version script.
411                               (default is system dependent)]),
412               [have_ld_version_script=$enableval],
413               [ : ] )
414 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
415
416 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM",
417                    [defined to the name of the strong random device])
418 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM",
419                    [defined to the name of the weaker random device])
420
421 ###############################
422 #### Checks for libraries. ####
423 ###############################
424
425 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION")
426 if test "x$GPG_ERROR_LIBS" = "x"; then
427   AC_MSG_ERROR([libgpg-error is needed.
428                 See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .])
429 fi
430
431 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GCRYPT,
432           [The default error source for libgcrypt.])
433
434 # Solaris needs -lsocket and -lnsl. Unisys system includes
435 # gethostbyname in libsocket but needs libnsl for socket.
436 AC_SEARCH_LIBS(setsockopt, [socket], ,
437         [AC_SEARCH_LIBS(setsockopt, [socket], , , [-lnsl])])
438 AC_SEARCH_LIBS(setsockopt, [nsl])
439
440 ##################################
441 #### Checks for header files. ####
442 ##################################
443
444 AC_HEADER_STDC
445 AC_CHECK_HEADERS(unistd.h sys/select.h)
446
447 ##########################################
448 #### Checks for typedefs, structures, ####
449 ####  and compiler characteristics.   ####
450 ##########################################
451
452 AC_C_CONST
453 AC_C_INLINE
454 AC_TYPE_SIZE_T
455 AC_TYPE_SIGNAL
456 AC_DECL_SYS_SIGLIST
457
458 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
459 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
460 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
461 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
462 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
463
464 AC_CHECK_TYPE(socklen_t,,
465               [AC_DEFINE_UNQUOTED([socklen_t],
466                                   [int],
467                                   [Define to `int' if unavailable.])],
468               [
469 #include <sys/types.h>
470 #include <sys/socket.h>
471               ])
472
473 TYPE_SOCKLEN_T
474
475 #######################################
476 #### Checks for library functions. ####
477 #######################################
478
479 AC_FUNC_VPRINTF
480 # We have replacements for these in src/missing-string.c
481 AC_CHECK_FUNCS(stpcpy strcasecmp)
482 # We have replacements for these in src/g10lib.h
483 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
484 # Other checks
485 AC_CHECK_FUNCS(strerror rand mmap getpagesize waitpid wait4)
486 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime)
487
488 GNUPG_CHECK_MLOCK
489
490 # Check whether we can use Linux capabilities as requested.
491 if test "$use_capabilities" = "yes" ; then
492 use_capabilities=no
493 AC_CHECK_HEADERS(sys/capability.h)
494 if test "$ac_cv_header_sys_capability_h" = "yes" ; then
495   AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
496   if test "$ac_cv_lib_cap_cap_init" = "yes"; then
497      AC_DEFINE(USE_CAPABILITIES,1,
498                [define if capabilities should be used])
499      LIBS="$LIBS -lcap"
500      use_capabilities=yes
501   fi
502 fi
503 if test "$use_capabilities" = "no" ; then
504     AC_MSG_WARN([[
505 ***
506 *** The use of capabilities on this system is not possible.
507 *** You need a recent Linux kernel and some patches:
508 ***   fcaps-2.2.9-990610.patch      (kernel patch for 2.2.9)
509 ***   fcap-module-990613.tar.gz     (kernel module)
510 ***   libcap-1.92.tar.gz            (user mode library and utilities)
511 *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
512 *** set (filesystems menu). Be warned: This code is *really* ALPHA.
513 ***]])
514 fi
515 fi
516
517 # Check whether a random device is available.
518 if test "$try_dev_random" = yes ; then
519     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
520     [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
521       ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
522     if test "$ac_cv_have_dev_random" = yes; then
523         AC_DEFINE(HAVE_DEV_RANDOM,1,
524                  [defined if the system supports a random device] )
525     fi
526 else
527     AC_MSG_CHECKING(for random device)
528     ac_cv_have_dev_random=no
529     AC_MSG_RESULT(has been disabled)
530 fi
531
532 # Figure out the random modules for this configuration.
533 if test "$random" = "default"; then
534
535     # Select default value.
536     if test "$ac_cv_have_dev_random" = yes; then
537         # Try Linuxish random device.
538         random_modules="linux"
539     else
540         case "${target}" in
541         *-*-mingw32*|*-*-cygwin*)
542           # Windows random device.
543           random_modules="w32"
544           ;;
545         *)
546           # Build everything, allow to select at runtime.
547           random_modules="$auto_random_modules"
548           ;;
549         esac    
550     fi
551 else
552     if test "$random" = "auto"; then
553         # Build everything, allow to select at runtime.
554         random_modules="$auto_random_modules"
555     else
556         random_modules="$random"
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 LIST_MEMBER(whirlpool, $enabled_digests)
742 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
743 AC_DEFINE_UNQUOTED(USE_WHIRLPOOL, $found,
744                                [Defined if this module should be included])
745
746 # rmd160 and sha1 should be included always.
747 GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo sha1.lo"
748 AC_DEFINE_UNQUOTED(USE_RMD160, 1, [Defined if this module should be included])
749 AC_DEFINE_UNQUOTED(USE_SHA1, 1,   [Defined if this module should be included])
750
751 LIST_MEMBER(linux, $random_modules)
752 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo"
753 AC_DEFINE_UNQUOTED(USE_RNDLINUX, $found,
754                    [Defined if the /dev/random based RNG should be used.])
755
756
757 LIST_MEMBER(unix, $random_modules)
758 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo"
759 AC_DEFINE_UNQUOTED(USE_RNDUNIX, $found,
760                   [Defined if the default Unix RNG should be used.])
761 if test "$found" = "1"; then
762    print_egd_notice=yes
763 fi
764
765 LIST_MEMBER(egd, $random_modules)
766 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo"
767 AC_DEFINE_UNQUOTED(USE_RNDEGD, $found,
768                   [Defined if the EGD based RNG should be used.])
769
770 LIST_MEMBER(w32, $random_modules)
771 test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo"
772 AC_DEFINE_UNQUOTED(USE_RNDW32, $found,
773                   [Defined if the Windows specific RNG should be used.])
774
775 AC_SUBST([GCRYPT_CIPHERS])
776 AC_SUBST([GCRYPT_PUBKEY_CIPHERS])
777 AC_SUBST([GCRYPT_DIGESTS])
778 AC_SUBST([GCRYPT_RANDOM])
779
780 AC_SUBST(LIBGCRYPT_CIPHERS, $enabled_ciphers)
781 AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers)
782 AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests)
783
784 AC_CONFIG_FILES([
785 Makefile
786 mpi/Makefile
787 cipher/Makefile
788 doc/Makefile
789 src/Makefile
790 src/libgcrypt-config
791 tests/Makefile
792 w32-dll/Makefile
793 ])
794 AC_OUTPUT
795
796 # Give some feedback
797 echo
798
799 if test "$print_egd_notice" = "yes"; then
800 cat <<G10EOF
801   
802    The performance of the Unix random gatherer module (rndunix) is not
803    very good and it does not keep the entropy pool over multiple
804    invocations of GnuPG.  The suggested way to overcome this problem is
805    to use the
806   
807                  Entropy Gathering Daemon (EGD)
808   
809    which provides a entropy source for the whole system.  It is written
810    in Perl and available at the GnuPG FTP servers.  To enable EGD you
811    should rerun configure with the option "--enable-static-rnd=egd".
812    For more information consult the GnuPG webpages:
813   
814              http://www.gnupg.org/download.html#egd
815
816 G10EOF
817 fi
818
819 warn=""
820 for file in "random_modules"; do
821   case "$file" in rndunix | rndw32) warn="$warn $file";; esac
822 done
823 if test -n "$warn"; then
824   echo "Please note that you are building a version of Libgcrypt with"
825   echo "  $warn"
826   echo "included.  These parts are licensed under the GPL and thus the"
827   echo "use of this library has to comply with the conditions of the GPL."
828 fi
829
830 # Give some feedback
831 echo   "                Configured for: $PRINTABLE_OS_NAME ($target)"
832 echo