ChangeLog:
[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 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 whirlpool"
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_SEARCH_LIBS(setsockopt, [socket], ,
432         [AC_SEARCH_LIBS(setsockopt, [socket], , , [-lnsl])])
433 AC_SEARCH_LIBS(setsockopt, [nsl])
434
435 ##################################
436 #### Checks for header files. ####
437 ##################################
438
439 AC_HEADER_STDC
440 AC_CHECK_HEADERS(unistd.h sys/select.h)
441
442 ##########################################
443 #### Checks for typedefs, structures, ####
444 ####  and compiler characteristics.   ####
445 ##########################################
446
447 AC_C_CONST
448 AC_C_INLINE
449 AC_TYPE_SIZE_T
450 AC_TYPE_SIGNAL
451 AC_DECL_SYS_SIGLIST
452
453 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
454 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
455 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
456 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
457 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
458
459 AC_CHECK_TYPE(socklen_t,,
460               [AC_DEFINE_UNQUOTED([socklen_t],
461                                   [int],
462                                   [Define to `int' if unavailable.])],
463               [
464 #include <sys/types.h>
465 #include <sys/socket.h>
466               ])
467
468 TYPE_SOCKLEN_T
469
470 #######################################
471 #### Checks for library functions. ####
472 #######################################
473
474 AC_FUNC_VPRINTF
475 # We have replacements for these in src/missing-string.c
476 AC_CHECK_FUNCS(stpcpy strcasecmp)
477 # We have replacements for these in src/g10lib.h
478 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
479 # Other checks
480 AC_CHECK_FUNCS(strerror rand mmap getpagesize waitpid wait4)
481 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime)
482
483 GNUPG_CHECK_MLOCK
484
485 # Check whether we can use Linux capabilities as requested.
486 if test "$use_capabilities" = "yes" ; then
487 use_capabilities=no
488 AC_CHECK_HEADERS(sys/capability.h)
489 if test "$ac_cv_header_sys_capability_h" = "yes" ; then
490   AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
491   if test "$ac_cv_lib_cap_cap_init" = "yes"; then
492      AC_DEFINE(USE_CAPABILITIES,1,
493                [define if capabilities should be used])
494      LIBS="$LIBS -lcap"
495      use_capabilities=yes
496   fi
497 fi
498 if test "$use_capabilities" = "no" ; then
499     AC_MSG_WARN([[
500 ***
501 *** The use of capabilities on this system is not possible.
502 *** You need a recent Linux kernel and some patches:
503 ***   fcaps-2.2.9-990610.patch      (kernel patch for 2.2.9)
504 ***   fcap-module-990613.tar.gz     (kernel module)
505 ***   libcap-1.92.tar.gz            (user mode library and utilities)
506 *** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
507 *** set (filesystems menu). Be warned: This code is *really* ALPHA.
508 ***]])
509 fi
510 fi
511
512 # Check whether a random device is available.
513 if test "$try_dev_random" = yes ; then
514     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
515     [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
516       ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
517     if test "$ac_cv_have_dev_random" = yes; then
518         AC_DEFINE(HAVE_DEV_RANDOM,1,
519                  [defined if the system supports a random device] )
520     fi
521 else
522     AC_MSG_CHECKING(for random device)
523     ac_cv_have_dev_random=no
524     AC_MSG_RESULT(has been disabled)
525 fi
526
527 # Figure out the random modules for this configuration.
528 if test "$random" = "default"; then
529
530     # Select default value.
531     if test "$ac_cv_have_dev_random" = yes; then
532         # Try Linuxish random device.
533         random_modules="linux"
534     else
535         case "${target}" in
536         *-*-mingw32*|*-*-cygwin*)
537           # Windows random device.
538           random_modules="w32"
539           ;;
540         *)
541           # Build everything, allow to select at runtime.
542           random_modules="$auto_random_modules"
543           ;;
544         esac    
545     fi
546 else
547     if test "$random" = "auto"; then
548         # Build everything, allow to select at runtime.
549         random_modules="$auto_random_modules"
550     else
551         random_modules="$random"
552     fi
553 fi
554
555
556 #
557 # Setup assembler stuff.
558 #
559 GNUPG_SYS_SYMBOL_UNDERSCORE()
560 AC_MSG_CHECKING(for mpi assembler functions)
561 if test -f $srcdir/mpi/config.links ; then
562     . $srcdir/mpi/config.links
563     AC_CONFIG_LINKS("$mpi_ln_list")
564     ac_cv_mpi_mod_list="$mpi_mod_list"
565     ac_cv_mpi_sflags="$mpi_sflags"
566     ac_cv_mpi_config_done="yes"
567     AC_MSG_RESULT(done)
568 else
569     AC_MSG_RESULT(failed)
570     AC_MSG_ERROR([mpi/config.links missing!])
571 fi
572 MPI_MOD_LIST_LO=""
573 MPI_MOD_LIST_O=""
574 if test "$ac_cv_mpi_mod_list" != ""; then
575   for i in $ac_cv_mpi_mod_list; do
576       MPI_MOD_LIST_LO="$MPI_MOD_LIST_LO $i.lo"
577       MPI_MOD_LIST_O="$MPI_MOD_LIST_O $i.o"
578   done
579 fi
580 AC_SUBST(MPI_MOD_LIST_LO)
581 AC_SUBST(MPI_MOD_LIST_O)
582 MPI_SFLAGS="$ac_cv_mpi_sflags"
583 AC_SUBST(MPI_SFLAGS)
584
585 # Allow users to append something to the version string without
586 # flagging it as development version.  The user version part is
587 # considered everything after a dash.
588 changequote(,)#
589 tmp_pat='[a-zA-Z]'
590 changequote([,])#
591 if echo "$VERSION" | sed 's/-.*//' | grep "$tmp_pat" >/dev/null ; then
592     AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
593               [Defined if this is not a regular release])
594 fi
595
596 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
597
598 # We don't check for GNU make anymore - automake should not have the
599 # old flaws anymore.
600 #GNUPG_CHECK_GNUMAKE
601
602 AC_ARG_ENABLE(gcc-warnings,
603               AC_HELP_STRING([--enable-gcc-warnings],
604                              [enable more verbose gcc warnings]),
605               [more_gcc_warnings="$enableval"],
606               [more_gcc_warnings="no"])
607
608 if test "$GCC" = yes; then
609     if test "$USE_MAINTAINER_MODE" = "yes" ||
610        test "$more_gcc_warnings" = "yes"; then
611         CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
612         if test "$more_gcc_warnings" = "yes"; then
613             CFLAGS="$CFLAGS -W -Wpointer-arith -Wbad-function-cast"
614             CFLAGS="$CFLAGS -Wwrite-strings -Wunreachable-code"
615             CFLAGS="$CFLAGS -Wno-sign-compare"
616         fi
617     else
618         CFLAGS="$CFLAGS -Wall"
619     fi
620 fi
621
622 #
623 # Make the version number in src/gcrypt.h the same as the one here.
624 # (this is easier than to have a *.in file just for one substitution)
625 #
626 GNUPG_FIX_HDR_VERSION([src/gcrypt.h], GCRYPT_VERSION)
627
628 AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION)
629 AC_SUBST(LIBGCRYPT_CONFIG_LIBS)
630 AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS)
631 AC_SUBST(LIBGCRYPT_THREAD_MODULES)
632
633 AC_CONFIG_COMMANDS([gcrypt-conf],[[
634 chmod +x src/libgcrypt-config
635 ]],[[
636 prefix=$prefix
637 exec_prefix=$exec_prefix
638 libdir=$libdir
639 datadir=$datadir
640 DATADIRNAME=$DATADIRNAME
641 ]])
642
643 #####################
644 #### Conclusion. ####
645 #####################
646
647 # Define conditional sources and config.h symbols depending on the
648 # selected ciphers, pubkey-ciphers, digests and random modules.
649
650 LIST_MEMBER(arcfour, $enabled_ciphers)
651 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo"
652 AC_DEFINE_UNQUOTED(USE_ARCFOUR, $found,
653                                  [Defined if this module should be included])
654
655 LIST_MEMBER(blowfish, $enabled_ciphers)
656 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo"
657 AC_DEFINE_UNQUOTED(USE_BLOWFISH, $found,
658                                   [Defined if this module should be included])
659
660 LIST_MEMBER(cast5, $enabled_ciphers)
661 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo"
662 AC_DEFINE_UNQUOTED(USE_CAST5, $found,
663                                [Defined if this module should be included])
664
665 LIST_MEMBER(des, $enabled_ciphers)
666 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo"
667 AC_DEFINE_UNQUOTED(USE_DES, $found,
668                              [Defined if this module should be included])
669
670 LIST_MEMBER(aes, $enabled_ciphers)
671 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo"
672 AC_DEFINE_UNQUOTED(USE_AES, $found,
673                              [Defined if this module should be included])
674
675 LIST_MEMBER(twofish, $enabled_ciphers)
676 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo"
677 AC_DEFINE_UNQUOTED(USE_TWOFISH, $found,
678                                  [Defined if this module should be included])
679
680 LIST_MEMBER(serpent, $enabled_ciphers)
681 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo"
682 AC_DEFINE_UNQUOTED(USE_SERPENT, $found,
683                                  [Defined if this module should be included])
684
685 LIST_MEMBER(rfc2268, $enabled_ciphers)
686 test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo"
687 AC_DEFINE_UNQUOTED(USE_RFC2268, $found,
688                                  [Defined if this module should be included])
689
690 LIST_MEMBER(dsa, $enabled_pubkey_ciphers)
691 test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo"
692 AC_DEFINE_UNQUOTED(USE_DSA, $found,
693                              [Defined if this module should be included])
694
695 LIST_MEMBER(rsa, $enabled_pubkey_ciphers)
696 test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo"
697 AC_DEFINE_UNQUOTED(USE_RSA, $found,
698                             [Defined if this module should be included])
699
700 LIST_MEMBER(elgamal, $enabled_pubkey_ciphers)
701 test "$found" = "1" \ 
702      && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo"
703 AC_DEFINE_UNQUOTED(USE_ELGAMAL, $found,
704                                 [Defined if this module should be included])
705
706 LIST_MEMBER(crc, $enabled_digests)
707 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo"
708 AC_DEFINE_UNQUOTED(USE_CRC, $found,
709                             [Defined if this module should be included])
710
711 LIST_MEMBER(md4, $enabled_digests)
712 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo"
713 AC_DEFINE_UNQUOTED(USE_MD4, $found,
714                              [Defined if this module should be included])
715
716 LIST_MEMBER(md5, $enabled_digests)
717 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo"
718 AC_DEFINE_UNQUOTED(USE_MD5, $found,
719                              [Defined if this module should be included])
720
721 LIST_MEMBER(sha256, $enabled_digests)
722 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo"
723 AC_DEFINE_UNQUOTED(USE_SHA256, $found,
724                                 [Defined if this module should be included])
725
726 LIST_MEMBER(sha512, $enabled_digests)
727 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo"
728 AC_DEFINE_UNQUOTED(USE_SHA512, $found,
729                                 [Defined if this module should be included])
730
731 LIST_MEMBER(tiger, $enabled_digests)
732 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo"
733 AC_DEFINE_UNQUOTED(USE_TIGER, $found,
734                                [Defined if this module should be included])
735
736 LIST_MEMBER(whirlpool, $enabled_digests)
737 test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo"
738 AC_DEFINE_UNQUOTED(USE_WHIRLPOOL, $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 src/libgcrypt.pc
787 tests/Makefile
788 w32-dll/Makefile
789 ])
790 AC_OUTPUT
791
792 # Give some feedback
793 echo
794
795 if test "$print_egd_notice" = "yes"; then
796 cat <<G10EOF
797   
798    The performance of the Unix random gatherer module (rndunix) is not
799    very good and it does not keep the entropy pool over multiple
800    invocations of GnuPG.  The suggested way to overcome this problem is
801    to use the
802   
803                  Entropy Gathering Daemon (EGD)
804   
805    which provides a entropy source for the whole system.  It is written
806    in Perl and available at the GnuPG FTP servers.  To enable EGD you
807    should rerun configure with the option "--enable-static-rnd=egd".
808    For more information consult the GnuPG webpages:
809   
810              http://www.gnupg.org/download.html#egd
811
812 G10EOF
813 fi
814
815 warn=""
816 for file in "random_modules"; do
817   case "$file" in rndunix | rndw32) warn="$warn $file";; esac
818 done
819 if test -n "$warn"; then
820   echo "Please note that you are building a version of Libgcrypt with"
821   echo "  $warn"
822   echo "included.  These parts are licensed under the GPL and thus the"
823   echo "use of this library has to comply with the conditions of the GPL."
824 fi
825
826 # Give some feedback
827 echo   "                Configured for: $PRINTABLE_OS_NAME ($target)"
828 echo